| | |
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
| Thread Tools | Search this Thread |
add android api applet application applications array arrays automation bank binary bluetooth chat class classes client code component converter database db development dice digit draw eclipse equation error event exception formatingtextintooltipjava fractal functiontesting game givemetehcodez graphics gui health html hyper ide idea image infinite input int integer j2me java javame javaprojects jni jpanel julia linux list loop main map method methods mobile myregfun netbeans newbie nonstatic openjavafx oracle pattern pearl print problem program programming project recursion repositories scanner screen scrollbar server set size sms sort sorting spamblocker sql sqlserver state storm string superclass swing text-file thread threads time tree windows






