Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-12-2008, 03:25 AM
Member
 
Join Date: May 2008
Posts: 1
Rep Power: 0
JetsYanks is on a distinguished road
Default 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
  #2 (permalink)  
Old 05-12-2008, 04:45 AM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 537
Rep Power: 2
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
Default
What about JScrollPane? have you try to use it for the JList?
__________________
A specific, detailed, simple, well elaborated, and "tested before asking" question may gather more quick replies. hopefully
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 05-12-2008, 04:49 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 6,525
Rep Power: 9
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
I think he wants add more than one JPanel on a frame.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Someone helped you?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.
Help:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Resources:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Web:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Tips:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 05-12-2008, 04:56 AM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 537
Rep Power: 2
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
Default
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
__________________
A specific, detailed, simple, well elaborated, and "tested before asking" question may gather more quick replies. hopefully
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

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

BB 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 08:50 AM
Problems with JPanels and displaying Mastergeek666 AWT / Swing 1 01-19-2008 12:32 AM
Can't synchronize multiple JPanels in a JFrame vassil_zorev AWT / Swing 0 12-30-2007 04:22 PM
How to add Images to JPanels? Soda New To Java 3 12-08-2007 05:54 PM
Help with JList Albert NetBeans 1 07-13-2007 03:42 PM


All times are GMT +2. The time now is 01:54 AM.



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