-
August 20th, 2013, 03:19 AM
#1
JdesktopPane
I have a situation where i would like to have an internal frame inside of a jdesktoppane. Currently that works but i would like to have buttons and labels and other components showing on the jdesktoppane (not related to the internal frame). So far the buttons that i made don't show on the the desktoppane. Please help me figure out why it is not displaying. Here's the code...
Code:
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class InternalFrame extends JFrame
{
JDesktopPane desktop;
private JPanel background;
public InternalFrame()
{
super("Internal Frames");
this.setExtendedState(Frame.MAXIMIZED_BOTH);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//this.setLayout(null);
background = new JPanel();
background.setLocation(0,0);
background.setLayout(new FlowLayout());
// setLayout(new FlowLayout());
JButton button1 = new JButton("Button 1");
JButton button2 = new JButton("Button 2");
JButton button3 = new JButton("Button 3");
//button1.setBounds(10,200,200,200);
background.add(button1);
add(button2);
add(button3);
setVisible(true);
desktop = new JDesktopPane();
createFrame();
setContentPane(desktop);
desktop.add(background);
}
protected void createFrame()
{
MyInternalFrame frame = new MyInternalFrame();
MyInternalFrame frame2 = new MyInternalFrame();
frame.setVisible(true);
frame2.setVisible(true);
desktop.add(frame);
desktop.add(frame2);
/* try
{
frame.setSelected(true);
}catch (java.beans.PropertyVetoException e) {} */
}
protected void quit()
{
System.exit(0);
}
private static void createAndShowGUI()
{
JFrame.setDefaultLookAndFeelDecorated(true);
InternalFrame frame = new InternalFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
JFrame.setDefaultLookAndFeelDecorated(true);
InternalFrame frame2 = new InternalFrame();
frame2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame2.setVisible(true);
}
public static void main(String[] args)
{
javax.swing.SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
createAndShowGUI();
}
});
}
}
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
|