List of usage examples for javax.swing JInternalFrame addPropertyChangeListener
public void addPropertyChangeListener(PropertyChangeListener listener)
From source file:MainClass.java
public static void main(final String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JDesktopPane desktop = new JDesktopPane(); JInternalFrame palette = new JInternalFrame("Palette", true, true, true, true); palette.addPropertyChangeListener(new InternalFramePropertyChangeHandler()); palette.setBounds(350, 150, 100, 100); desktop.add(palette, JDesktopPane.PALETTE_LAYER); palette.setVisible(true);//from w w w.j a va 2s . c om frame.add(desktop, BorderLayout.CENTER); frame.setSize(500, 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);//from w w w .ja v a2s .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:OptPaneComparison.java
public OptPaneComparison(final String message) { setDefaultCloseOperation(EXIT_ON_CLOSE); final int msgType = JOptionPane.QUESTION_MESSAGE; final int optType = JOptionPane.OK_CANCEL_OPTION; final String title = message; setSize(350, 200);//w w w .j a v a 2 s. c om // Create a desktop for internal frames final JDesktopPane desk = new JDesktopPane(); setContentPane(desk); // Add a simple menu bar JMenuBar mb = new JMenuBar(); setJMenuBar(mb); JMenu menu = new JMenu("Dialog"); JMenu imenu = new JMenu("Internal"); mb.add(menu); mb.add(imenu); final JMenuItem construct = new JMenuItem("Constructor"); final JMenuItem stat = new JMenuItem("Static Method"); final JMenuItem iconstruct = new JMenuItem("Constructor"); final JMenuItem istat = new JMenuItem("Static Method"); menu.add(construct); menu.add(stat); imenu.add(iconstruct); imenu.add(istat); // Create our JOptionPane. We're asking for input, so we call // setWantsInput. // Note that we cannot specify this via constructor parameters. optPane = new JOptionPane(message, msgType, optType); optPane.setWantsInput(true); // Add a listener for each menu item that will display the appropriate // dialog/internal frame construct.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { // Create and display the dialog JDialog d = optPane.createDialog(desk, title); d.setVisible(true); respond(getOptionPaneValue()); } }); stat.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { String s = JOptionPane.showInputDialog(desk, message, title, msgType); respond(s); } }); iconstruct.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { // Create and display the dialog JInternalFrame f = optPane.createInternalFrame(desk, title); f.setVisible(true); // Listen for the frame to close before getting the value from // it. f.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent ev) { if ((ev.getPropertyName().equals(JInternalFrame.IS_CLOSED_PROPERTY)) && (ev.getNewValue() == Boolean.TRUE)) { respond(getOptionPaneValue()); } } }); } }); istat.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { String s = JOptionPane.showInternalInputDialog(desk, message, title, msgType); respond(s); } }); }
From source file:org.docx4all.ui.main.WordMLEditor.java
public void createInternalFrame(FileObject f) { if (f == null) { return;//from ww w . j a v a2 s. co m } log.info(VFSUtils.getFriendlyName(f.getName().getURI())); JInternalFrame iframe = _iframeMap.get(f.getName().getURI()); if (iframe != null) { iframe.setVisible(true); } else { iframe = new JInternalFrame(f.getName().getBaseName(), true, true, true, true); iframe.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); iframe.addInternalFrameListener(_internalFrameListener); iframe.addInternalFrameListener(_toolbarStates); iframe.addPropertyChangeListener(WindowMenu.getInstance()); if (iframe.getUI() instanceof BasicInternalFrameUI) { BasicInternalFrameUI ui = (BasicInternalFrameUI) iframe.getUI(); javax.swing.JComponent northPane = ui.getNorthPane(); if (northPane == null) { // Happens on Mac OSX: Google for "osx java getNorthPane" // Fix is from it.businesslogic.ireport.gui.JMDIFrame javax.swing.plaf.basic.BasicInternalFrameUI aUI = new javax.swing.plaf.basic.BasicInternalFrameUI( iframe); iframe.setUI(aUI); // Try again ui = (BasicInternalFrameUI) iframe.getUI(); northPane = ((javax.swing.plaf.basic.BasicInternalFrameUI) ui).getNorthPane(); } northPane.addMouseMotionListener(_titleBarMouseListener); } JEditorPane editorView = createEditorView(f); JPanel panel = FxScriptUIHelper.getInstance().createEditorPanel(editorView); iframe.getContentPane().add(panel); iframe.pack(); _desktop.add(iframe); editorView.requestFocusInWindow(); editorView.select(0, 0); String filePath = f.getName().getURI(); iframe.putClientProperty(WordMLDocument.FILE_PATH_PROPERTY, filePath); _iframeMap.put(filePath, iframe); iframe.show(); } try { iframe.setSelected(true); iframe.setIcon(false); iframe.setMaximum(true); } catch (PropertyVetoException exc) { // do nothing } }