?
Solved

set JPanel size

Posted on 2004-04-16
5
Medium Priority
?
386 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Suggested Courses
Course of the Month14 days, 10 hours left to enroll

770 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