Solved

set JPanel size

Posted on 2004-04-16
5
370 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 25 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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 connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now