Commander / Structure, how?

I would like to see a little Swing example with one MainFrame, and one frame that slide over the MainFrame when you click a button.

Like the Commander and structure does in IntelliJ.

Can anyone provide me with a simple sample that does this?

4 comments
Comment actions Permalink

Do you mean using the OpenAPI or Swing in general?

0
Comment actions Permalink

ssirovy:

Swing in general.
Can you provide me with an example.

(before I can make plugins, i haft to learn some more abount swing.)

0
Comment actions Permalink

Here is a good link on Swing usage (I use this more than my books):
http://java.sun.com/docs/books/tutorial/uiswing/components/components.html


I whipped up a super simple and brain-dead example for you to look at.

HTH,
-sms

-



import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;
import javax.swing.JPanel;
import javax.swing.JTextArea;

public class LayeredPaneTest extends JFrame {


public LayeredPaneTest(String title) {
super(title);
setSize(410, 510);
setResizable(false);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});

// creates the textArea to take up most of the screen
JTextArea tArea = new JTextArea(5, 50);
tArea.setText("Just a test...");

// put the textArea on a JPanel
final JPanel main = new JPanel(new BorderLayout(5, 5));
main.setBounds(0, 0, 400, 500);
main.add(tArea, BorderLayout.CENTER);

// create a widget to slide over the top of the textArea
final JLabel slider = new JLabel("Click Me", JLabel.CENTER);
slider.setBounds(0, 0, 300, 500);
slider.setOpaque(true);
slider.setBackground(Color.RED);
slider.setVisible(true);
slider.addMouseListener(new MouseAdapter() {
public void mouseReleased(MouseEvent e) {
new Thread(new Runnable() {
public void run() {
for (int i = 300; i >= 0; i--) {
slider.setBounds(0, 0, i, 500);
repaint();
}
slider.setVisible(false);
}
}).start();
}
});

// put the main panel at lower depth than the label
JLayeredPane lp = new JLayeredPane();
lp.add(main, new Integer(100));
lp.add(slider, new Integer(200));

// add the layered pane to the content pane
JPanel cp = (JPanel) getContentPane();
cp.setLayout(new BorderLayout(5, 5));
cp.add(lp, BorderLayout.CENTER);


show();
}

public static void main(String[] args) {
new LayeredPaneTest("LayeredPaneTest");
}
}

0
Comment actions Permalink

Thanks a lot.

I am realy gratefull for you help.

0

Please sign in to leave a comment.