-
August 15th, 2013, 12:57 AM
#1
multiple frame
Hi i want to do something that sounds simple but it has been giving me a lot of problems. I want to display two panels inside of a jframe. So far none of the panels show up when i run the program. I can't figure out why at least one of them isn't showing up. here's the code thanks
Code:
import java.awt.*;
import java.awt.BorderLayout.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
public class twoFrame extends JFrame
{
private JFrame big;
private JPanel panel1, panel2;
private JButton but;
private JScrollPane sp;
private JTextArea full;
public twoFrame()
{
JFrame big = new JFrame();
full = new JTextArea();
sp = new JScrollPane(full);
sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
full.setEditable(false);
JPanel panel1 = new JPanel();
getContentPane().add(panel1);
panel1.setPreferredSize(new Dimension (300,300));
panel1.setLayout(null);
//panel1.setBounds(10,10,300,300);
panel1.setVisible(true);
add(panel1);
panel1.add(sp);
JPanel panel2 = new JPanel();
getContentPane().add(panel2);
panel2.setLayout(null);
big.add(panel1);
big.add(panel2);
//panel2.add(but);
//big.add(but);
pack();
setTitle("Practice Frame");
setLocationRelativeTo(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
this.setExtendedState(Frame.MAXIMIZED_BOTH);
}
public static void main(String[] args)
{
twoFrame tf = new twoFrame();
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|