my dog learned polymorphism*
The moose likes Swing / AWT / SWT and the fly likes Can I Use JLayeredPane Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Can I Use JLayeredPane" Watch "Can I Use JLayeredPane" New topic
Author

Can I Use JLayeredPane

nabi bux
Ranch Hand

Joined: Mar 14, 2005
Posts: 73
Hi
To all I have the following Prpgram In which I Have Declayred Box and The JPanel I added Box To JPanel And Panel to JFrame content Please Compile the Following and Then sugget Me I Want to JInternal frame at right to the Frame what Should I do should I add JLayere pant To JFrame contentpane at right and then add Internal frame to it please Help here is the code



/**
* @(#)DataBase.java
*
* DataBase application
*
* @author
* @version 1.00 2007/4/2
*/

import java.awt.BorderLayout;
import java.awt.Frame;
import java.awt.Panel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.border.*;
import javax.swing.JButton;
import javax.swing.JDesktopPane;
import javax.swing.JInternalFrame;
import javax.swing.JLayeredPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.*;
import java.awt.*;
public class DataBase extends JFrame {/*getContentPane().setLayout(
new BoxLayout( getContentPane(), BoxLayout.Y_AXIS );
. . . . .*/

JButton openButton, macButton, javaButton, motifButton, winButton;

JLayeredPane desktop;

JInternalFrame internalFrame;

public DataBase() {
super("Internal Frame Demo");
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
SwingUtilities.updateComponentTreeUI(this);
} catch (Exception ex1) {
System.err.println("Unsupported LookAndFeel: " );
}
openButton = new JButton("Open");
macButton = new JButton("Mac");
javaButton = new JButton("Metal");
motifButton = new JButton("Motif");
winButton = new JButton("Windows");
setSize(500, 400);

JPanel p = new JPanel(new BorderLayout());
Box left=Box.createVerticalBox();
p.setBorder( new TitledBorder( new EtchedBorder(),"Function Buttton"));
Dimension size=new Dimension(100,20);
p.setBackground(Color.BLACK);
left.add(openButton);
left.add(macButton);
left.add(javaButton);
left.add(motifButton);
left.add(winButton);

openButton.setMaximumSize(winButton.getPreferredSize());
// b2.setMaximumSize(b3.getPreferredSize());
openButton.setMaximumSize(winButton.getPreferredSize());
macButton.setMaximumSize(winButton.getPreferredSize());// Setting he size of Button With respect to Larger Button
javaButton.setMaximumSize(winButton.getPreferredSize());
motifButton.setMaximumSize(winButton.getPreferredSize());

p.add(left,BorderLayout.CENTER);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});


this.getContentPane().setBackground(Color.gray);
this.getContentPane().add(p, BorderLayout.WEST);


}


public static void main(String args[]) {
DataBase sif = new DataBase();
sif.setVisible(true);
}
}
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38481
    
  23
Please use code tags for code quotes.
You can't simply put a JInternalFrame on top of a JPanel; JInternalFrames live inside JDesktopPanes. See this part of the Java Tutorial.
And rather than using your WindowListener, simply set the default closing operation to EXIT_ON_CLOSE. Details in the JFrame page of the API.
nabi bux
Ranch Hand

Joined: Mar 14, 2005
Posts: 73
OK thank to solve my problem
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can I Use JLayeredPane