Java Code Examples for javax.swing.JInternalFrame

The following are top voted examples for showing how to use javax.swing.JInternalFrame. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: incubator-netbeans   File: WindowBuilders.java   View source code 6 votes vote down vote up
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;
}
 
Example 2
Project: openjdk-jdk10   File: JInternalFrameOperator.java   View source code 6 votes vote down vote up
/**
 * 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;
}
 
Example 3
Project: AgentWorkbench   File: BasicGraphGuiJDesktopPane.java   View source code 6 votes vote down vote up
/**
	 * 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 ! ---
					}
				}			
			
//			}
//		});
		
	}
 
Example 4
Project: FreeCol   File: Canvas.java   View source code 6 votes vote down vote up
/**
 * 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);
}
 
Example 5
Project: FreeCol   File: Canvas.java   View source code 6 votes vote down vote up
/**
 * 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;
            }
        }
    }        
}
 
Example 6
Project: VASSAL-src   File: GenericListener.java   View source code 6 votes vote down vote up
/**
 * 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;
}
 
Example 7
Project: freecol   File: Canvas.java   View source code 6 votes vote down vote up
/**
 * 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;
}
 
Example 8
Project: FreeCol   File: Canvas.java   View source code 6 votes vote down vote up
/**
 * 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;
}
 
Example 9
Project: openjdk-jdk10   File: DockIconRepaint.java   View source code 6 votes vote down vote up
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);
}
 
Example 10
Project: openjdk-jdk10   File: Test6505027.java   View source code 6 votes vote down vote up
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));
}
 
Example 11
Project: openjdk-jdk10   File: JInternalFrameOperator.java   View source code 5 votes vote down vote up
/**
 * Maps {@code JInternalFrame.getDesktopIcon()} through queue
 */
public JDesktopIcon getDesktopIcon() {
    return (runMapping(new MapAction<JDesktopIcon>("getDesktopIcon") {
        @Override
        public JDesktopIcon map() {
            return ((JInternalFrame) getSource()).getDesktopIcon();
        }
    }));
}
 
Example 12
Project: openjdk-jdk10   File: JInternalFrameOperator.java   View source code 5 votes vote down vote up
/**
 * 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);
        }
    });
}
 
Example 13
Project: AgentWorkbench   File: ProgressMonitor.java   View source code 5 votes vote down vote up
/**
 * 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;
}
 
Example 14
Project: openjdk-jdk10   File: JInternalFrameOperator.java   View source code 5 votes vote down vote up
/**
 * 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);
        }
    });
}
 
Example 15
Project: AgentWorkbench   File: BasicGraphGuiJDesktopPane.java   View source code 5 votes vote down vote up
/**
 * 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;
}
 
Example 16
Project: FreeCol   File: Canvas.java   View source code 5 votes vote down vote up
/**
 * 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());
    }
}
 
Example 17
Project: AgentWorkbench   File: BasicGraphGuiJDesktopPane.java   View source code 5 votes vote down vote up
/**
 * Gets the last opened JInternalFrame.
 * @return the last opened JInternalFrame
 */
public JInternalFrame getLastOpenedEditor() {
	if (this.lastOpenedEditor.size()==0) {
		return null;	
	} 
	return lastOpenedEditor.lastElement();
}
 
Example 18
Project: AgentWorkbench   File: BasicGraphGuiJDesktopPane.java   View source code 5 votes vote down vote up
/**
 * 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();
			}
		}
	}
}
 
Example 19
Project: openjdk-jdk10   File: JInternalFrameOperator.java   View source code 5 votes vote down vote up
/**
 * Maps {@code JInternalFrame.getTitle()} through queue
 */
public String getTitle() {
    return (runMapping(new MapAction<String>("getTitle") {
        @Override
        public String map() {
            return ((JInternalFrame) getSource()).getTitle();
        }
    }));
}
 
Example 20
Project: AgentWorkbench   File: DynTableJPanel.java   View source code 5 votes vote down vote up
/**
 * 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;
	}	
}
 
Example 21
Project: openjdk-jdk10   File: JInternalFrameOperator.java   View source code 5 votes vote down vote up
/**
 * Maps {@code JInternalFrame.isMaximizable()} through queue
 */
public boolean isMaximizable() {
    return (runMapping(new MapBooleanAction("isMaximizable") {
        @Override
        public boolean map() {
            return ((JInternalFrame) getSource()).isMaximizable();
        }
    }));
}
 
Example 22
Project: AgentWorkbench   File: ProgressMonitor.java   View source code 5 votes vote down vote up
/**
 * 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);
	}
}
 
Example 23
Project: openjdk-jdk10   File: JInternalFrameOperator.java   View source code 5 votes vote down vote up
/**
 * 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);
        }
    });
}
 
Example 24
Project: marathonv5   File: JavaElementPropertyAccessor.java   View source code 5 votes vote down vote up
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;
}
 
Example 25
Project: marathonv5   File: JavaElementPropertyAccessor.java   View source code 5 votes vote down vote up
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;
}
 
Example 26
Project: openjdk-jdk10   File: JInternalFrameOperator.java   View source code 5 votes vote down vote up
/**
 * 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()));
    }
}
 
Example 27
Project: openjdk-jdk10   File: JInternalFrameOperator.java   View source code 5 votes vote down vote up
/**
 * Maps {@code JInternalFrame.getJMenuBar()} through queue
 */
public JMenuBar getJMenuBar() {
    return (runMapping(new MapAction<JMenuBar>("getJMenuBar") {
        @Override
        public JMenuBar map() {
            return ((JInternalFrame) getSource()).getJMenuBar();
        }
    }));
}
 
Example 28
Project: marathonv5   File: JSONOMapConfigTest.java   View source code 5 votes vote down vote up
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());
}
 
Example 29
Project: marathonv5   File: JSONOMapConfigTest.java   View source code 5 votes vote down vote up
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());
}
 
Example 30
Project: openjdk-jdk10   File: JInternalFrameOperator.java   View source code 5 votes vote down vote up
/**
 * Maps {@code JInternalFrame.isResizable()} through queue
 */
public boolean isResizable() {
    return (runMapping(new MapBooleanAction("isResizable") {
        @Override
        public boolean map() {
            return ((JInternalFrame) getSource()).isResizable();
        }
    }));
}
 
Example 31
Project: openjdk-jdk10   File: JInternalFrameOperator.java   View source code 5 votes vote down vote up
/**
 * 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);
        }
    });
}
 
Example 32
Project: JDigitalSimulator   File: Application.java   View source code 5 votes vote down vote up
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);
}
 
Example 33
Project: JDigitalSimulator   File: Guitilities.java   View source code 5 votes vote down vote up
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();
		}
	});
}
 
Example 34
Project: openjdk-jdk10   File: JInternalFrameOperator.java   View source code 5 votes vote down vote up
/**
 * Maps {@code JInternalFrame.isSelected()} through queue
 */
public boolean isSelected() {
    return (runMapping(new MapBooleanAction("isSelected") {
        @Override
        public boolean map() {
            return ((JInternalFrame) getSource()).isSelected();
        }
    }));
}
 
Example 35
Project: 3way_laboratorios   File: Inicial.java   View source code 5 votes vote down vote up
/**
* 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();
}
 
Example 36
Project: ramus   File: TableEditorTable.java   View source code 5 votes vote down vote up
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);
}
 
Example 37
Project: freecol   File: Canvas.java   View source code 5 votes vote down vote up
/**
 * 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;
}
 
Example 38
Project: freecol   File: Canvas.java   View source code 5 votes vote down vote up
/**
 * 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());
    }
}
 
Example 39
Project: freecol   File: Canvas.java   View source code 5 votes vote down vote up
/**
 * 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();
    }
}
 
Example 40
Project: openjdk-jdk10   File: JInternalFrameOperator.java   View source code 5 votes vote down vote up
/**
 * 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);
        }
    });
}