List of usage examples for javax.swing JDesktopPane JDesktopPane
public JDesktopPane()
JDesktopPane
. From source file:InternalFrameListenerDemo.java
public static void main(final String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JDesktopPane desktop = new JDesktopPane(); JInternalFrame internalFrame = new JInternalFrame("Can Do All", true, true, true, true); desktop.add(internalFrame);/* w w w .j a va2 s .co m*/ internalFrame.setBounds(25, 25, 200, 100); JLabel label = new JLabel(internalFrame.getTitle(), JLabel.CENTER); internalFrame.add(label, BorderLayout.CENTER); internalFrame.setVisible(true); internalFrame.addInternalFrameListener(new InternalFrameListener() { public void internalFrameClosing(InternalFrameEvent e) { displayMessage("Internal frame closing", e); } public void internalFrameClosed(InternalFrameEvent e) { displayMessage("Internal frame closed", e); } public void internalFrameOpened(InternalFrameEvent e) { displayMessage("Internal frame opened", e); } public void internalFrameIconified(InternalFrameEvent e) { displayMessage("Internal frame iconified", e); } public void internalFrameDeiconified(InternalFrameEvent e) { displayMessage("Internal frame deiconified", e); } public void internalFrameActivated(InternalFrameEvent e) { displayMessage("Internal frame activated", e); } public void internalFrameDeactivated(InternalFrameEvent e) { displayMessage("Internal frame deactivated", e); } void displayMessage(String prefix, InternalFrameEvent e) { System.out.println(prefix + ": " + e.getSource()); } }); desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE); frame.add(desktop, BorderLayout.CENTER); frame.setSize(500, 300); frame.setVisible(true); }
From source file:InternalFrameEventTest.java
public static void main(String[] a) { JFrame frame = new JFrame(); Container contentPane = frame.getContentPane(); JLayeredPane desktop = new JDesktopPane(); desktop.setOpaque(false);/* w ww . ja v a2 s. co m*/ contentPane.add(desktop, BorderLayout.CENTER); desktop.add(createLayer("One"), JLayeredPane.POPUP_LAYER); desktop.add(createLayer("Two"), JLayeredPane.DEFAULT_LAYER); desktop.add(createLayer("Three"), JLayeredPane.PALETTE_LAYER); frame.setSize(400, 200); frame.setVisible(true); }
From source file:InternalFrameTest.java
public static void main(String args[]) { JFrame frame = new JFrame("Internal Frame Listener"); Container contentPane = frame.getContentPane(); JLayeredPane desktop = new JDesktopPane(); desktop.setOpaque(false);/*from w w w.j a v a 2 s . c o m*/ desktop.add(createLayer("One"), JLayeredPane.POPUP_LAYER); desktop.add(createLayer("Two"), JLayeredPane.DEFAULT_LAYER); desktop.add(createLayer("Three"), JLayeredPane.PALETTE_LAYER); contentPane.add(desktop, BorderLayout.CENTER); frame.setSize(300, 300); frame.show(); }
From source file:DesktopSample.java
public static void main(String[] args) { String title = "Desktop Sample"; JFrame frame = new JFrame(title); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JDesktopPane desktop = new JDesktopPane(); JInternalFrame internalFrames[] = { new JInternalFrame("Can Do All", true, true, true, true), new JInternalFrame("Not Resizable", false, true, true, true), new JInternalFrame("Not Closable", true, false, true, true), new JInternalFrame("Not Maximizable", true, true, false, true), new JInternalFrame("Not Iconifiable", true, true, true, false) }; InternalFrameListener internalFrameListener = new InternalFrameIconifyListener(); for (int i = 0, n = internalFrames.length; i < n; i++) { desktop.add(internalFrames[i]);//from ww w . j av a2s.co m internalFrames[i].setBounds(i * 25, i * 25, 200, 100); internalFrames[i].addInternalFrameListener(internalFrameListener); JLabel label = new JLabel(internalFrames[i].getTitle(), JLabel.CENTER); Container content = internalFrames[i].getContentPane(); content.add(label, BorderLayout.CENTER); internalFrames[i].setVisible(true); } JInternalFrame palette = new JInternalFrame("Palette", true, false, true, false); palette.setBounds(350, 150, 100, 100); palette.putClientProperty("JInternalFrame.isPalette", Boolean.TRUE); desktop.add(palette, JDesktopPane.PALETTE_LAYER); palette.setVisible(true); desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE); Container content = frame.getContentPane(); content.add(desktop, BorderLayout.CENTER); frame.setSize(500, 300); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { boolean resizable = true; boolean closeable = true; boolean maximizable = true; boolean iconifiable = true; String title = "Frame Title"; JInternalFrame iframe = new JInternalFrame(title, resizable, closeable, maximizable, iconifiable); iframe.setSize(300, 300);/* ww w.j a v a 2 s . c om*/ iframe.setVisible(true); iframe.getContentPane().add(new JTextArea()); JDesktopPane desktop = new JDesktopPane(); desktop.add(iframe); JFrame frame = new JFrame(); frame.getContentPane().add(desktop, BorderLayout.CENTER); frame.setSize(300, 300); frame.setVisible(true); }
From source file:InternalFramePropertyChangeHandler.java
public static void main(final String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JDesktopPane desktop = new JDesktopPane(); JInternalFrame internalFrame = new JInternalFrame("Can Do All", true, true, true, true); InternalFramePropertyChangeHandler ins = new InternalFramePropertyChangeHandler(); // Add listener for iconification events internalFrame.addPropertyChangeListener(ins); desktop.add(internalFrame);/* w ww . ja v a 2s . c o m*/ internalFrame.setBounds(25, 25, 200, 100); JLabel label = new JLabel(internalFrame.getTitle(), JLabel.CENTER); internalFrame.add(label, BorderLayout.CENTER); internalFrame.setVisible(true); frame.add(desktop, BorderLayout.CENTER); frame.setSize(500, 300); frame.setVisible(true); }
From source file:InternalFrameIconifyListener.java
public static void main(final String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JDesktopPane desktop = new JDesktopPane(); JInternalFrame internalFrame = new JInternalFrame("Can Do All", true, true, true, true); InternalFrameListener internalFrameListener = new InternalFrameIconifyListener(); // Add listener for iconification events internalFrame.addInternalFrameListener(internalFrameListener); desktop.add(internalFrame);/*from ww w .ja v a 2 s .com*/ internalFrame.setBounds(25, 25, 200, 100); JLabel label = new JLabel(internalFrame.getTitle(), JLabel.CENTER); internalFrame.add(label, BorderLayout.CENTER); internalFrame.setVisible(true); frame.add(desktop, BorderLayout.CENTER); frame.setSize(500, 300); frame.setVisible(true); }
From source file:Examples.java
public static void main(String args[]) { JFrame frame = new JFrame("Example Popup"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container contentPane = frame.getContentPane(); contentPane.setLayout(new GridLayout(0, 1)); JFrame frame2 = new JFrame("Desktop"); final JDesktopPane desktop = new JDesktopPane(); frame2.getContentPane().add(desktop); JButton pick = new JButton("Pick"); pick.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { System.out.println("Hi"); }/*from ww w.ja va 2 s.c o m*/ }); frame2.getContentPane().add(pick, BorderLayout.SOUTH); JButton messagePopup = new JButton("Message"); contentPane.add(messagePopup); messagePopup.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { Component source = (Component) actionEvent.getSource(); JOptionPane.showMessageDialog(source, "Printing complete"); JOptionPane.showInternalMessageDialog(desktop, "Printing complete"); } }); JButton confirmPopup = new JButton("Confirm"); contentPane.add(confirmPopup); confirmPopup.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { Component source = (Component) actionEvent.getSource(); JOptionPane.showConfirmDialog(source, "Continue printing?"); JOptionPane.showInternalConfirmDialog(desktop, "Continue printing?"); } }); JButton inputPopup = new JButton("Input"); contentPane.add(inputPopup); inputPopup.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { Component source = (Component) actionEvent.getSource(); JOptionPane.showInputDialog(source, "Enter printer name:"); // Moons of Neptune String smallList[] = { "Naiad", "Thalassa", "Despina", "Galatea", "Larissa", "Proteus", "Triton", "Nereid" }; JOptionPane.showInternalInputDialog(desktop, "Pick a printer", "Input", JOptionPane.QUESTION_MESSAGE, null, smallList, "Triton"); // Moons of Saturn - includes two provisional designations to // make 20 String bigList[] = { "Pan", "Atlas", "Prometheus", "Pandora", "Epimetheus", "Janus", "Mimas", "Enceladus", "Tethys", "Telesto", "Calypso", "Dione", "Helene", "Rhea", "Titan", "Hyperion", "Iapetus", "Phoebe", "S/1995 S 2", "S/1981 S 18" }; // Object saturnMoon = JOptionPane.showInputDialog(source, "Pick // a printer", "Input", JOptionPane.QUESTION_MESSAGE, null, // bigList, "Titan"); Object saturnMoon = JOptionPane.showInputDialog(source, "Pick a printer", "Input", JOptionPane.QUESTION_MESSAGE, null, bigList, null); System.out.println("Saturn Moon: " + saturnMoon); } }); JButton optionPopup = new JButton("Option"); contentPane.add(optionPopup); optionPopup.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { Component source = (Component) actionEvent.getSource(); Icon greenIcon = new DiamondIcon(Color.green); Icon redIcon = new DiamondIcon(Color.red); Object iconArray[] = { greenIcon, redIcon }; JOptionPane.showOptionDialog(source, "Continue printing?", "Select an Option", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, iconArray, iconArray[1]); Icon blueIcon = new DiamondIcon(Color.blue); Object stringArray[] = { "Do It", "No Way" }; JOptionPane.showInternalOptionDialog(desktop, "Continue printing?", "Select an Option", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, blueIcon, stringArray, stringArray[0]); } }); frame.setSize(300, 200); frame.setVisible(true); frame2.setSize(300, 200); frame2.setVisible(true); }
From source file:ResourceModExample.java
public static void main(String[] args) { Border border = BorderFactory.createRaisedBevelBorder(); Border tripleBorder = new CompoundBorder(new CompoundBorder(border, border), border); UIManager.put("Button.border", tripleBorder); UIManager.put("InternalFrame.closeIcon", new ImageIcon("close.gif")); UIManager.put("InternalFrame.iconizeIcon", new ImageIcon("iconify.gif")); UIManager.put("InternalFrame.maximizeIcon", new ImageIcon("maximize.gif")); UIManager.put("InternalFrame.altMaximizeIcon", new ImageIcon("altMax.gif")); UIManager.put("InternalFrame.titleFont", new Font("Serif", Font.ITALIC, 12)); UIManager.put("ScrollBar.width", new Integer(30)); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container c = f.getContentPane(); JDesktopPane desk = new JDesktopPane(); c.add(desk, BorderLayout.CENTER); JButton cut = new JButton("Cut"); JButton copy = new JButton("Copy"); JButton paste = new JButton("Paste"); JPanel p = new JPanel(new FlowLayout()); p.add(cut);/*from w ww .j a va2s.com*/ p.add(copy); p.add(paste); c.add(p, BorderLayout.SOUTH); JInternalFrame inf = new JInternalFrame("MyFrame", true, true, true, true); JLabel l = new JLabel(new ImageIcon("luggage.jpeg")); JScrollPane scroll = new JScrollPane(l); inf.setContentPane(scroll); inf.setBounds(10, 10, 350, 280); desk.add(inf); inf.setVisible(true); f.setSize(380, 360); f.setVisible(true); }
From source file:flow.visibility.FlowMain.java
public static void main(String[] args) throws Exception { /************************************************************** * Creating the Main GUI //from w w w. jav a2s . c o m **************************************************************/ final JDesktopPane desktop = new JDesktopPane(); final JMenuBar mb = new JMenuBar(); JMenu menu; /** Add File Menu to Open File and Save Result */ menu = new JMenu("File"); JMenuItem Open = new JMenuItem("Open"); JMenuItem Save = new JMenuItem("Save"); menu.add(Open); menu.add(Save); menu.addSeparator(); JMenuItem Exit = new JMenuItem("Exit"); menu.add(Exit); Exit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.exit(0); } }); mb.add(menu); /** Add Control Menu to Start and Stop Capture */ menu = new JMenu("Control"); JMenuItem Start = new JMenuItem("Start Capture"); JMenuItem Stop = new JMenuItem("Stop Capture"); menu.add(Start); Start.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { FlowDumper.main(false); } }); menu.add(Stop); Stop.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { FlowDumper.main(true); } }); mb.add(menu); /** Add Configuration Menu for Tapping and Display */ menu = new JMenu("Configuration"); JMenuItem Tapping = new JMenuItem("Tapping Configuration"); JMenuItem Display = new JMenuItem("Display Configuration"); menu.add(Tapping); Tapping.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { FlowTapping.main(null); } }); menu.add(Display); mb.add(menu); /** Add Detail Menu for NetGrok Visualization and JEthereal Inspection */ menu = new JMenu("Flow Detail"); JMenuItem FlowVisual = new JMenuItem("Flow Visualization"); JMenuItem FlowInspect = new JMenuItem("Flow Inspections"); menu.add(FlowVisual); FlowVisual.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { NetworkView.main(null); } }); menu.add(FlowInspect); FlowInspect.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Ethereal.main(null); } }); mb.add(menu); /** Add Help Menu for Software Information */ menu = new JMenu("Help"); JMenuItem About = new JMenuItem("About"); menu.add(About); About.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(null, "OF@TEIN Flow Visibility Tools @ 2015 by GIST", "About the Software", JOptionPane.PLAIN_MESSAGE); } }); mb.add(menu); /** Creating the main frame */ JFrame frame = new JFrame("OF@TEIN Flow Visibility Tools"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new BorderLayout()); frame.add(desktop); frame.setJMenuBar(mb); frame.setSize(1215, 720); frame.setLocationRelativeTo(null); frame.setVisible(true); /**Add Blank three (3) Internal Jframe*/ /**Internal Frame from Flow Summary Chart*/ JInternalFrame FlowStatistic = new JInternalFrame("Flow Statistic", true, true, true, true); FlowStatistic.setBounds(0, 0, 600, 330); ChartPanel chartPanel = new ChartPanel(createChart(null)); chartPanel.setMouseZoomable(true, false); FlowStatistic.add(chartPanel); FlowStatistic.setVisible(true); desktop.add(FlowStatistic); /**Internal Frame from Flow Summary Text*/ JInternalFrame FlowSummary = new JInternalFrame("Flow Summary", true, true, true, true); FlowSummary.setBounds(0, 331, 600, 329); JTextArea textArea = new JTextArea(50, 10); JScrollPane scrollPane = new JScrollPane(textArea); FlowSummary.add(scrollPane); FlowSummary.setVisible(true); desktop.add(FlowSummary); //JInternalFrame FlowInspection = new JInternalFrame("Flow Inspection", true, true, true, true); //FlowInspection.setBounds(601, 0, 600, 660); //JTextArea textArea2 = new JTextArea(50, 10); //JScrollPane scrollPane2 = new JScrollPane(textArea2); //FlowInspection.add(scrollPane2); //FlowInspection.setVisible(true); //desktop.add(FlowInspection); /**Internal Frame from Printing the Packet Sequence*/ JInternalFrame FlowSequence = new JInternalFrame("Flow Sequence", true, true, true, true); FlowSequence.setBounds(601, 0, 600, 660); JTextArea textArea3 = new JTextArea(50, 10); JScrollPane scrollPane3 = new JScrollPane(textArea3); FlowSequence.add(scrollPane3); FlowSequence.setVisible(true); desktop.add(FlowSequence); /************************************************************** * Update the Frame Regularly **************************************************************/ /** Regularly update the Frame Content every 3 seconds */ for (;;) { desktop.removeAll(); desktop.add(FlowProcess.FlowStatistic()); desktop.add(FlowProcess.FlowSummary()); //desktop.add(FlowProcess.FlowInspection()); desktop.add(FlowProcess.FlowSequence()); desktop.revalidate(); Thread.sleep(10000); } }