Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-12-2008, 04:25 AM
Member
 
Join Date: May 2008
Posts: 1
JetsYanks is on a distinguished road
JList and JPanels
Hey everyone, Ive recently started working with Java and have a basic grasp to it, but I hit a problem. When I enter a JList into a JPanel, the list will show up, but any other JPanels I add will not show up(when I run void-main option in BlueJ), and Im not sure as to what Im doing wrong because I'm having no Compiling Issues.

Heres an example of my code-

Code:
import java.awt.*; import javax.swing.*; import javax.swing.event.*; public class Test extends JFrame { private String[] stringNames = {"Test1", "Test2", "Test3", "Test4", "Test5", "Test6", "Test7", "Test8", "Test9", "Test10", "Test11"}; private JList jlist = new JList(stringNames); private JTextField jtext = new JTextField("--Welcome--"); public static void main(String[] args) { Test frame = new Test(); frame.setSize(650, 550); frame.setTitle("Welcome to Java"); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } public Test() { Container container = getContentPane(); getContentPane().setLayout(new FlowLayout()); getContentPane().add(jlist); getContentPane().add(jtext); JList jlist = new JList(stringNames); JPanel p1 = new JPanel(); p1.add(jlist); JPanel p2 = new JPanel(); JPanel p3 = new JPanel(); p2.add(jtext); p2.add(p1, BorderLayout.WEST); p3.add(p2, BorderLayout.EAST); } }
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-12-2008, 05:45 AM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 284
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
What about JScrollPane? have you try to use it for the JList?
__________________
best regards,
sukatoa
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 05-12-2008, 05:49 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 1,237
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
I think he wants add more than one JPanel on a frame.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Want to make your IDE the best?Vote Now
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 05-12-2008, 05:56 AM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 284
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
yah...

@ OP, have a look at the getContentPane().add(something)...
only jlist and jtext are added...

You can bring them at the bottom.
and add the panels like what you did in jlist
__________________
best regards,
sukatoa
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
JList problem zizou147 Advanced Java 1 04-17-2008 09:50 AM
Problems with JPanels and displaying Mastergeek666 AWT / Swing 1 01-19-2008 01:32 AM
Can't synchronize multiple JPanels in a JFrame vassil_zorev AWT / Swing 0 12-30-2007 05:22 PM
How to add Images to JPanels? Soda New To Java 3 12-08-2007 06:54 PM
Help with JList Albert NetBeans 1 07-13-2007 04:42 PM


All times are GMT +3. The time now is 05:51 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org