problem with jpanels

Reply

Join Date: Oct 2007
Posts: 9
Reputation: enes is an unknown quantity at this point 
Solved Threads: 0
enes enes is offline Offline
Newbie Poster

problem with jpanels

 
0
  #1
Nov 13th, 2007
when ı add two panels into a frame last panel i added seen on the screeen how can i show both panels in one frame
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,190
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 483
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is online now Online
Code tags enforcer

Re: problem with jpanels

 
0
  #2
Nov 13th, 2007
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
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
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 19
Reputation: Artmann is an unknown quantity at this point 
Solved Threads: 0
Artmann Artmann is offline Offline
Newbie Poster

Re: problem with jpanels

 
0
  #3
Nov 13th, 2007
It's probobly a layout issue. Try to use something like this

  1.  
  2. class MyFrame extends JFrame
  3. {
  4.  
  5. public MyFrame()
  6. {
  7.  
  8. setSize(800,600);
  9. setTitle("MyFrame");
  10.  
  11. JPanel panel1 = new JPanel();
  12. JPanel panel2 = new JPanel();
  13.  
  14. Container cp = getContentPane();
  15.  
  16. [B][COLOR="Red"] cp.setLayout(new FlowLayout());[/COLOR][/B]
  17.  
  18. cp.add(panel1);
  19. cp.add(panel2);
  20.  
  21. }
  22.  
  23.  
  24. }
-Signed Artmann
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: problem with jpanels

 
0
  #4
Nov 13th, 2007
and what makes you think you get only one panel to show if you do that?
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 19
Reputation: Artmann is an unknown quantity at this point 
Solved Threads: 0
Artmann Artmann is offline Offline
Newbie Poster

Re: problem with jpanels

 
0
  #5
Nov 14th, 2007
My Example will show two panels.
I just wanted to show him how to add a layout to the frame.
If he hasn't done that he will only see one panel.
-Signed Artmann
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,358
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 252
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: problem with jpanels

 
0
  #6
Nov 14th, 2007
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.
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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC