protected JInternalFrame createInstanceImpl() { JInternalFrame frame = new JInternalFrame(title, resizable, closable, maximizable, iconable) { protected JRootPane createRootPane() { return _rootPane == null ? null : _rootPane.createInstance(); } public void addNotify() { try { // Doesn't seem to work correctly setClosed(_isClosed); setMaximum(_isMaximum); setIcon(_isIcon); setSelected(_isSelected); } catch (PropertyVetoException ex) {} } }; return frame; }
/** * Returns information about component. */ @Override public Hashtable<String, Object> getDump() { Hashtable<String, Object> result = super.getDump(); result.put(TITLE_DPROP, ((JInternalFrame) getSource()).getTitle()); String state = STATE_NORMAL_DPROP_VALUE; if (((JInternalFrame) getSource()).isClosed()) { state = STATE_CLOSED_DPROP_VALUE; } else if (((JInternalFrame) getSource()).isIcon()) { state = STATE_ICONIFIED_DPROP_VALUE; } else if (((JInternalFrame) getSource()).isMaximum()) { state = STATE_MAXIMAZED_DPROP_VALUE; } result.put(STATE_DPROP, state); result.put(IS_RESIZABLE_DPROP, ((JInternalFrame) getSource()).isResizable() ? "true" : "false"); result.put(IS_SELECTED_DPROP, ((JInternalFrame) getSource()).isSelected() ? "true" : "false"); return result; }
/** * Sets the data model update. * @param dataModelNotification the new data model update */ public void setDataModelNotification(final DataModelNotification dataModelNotification) { // SwingUtilities.invokeLater(new Runnable() { // @Override // public void run() { Vector<String> internalFramesTitles = new Vector<String>(getHashMapEditorFrames().keySet()); for (String internalFrameTitles : internalFramesTitles) { JInternalFrame internalFrame = getHashMapEditorFrames().get(internalFrameTitles); if (internalFrame instanceof BasicGraphGuiProperties) { // --- Put notification into the property dialog ---- BasicGraphGuiProperties basicProperties = (BasicGraphGuiProperties) internalFrame; if (basicProperties.setDataModelNotification(dataModelNotification)==true) return; // --- Done ! --- } } // } // }); }
/** * Removes the given component from this canvas. * * @param comp The {@code Component} to remove. */ public void removeFromCanvas(Component comp) { if (comp == null) return; final Rectangle updateBounds = comp.getBounds(); final JInternalFrame frame = getInternalFrame(comp); notifyClose(comp, frame); if (frame != null && frame != comp) { frame.dispose(); } else { // Java 1.7.0 as seen on Fedora with: // Java version: 1.7.0_40 // Java WM version: 24.0-b56 // crashes here deep in the java libraries. try { super.remove(comp); } catch (Exception e) { logger.log(Level.WARNING, "Java crash", e); } } repaint(updateBounds.x, updateBounds.y, updateBounds.width, updateBounds.height); }
/** * Close a panel by class name. * * @param panel The panel to close. */ public void closePanel(String panel) { if (panel.endsWith("Panel")) { for (Component c1 : getComponents()) { if (c1 instanceof JInternalFrame) { for (Component c2 : ((JInternalFrame)c1).getContentPane() .getComponents()) { if (panel.equals(c2.getClass().getName())) { notifyClose(c2, (JInternalFrame)c1); return; } } } } } else if (panel.endsWith("Dialog")) { for (FreeColDialog<?> fcd : dialogs) { if (panel.equals(fcd.getClass().getName())) { dialogs.remove(fcd); fcd.dispose(); return; } } } }
/** * Return true if the given component is likely to be a container such the each * component within the container should be be considered as a user input. * * @param c * @return true if the component children should have this listener added. */ protected boolean isProbablyAContainer (Component c) { boolean result = extListener != null ? extListener.isContainer(c) : false; if (!result) { boolean isSwing = isSwingClass(c); if (isSwing) { result = c instanceof JPanel || c instanceof JSplitPane || c instanceof JToolBar || c instanceof JViewport || c instanceof JScrollPane || c instanceof JFrame || c instanceof JRootPane || c instanceof Window || c instanceof Frame || c instanceof Dialog || c instanceof JTabbedPane || c instanceof JInternalFrame || c instanceof JDesktopPane || c instanceof JLayeredPane; } else { result = c instanceof Container; } } return result; }
/** * Gets a currently displayed FreeColPanel of a given type. * * @param <T> The actual panel type. * @param type The type of {@code FreeColPanel} to look for. * @return A currently displayed {@code FreeColPanel} of the * requested type, or null if none found. */ private <T extends FreeColPanel> T getExistingFreeColPanel(Class<T> type) { for (Component c1 : getComponents()) { if (c1 instanceof JInternalFrame) { for (Component c2 : ((JInternalFrame)c1).getContentPane() .getComponents()) { try { T ret = type.cast(c2); if (ret != null) { final JInternalFrame jif = (JInternalFrame)c1; SwingUtilities.invokeLater(() -> { jif.toFront(); jif.repaint(); }); return ret; } } catch (ClassCastException cce) {} } } } return null; }
private static void createUI() { frame = new JFrame(); frame.setUndecorated(true); frame.setSize(300, 300); frame.setLocationRelativeTo(null); final JDesktopPane pane = new JDesktopPane(); final JPanel panel = new JPanel() { @Override protected void paintComponent(Graphics g) { g.setColor(color); g.fillRect(0, 0, getWidth(), getHeight()); } }; jif = new JInternalFrame(); jif.add(panel); jif.setVisible(true); jif.setSize(300, 300); pane.add(jif); frame.add(pane); frame.setVisible(true); }
public Test6505027(JFrame main) { Container container = main; if (INTERNAL) { JInternalFrame frame = new JInternalFrame(); frame.setBounds(OFFSET, OFFSET, WIDTH, HEIGHT); frame.setVisible(true); JDesktopPane desktop = new JDesktopPane(); desktop.add(frame, new Integer(1)); container.add(desktop); container = frame; } if (TERMINATE) { this.table.putClientProperty(KEY, Boolean.TRUE); } TableColumn column = this.table.getColumn(COLUMNS[1]); column.setCellEditor(new DefaultCellEditor(new JComboBox(ITEMS))); container.add(BorderLayout.NORTH, new JTextField()); container.add(BorderLayout.CENTER, new JScrollPane(this.table)); }
/** * Maps {@code JInternalFrame.getDesktopIcon()} through queue */ public JDesktopIcon getDesktopIcon() { return (runMapping(new MapAction<JDesktopIcon>("getDesktopIcon") { @Override public JDesktopIcon map() { return ((JInternalFrame) getSource()).getDesktopIcon(); } })); }
/** * Maps {@code JInternalFrame.setGlassPane(Component)} through queue */ public void setGlassPane(final Component component) { runMapping(new MapVoidAction("setGlassPane") { @Override public void map() { ((JInternalFrame) getSource()).setGlassPane(component); } }); }
/** * Returns the progress monitor container that is either a JDialog or a JInternFrame. * @return the progress monitor container */ private Container getProgressMonitorContainer() { if (progressMonitorContainer==null) { Dimension defaultSize = new Dimension(570, 188); if (this.parentDesktopPane==null) { JDialog jDialog = new JDialog(this.owner); jDialog.setSize(defaultSize); jDialog.setResizable(false); if (this.owner==null) { jDialog.setAlwaysOnTop(true); } jDialog.setTitle(this.windowTitle); if (this.iconImage!=null) { jDialog.setIconImage(this.iconImage.getImage()); } jDialog.setContentPane(this.getJContentPane()); jDialog.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); this.progressMonitorContainer = jDialog; this.setLookAndFeel(); } else { JInternalFrame jInternalFrame = new JInternalFrame(); jInternalFrame.setSize(defaultSize); jInternalFrame.setResizable(false); jInternalFrame.setTitle(this.windowTitle); if (this.iconImage!=null) { jInternalFrame.setFrameIcon(this.iconImage); } jInternalFrame.setContentPane(this.getJContentPane()); jInternalFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); this.progressMonitorContainer = jInternalFrame; } } return progressMonitorContainer; }
/** * Maps {@code JInternalFrame.setFrameIcon(Icon)} through queue */ public void setFrameIcon(final Icon icon) { runMapping(new MapVoidAction("setFrameIcon") { @Override public void map() { ((JInternalFrame) getSource()).setFrameIcon(icon); } }); }
/** * Returns a HashMap with all open editor windows. * @return the local a HashMap with all open property windows */ public HashMap<String, JInternalFrame> getHashMapEditorFrames() { if (this.editorFrames==null) { editorFrames = new HashMap<String, JInternalFrame>(); } return editorFrames; }
/** * A component is closing. Some components need position and size * to be saved. * * @param c The closing {@code Component}. * @param frame The enclosing {@code JInternalFrame}. */ private void notifyClose(Component c, JInternalFrame frame) { if (frame == null) return; if (c instanceof FreeColPanel) { FreeColPanel fcp = (FreeColPanel)c; fcp.firePropertyChange("closing", false, true); savePosition(fcp, frame.getLocation()); saveSize(fcp, fcp.getSize()); } }
/** * Gets the last opened JInternalFrame. * @return the last opened JInternalFrame */ public JInternalFrame getLastOpenedEditor() { if (this.lastOpenedEditor.size()==0) { return null; } return lastOpenedEditor.lastElement(); }
/** * Will close all open property windows for GraphNodes and NetworkCoponents. */ public void closeAllBasicGraphGuiProperties() { Vector<String> internalFramesTitles = new Vector<String>(this.getHashMapEditorFrames().keySet()); for (String internalFrameTitles : internalFramesTitles) { JInternalFrame internalFrame = this.getHashMapEditorFrames().get(internalFrameTitles); if (internalFrame instanceof BasicGraphGuiProperties) { try { internalFrame.setClosed(true); } catch (PropertyVetoException pve) { pve.printStackTrace(); } } } }
/** * Maps {@code JInternalFrame.getTitle()} through queue */ public String getTitle() { return (runMapping(new MapAction<String>("getTitle") { @Override public String map() { return ((JInternalFrame) getSource()).getTitle(); } })); }
/** * Sets the expansion direction. */ private void configureExpansionDirection() { if (this.getParent()==null) return; boolean isExtraDialog = false; this.mainFrame = null; this.mainFrameOldSize = this.getSize(); // --- Find out how the OntologyInstanceViewer is embedded -- Container container = this.getParent(); while (container.getParent()!=null) { container = container.getParent(); if (OntologyVisualisationConfiguration.getOwnerWindow()!=null && container==OntologyVisualisationConfiguration.getOwnerWindow()) { isExtraDialog=false; break; } else { if (container instanceof JDialog) { isExtraDialog=true; this.mainFrame=container; this.mainFrameOldSize = this.mainFrame.getSize(); break; } else if (container instanceof JInternalFrame) { isExtraDialog=true; this.mainFrame=container; this.mainFrameOldSize = this.mainFrame.getSize(); break; } } } // --- Set the expansion direction -------------------------- if (isExtraDialog==true) { this.expansionDirection = EXPANSION_Horizontal; } else { this.expansionDirection = EXPANSION_Vertical; } }
/** * Maps {@code JInternalFrame.isMaximizable()} through queue */ public boolean isMaximizable() { return (runMapping(new MapBooleanAction("isMaximizable") { @Override public boolean map() { return ((JInternalFrame) getSource()).isMaximizable(); } })); }
/** * Sets the title. * @param title the new title */ private void setTitle(String title) { Container progressCont = this.getProgressMonitorContainer(); if (progressCont instanceof JDialog) { ((JDialog) progressCont).setTitle(title); } else if (progressCont instanceof JInternalFrame) { ((JInternalFrame) progressCont).setTitle(title); } }
/** * Maps {@code JInternalFrame.setDefaultCloseOperation(int)} through queue */ public void setDefaultCloseOperation(final int i) { runMapping(new MapVoidAction("setDefaultCloseOperation") { @Override public void map() { ((JInternalFrame) getSource()).setDefaultCloseOperation(i); } }); }
public String getOMapClassName() { if (component instanceof Frame || component instanceof Window || component instanceof Dialog || component instanceof JInternalFrame) { String className = component.getClass().getName(); Package pkg = component.getClass().getPackage(); if (pkg == null) { return className; } String pkgName = pkg.getName(); if (!pkgName.startsWith("javax.swing") && !pkgName.startsWith("java.awt")) { return className; } if (className.equals("javax.swing.ColorChooserDialog")) { return className; } if (component instanceof JDialog) { Component[] components = ((JDialog) component).getContentPane().getComponents(); if (components.length == 1 && components[0] instanceof JFileChooser) { return JFileChooser.class.getName() + "#Dialog"; } if (components.length == 1 && components[0] instanceof JOptionPane) { return JOptionPane.class.getName() + "#Dialog_" + ((JOptionPane) components[0]).getMessageType() + "_" + ((JOptionPane) components[0]).getOptionType(); } } return null; } return null; }
public String getOMapClassSimpleName() { if (component instanceof Frame || component instanceof Window || component instanceof Dialog || component instanceof JInternalFrame) { String className = component.getClass().getName(); String simpleName = component.getClass().getSimpleName(); Package pkg = component.getClass().getPackage(); if (pkg == null) { return simpleName; } String pkgName = pkg.getName(); if (!pkgName.startsWith("javax.swing") && !pkgName.startsWith("java.awt")) { return simpleName; } if (className.equals("javax.swing.ColorChooserDialog")) { return simpleName; } if (component instanceof JDialog) { Component[] components = ((JDialog) component).getContentPane().getComponents(); if (components.length == 1 && components[0] instanceof JFileChooser) { return JFileChooser.class.getSimpleName() + "#Dialog"; } if (components.length == 1 && components[0] instanceof JOptionPane) { return JOptionPane.class.getSimpleName() + "#Dialog"; } } return null; } return null; }
/** * Waits JInternalframe in container. * * @param cont Container to search component in. * @param chooser a component chooser specifying searching criteria. * @param index Ordinal component index. * @return JInternalframe instance. * */ public static JInternalFrame waitJInternalFrame(final Container cont, final ComponentChooser chooser, final int index) { Component res = waitComponent(cont, new JInternalFrameFinder(chooser), index); if (res instanceof JInternalFrame) { return (JInternalFrame) res; } else if (res instanceof JInternalFrame.JDesktopIcon) { return ((JInternalFrame.JDesktopIcon) res).getInternalFrame(); } else { throw (new TimeoutExpiredException(chooser.getDescription())); } }
/** * Maps {@code JInternalFrame.getJMenuBar()} through queue */ public JMenuBar getJMenuBar() { return (runMapping(new MapAction<JMenuBar>("getJMenuBar") { @Override public JMenuBar map() { return ((JInternalFrame) getSource()).getJMenuBar(); } })); }
public void findContainerNP() { List<List<String>> np = config.findContainerNP(Window.class); AssertJUnit.assertEquals(1, np.size()); np = config.findContainerNP(JInternalFrame.class); AssertJUnit.assertEquals(1, np.size()); np = config.findContainerNP(JWindow.class); AssertJUnit.assertEquals(2, np.size()); }
/** * Maps {@code JInternalFrame.isResizable()} through queue */ public boolean isResizable() { return (runMapping(new MapBooleanAction("isResizable") { @Override public boolean map() { return ((JInternalFrame) getSource()).isResizable(); } })); }
/** * Maps {@code JInternalFrame.setClosable(boolean)} through queue */ public void setClosable(final boolean b) { runMapping(new MapVoidAction("setClosable") { @Override public void map() { ((JInternalFrame) getSource()).setClosable(b); } }); }
private void cascadeFrames(JInternalFrame[] frames, int separation) { if(frames.length<=0) return; java.awt.Rectangle bounds = getBounds(); int margin = frames.length*separation+separation; for(int frame=0;frame<frames.length;frame++) frames[frame].setBounds(separation+bounds.x+frame*separation, separation+bounds.y+frame*separation, bounds.width-margin, bounds.height-margin); }
public static void selectFrame(final JInternalFrame frame) { SwingUtilities.invokeLater(new Runnable(){ @Override public void run() { frame.requestFocusInWindow(); try { frame.setSelected(true); } catch (PropertyVetoException e) {} frame.toFront(); } }); }
/** * Maps {@code JInternalFrame.isSelected()} through queue */ public boolean isSelected() { return (runMapping(new MapBooleanAction("isSelected") { @Override public boolean map() { return ((JInternalFrame) getSource()).isSelected(); } })); }
/** * Método responsável por instanciar e mostrar a tela de Operações Bancarias * */ public void mostraTelaOperacoesBancarias() { JInternalFrame newFrame = new OperacoesBanco(this.contaService, clienteSelecionado); newFrame.setBounds(frameInterno.getBounds()); panelInterno.add(newFrame); newFrame.show(); }
public TableEditorTable(List<Attribute> attributes, GUIFramework framework) { this.framework = framework; this.attributes = attributes; plugins = new AttributePlugin[attributes.size()]; cellEditors = new TableCellEditor[plugins.length]; cellRenderers = new TableCellRenderer[plugins.length]; setHorizontalScrollEnabled(true); setShowVerticalLines(true); getInputMap(JInternalFrame.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put( KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "RamusENTER_Action"); getInputMap(JInternalFrame.WHEN_FOCUSED).put( KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "RamusENTER_Action"); AbstractAction ramusEnterAction = new AbstractAction() { /** * */ private static final long serialVersionUID = 4745861738845278043L; public void actionPerformed(ActionEvent ae) { CellEditor editor = getCellEditor(); if (editor != null) editor.stopCellEditing(); } }; getActionMap().put("RamusENTER_Action", ramusEnterAction); }
/** * Gets the internal frame for the given component. * * @param c The {@code Component}. * @return The given component if this is an internal frame or the * first parent that is an internal frame. Returns * {@code null} if no internal frame is found. */ private JInternalFrame getInternalFrame(final Component c) { Component temp = c; while (temp != null && !(temp instanceof JInternalFrame)) { temp = temp.getParent(); } return (JInternalFrame) temp; }
/** * Closes all the menus that are currently open. */ public void closeMenus() { for (JInternalFrame frame : getAllFrames()) { for (Component c : frame.getContentPane().getComponents()) { notifyClose(c, frame); } frame.dispose(); } while (!dialogs.isEmpty()) { FreeColDialog<?> dialog = dialogs.remove(0); dialog.dispose(); } }
/** * Maps {@code JInternalFrame.setDesktopIcon(JDesktopIcon)} through queue */ public void setDesktopIcon(final JDesktopIcon jDesktopIcon) { runMapping(new MapVoidAction("setDesktopIcon") { @Override public void map() { ((JInternalFrame) getSource()).setDesktopIcon(jDesktopIcon); } }); }