Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

set JPanel size

Posted on 2004-04-16
5
Medium Priority
?
388 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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

618 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