Results 1 to 2 of 2
Thread: HELP with jPanels
- 03-12-2009, 10:40 AM #1
Member
- Join Date
- Mar 2009
- Posts
- 1
- Rep Power
- 0
HELP with jPanels
Using netbeans I've created new JFrame object with JPanel inside. Now I want to add new Jpanel object and add it to a previous JPanel.
Something like this:
Of course, the new panel2 won't show in the mainFrame...please help...Java Code:package p; public class mainFrame extends javax.swing.JFrame { public mainFrame() { super("New Frame"); JPanel panel1 = new JPanel(); add(panel1); panel2 p2=new panel2(); panel1.add(p2); pack(); }} public class panel2 extends javax.swing.JPanel { public panel2() { jLabel2 = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel(); add(jLabel1);add(jLabel2); }} public class Main { public static void main(String[] args) { mainFrame M = new mainFrame(); M.setVisible(true); }}
-
The problem is with your use of layout manager. You should read the Sun Swing tutorial on this subject which you can find here: Lesson: Laying Out Components Within a Container (The Java™ Tutorials > Creating a GUI with JFC/Swing)
Similar Threads
-
JList and JPanels
By JetsYanks in forum New To JavaReplies: 8Last Post: 12-25-2009, 02:11 PM -
Help with overlapping JPanels
By xcallmejudasx in forum New To JavaReplies: 2Last Post: 03-09-2009, 10:19 PM -
Managing jPanels in jSplitPane
By calexander in forum Advanced JavaReplies: 6Last Post: 11-13-2008, 07:06 PM -
Problems with JPanels and displaying
By Mastergeek666 in forum AWT / SwingReplies: 1Last Post: 01-19-2008, 12:32 AM -
How to add Images to JPanels?
By Soda in forum New To JavaReplies: 3Last Post: 12-08-2007, 05:54 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks