| | |
problem with jpanels
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
There gone be something wrong with your code. Can you please post it?
PS: Use code tags, press hash "#" sign on post toolbar and paste your code between the tags which will appear
PS: Use code tags, press hash "#" sign on post toolbar and paste your code between the tags which will appear
Last edited by peter_budo; Nov 13th, 2007 at 8:32 am.
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
•
•
Join Date: Nov 2007
Posts: 19
Reputation:
Solved Threads: 0
It's probobly a layout issue. Try to use something like this
Java Syntax (Toggle Plain Text)
class MyFrame extends JFrame { public MyFrame() { setSize(800,600); setTitle("MyFrame"); JPanel panel1 = new JPanel(); JPanel panel2 = new JPanel(); Container cp = getContentPane(); [B][COLOR="Red"] cp.setLayout(new FlowLayout());[/COLOR][/B] cp.add(panel1); cp.add(panel2); } }
-Signed Artmann
Well, the contentPane of the the JFrams already has a layout. It simply needs to be used correctly. If you use add without any anchor parameter then according to the documentation
As a convenience, BorderLayout interprets the absence of a string specification the same as the constant CENTER
So, simply calling add(Component) twice, is the same as calling add(Component, CENTER) twice. She should be calling add(Component, CENTER) and add(Component, SOUTH), for example.
Of course, changing the layout (as your post showed) is always an option, but is not, strictly speaking, needed.
As a convenience, BorderLayout interprets the absence of a string specification the same as the constant CENTER
So, simply calling add(Component) twice, is the same as calling add(Component, CENTER) twice. She should be calling add(Component, CENTER) and add(Component, SOUTH), for example.
Of course, changing the layout (as your post showed) is always an option, but is not, strictly speaking, needed.
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
![]() |
Similar Threads
- Problem with Windows Update and WinXP (Web Browsers)
- Installing Windows 98 On VMware. Floppy problem (Windows 95 / 98 / Me)
- JApplet display problem (Java)
- Java GUI problem... contents of JFrame is invisible... (Java)
- Windows XP keeps restarting since a new video card (Windows NT / 2000 / XP)
- Redhat Linux 6.2 - ipop3d problem? (*nix Software)
- Problem with T720 (Cellphones, PDAs and Handheld Devices)
- Connection Problems (Networking Hardware Configuration)
- .htaccess mod_rewrite problem (Linux Servers and Apache)
Other Threads in the Java Forum
- Previous Thread: Efficient Connection
- Next Thread: Use different channels to play .wav file
Views: 918 | Replies: 5
| Thread Tools | Search this Thread |
Tag cloud for Java
android api apple applet application apps arguments array arrays automation binary bluetooth businessintelligence card chat class classes client code collision component crashcourse database draw eclipse ee error event exception file fractal free game gis givemetehcodez graphics gui helpwithhomework html ide image input integer integration j2me java javadoc javafx javaprojects jmf jni jpanel julia jvm linux list loop machine map method methods migrate mobile netbeans newbie nls number object oracle physics print problem program programming project radio recursion scanner screen security server service set size sms socket software sort sql string swing test textfield threads time transfer tree trolltech utility windows






