?
Solved

set JPanel size

Posted on 2004-04-16
5
Medium Priority
?
389 Views
Last Modified: 2012-06-27
How can i set the JPanel size?

Can i use setPreferredSize(100,100);?

thanks
0
Comment
Question by:Kennywen
  • 2
  • 2
5 Comments
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10840273
use setSize(100,100);

setPreferredSize(100,100) also will work.


Regards,
Muruga
0
 

Author Comment

by:Kennywen
ID: 10840317
setPreferredSize(100,100) will return below error:

BoxAlignmentDemo.java:80: setPreferredSize(java.awt.Dimension) in javax.swing.JComponent cannot be applied to (int,int)
controlMessage.setPreferredSize(100,100);
                     ^
0
 
LVL 9

Accepted Solution

by:
mmuruganandam earned 100 total points
ID: 10840332

controlMessage.setPreferredSize(new Dimension(100,100));

This will work.
0
 

Author Comment

by:Kennywen
ID: 10840347
thanks
0
 
LVL 30

Expert Comment

by:GrandSchtroumpf
ID: 10840506
The actual size of your panel will depend on the LayoutManager you use.
Some managers will use the preferred size, some others will use the minimum size.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses
Course of the Month16 days, 8 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question