List of usage examples for javax.swing JComponent WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
int WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
To view the source code for javax.swing JComponent WHEN_ANCESTOR_OF_FOCUSED_COMPONENT.
Click Source Link
registerKeyboardAction
that means that the command should be invoked when the receiving component is an ancestor of the focused component or is itself the focused component. From source file:davmail.ui.SettingsFrame.java
/** * DavMail settings frame./* w w w .j av a 2 s .c om*/ */ public SettingsFrame() { setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); setTitle(BundleMessage.format("UI_DAVMAIL_SETTINGS")); try { setIconImage(DavGatewayTray.getFrameIcon()); } catch (NoSuchMethodError error) { DavGatewayTray.debug(new BundleMessage("LOG_UNABLE_TO_SET_ICON_IMAGE")); } JTabbedPane tabbedPane = new JTabbedPane(); // add help (F1 handler) tabbedPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke("F1"), "help"); tabbedPane.getActionMap().put("help", new AbstractAction() { public void actionPerformed(ActionEvent e) { DesktopBrowser.browse("http://davmail.sourceforge.net"); } }); tabbedPane.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { boolean isSslEnabled = isSslEnabled(); popNoSSLCheckBox.setEnabled(Settings.getProperty("davmail.popPort") != null && isSslEnabled); imapNoSSLCheckBox.setEnabled(imapPortCheckBox.isSelected() && isSslEnabled); smtpNoSSLCheckBox.setEnabled(smtpPortCheckBox.isSelected() && isSslEnabled); caldavNoSSLCheckBox.setEnabled(caldavPortCheckBox.isSelected() && isSslEnabled); ldapNoSSLCheckBox.setEnabled(ldapPortCheckBox.isSelected() && isSslEnabled); } }); JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); mainPanel.add(getSettingsPanel()); mainPanel.add(getDelaysPanel()); mainPanel.add(Box.createVerticalGlue()); tabbedPane.add(BundleMessage.format("UI_TAB_MAIN"), mainPanel); JPanel proxyPanel = new JPanel(); proxyPanel.setLayout(new BoxLayout(proxyPanel, BoxLayout.Y_AXIS)); proxyPanel.add(getProxyPanel()); proxyPanel.add(getNetworkSettingsPanel()); tabbedPane.add(BundleMessage.format("UI_TAB_NETWORK"), proxyPanel); JPanel encryptionPanel = new JPanel(); encryptionPanel.setLayout(new BoxLayout(encryptionPanel, BoxLayout.Y_AXIS)); encryptionPanel.add(getKeystorePanel()); encryptionPanel.add(getSmartCardPanel()); // empty panel encryptionPanel.add(new JPanel()); tabbedPane.add(BundleMessage.format("UI_TAB_ENCRYPTION"), encryptionPanel); JPanel loggingPanel = new JPanel(); loggingPanel.setLayout(new BoxLayout(loggingPanel, BoxLayout.Y_AXIS)); loggingPanel.add(getLoggingSettingsPanel()); // empty panel loggingPanel.add(new JPanel()); tabbedPane.add(BundleMessage.format("UI_TAB_LOGGING"), loggingPanel); JPanel advancedPanel = new JPanel(); advancedPanel.setLayout(new BoxLayout(advancedPanel, BoxLayout.Y_AXIS)); advancedPanel.add(getOtherSettingsPanel()); // empty panel advancedPanel.add(new JPanel()); tabbedPane.add(BundleMessage.format("UI_TAB_ADVANCED"), advancedPanel); if (OSXInfoPlist.isOSX()) { JPanel osxPanel = new JPanel(); osxPanel.setLayout(new BoxLayout(osxPanel, BoxLayout.Y_AXIS)); osxPanel.add(getOSXPanel()); // empty panel osxPanel.add(new JPanel()); tabbedPane.add(BundleMessage.format("UI_TAB_OSX"), osxPanel); } add(BorderLayout.CENTER, tabbedPane); JPanel buttonPanel = new JPanel(); JButton cancel = new JButton(BundleMessage.format("UI_BUTTON_CANCEL")); JButton ok = new JButton(BundleMessage.format("UI_BUTTON_SAVE")); JButton help = new JButton(BundleMessage.format("UI_BUTTON_HELP")); ActionListener save = new ActionListener() { public void actionPerformed(ActionEvent evt) { // save options Settings.setProperty("davmail.url", urlField.getText()); Settings.setProperty("davmail.popPort", popPortCheckBox.isSelected() ? popPortField.getText() : ""); Settings.setProperty("davmail.ssl.nosecurepop", String.valueOf(popNoSSLCheckBox.isSelected())); Settings.setProperty("davmail.imapPort", imapPortCheckBox.isSelected() ? imapPortField.getText() : ""); Settings.setProperty("davmail.ssl.nosecureimap", String.valueOf(imapNoSSLCheckBox.isSelected())); Settings.setProperty("davmail.smtpPort", smtpPortCheckBox.isSelected() ? smtpPortField.getText() : ""); Settings.setProperty("davmail.ssl.nosecuresmtp", String.valueOf(smtpNoSSLCheckBox.isSelected())); Settings.setProperty("davmail.caldavPort", caldavPortCheckBox.isSelected() ? caldavPortField.getText() : ""); Settings.setProperty("davmail.ssl.nosecurecaldav", String.valueOf(caldavNoSSLCheckBox.isSelected())); Settings.setProperty("davmail.ldapPort", ldapPortCheckBox.isSelected() ? ldapPortField.getText() : ""); Settings.setProperty("davmail.ssl.nosecureldap", String.valueOf(ldapNoSSLCheckBox.isSelected())); Settings.setProperty("davmail.keepDelay", keepDelayField.getText()); Settings.setProperty("davmail.sentKeepDelay", sentKeepDelayField.getText()); Settings.setProperty("davmail.caldavPastDelay", caldavPastDelayField.getText()); Settings.setProperty("davmail.imapIdleDelay", imapIdleDelayField.getText()); Settings.setProperty("davmail.useSystemProxies", String.valueOf(useSystemProxiesField.isSelected())); Settings.setProperty("davmail.enableProxy", String.valueOf(enableProxyField.isSelected())); Settings.setProperty("davmail.proxyHost", httpProxyField.getText()); Settings.setProperty("davmail.proxyPort", httpProxyPortField.getText()); Settings.setProperty("davmail.proxyUser", httpProxyUserField.getText()); Settings.setProperty("davmail.proxyPassword", httpProxyPasswordField.getText()); Settings.setProperty("davmail.noProxyFor", noProxyForField.getText()); Settings.setProperty("davmail.bindAddress", bindAddressField.getText()); Settings.setProperty("davmail.clientSoTimeout", String.valueOf(clientSoTimeoutField.getText())); Settings.setProperty("davmail.allowRemote", String.valueOf(allowRemoteField.isSelected())); Settings.setProperty("davmail.server.certificate.hash", certHashField.getText()); Settings.setProperty("davmail.disableUpdateCheck", String.valueOf(disableUpdateCheck.isSelected())); Settings.setProperty("davmail.caldavEditNotifications", String.valueOf(caldavEditNotificationsField.isSelected())); Settings.setProperty("davmail.caldavAlarmSound", String.valueOf(caldavAlarmSoundField.getText())); Settings.setProperty("davmail.forceActiveSyncUpdate", String.valueOf(forceActiveSyncUpdateCheckBox.isSelected())); Settings.setProperty("davmail.defaultDomain", String.valueOf(defaultDomainField.getText())); Settings.setProperty("davmail.showStartupBanner", String.valueOf(showStartupBannerCheckBox.isSelected())); Settings.setProperty("davmail.disableGuiNotifications", String.valueOf(disableGuiNotificationsCheckBox.isSelected())); Settings.setProperty("davmail.imapAutoExpunge", String.valueOf(imapAutoExpungeCheckBox.isSelected())); Settings.setProperty("davmail.popMarkReadOnRetr", String.valueOf(popMarkReadOnRetrCheckBox.isSelected())); String selectedEwsMode = (String) enableEwsComboBox.getSelectedItem(); String enableEws; if (EWS.equals(selectedEwsMode)) { enableEws = "true"; } else if (WEBDAV.equals(selectedEwsMode)) { enableEws = "false"; } else { enableEws = "auto"; } Settings.setProperty("davmail.enableEws", enableEws); Settings.setProperty("davmail.smtpSaveInSent", String.valueOf(smtpSaveInSentCheckBox.isSelected())); Settings.setProperty("davmail.ssl.keystoreType", (String) keystoreTypeCombo.getSelectedItem()); Settings.setProperty("davmail.ssl.keystoreFile", keystoreFileField.getText()); Settings.setProperty("davmail.ssl.keystorePass", String.valueOf(keystorePassField.getPassword())); Settings.setProperty("davmail.ssl.keyPass", String.valueOf(keyPassField.getPassword())); Settings.setProperty("davmail.ssl.clientKeystoreType", (String) clientKeystoreTypeCombo.getSelectedItem()); Settings.setProperty("davmail.ssl.clientKeystoreFile", clientKeystoreFileField.getText()); Settings.setProperty("davmail.ssl.clientKeystorePass", String.valueOf(clientKeystorePassField.getPassword())); Settings.setProperty("davmail.ssl.pkcs11Library", pkcs11LibraryField.getText()); Settings.setProperty("davmail.ssl.pkcs11Config", pkcs11ConfigField.getText()); Settings.setLoggingLevel("rootLogger", (Level) rootLoggingLevelField.getSelectedItem()); Settings.setLoggingLevel("davmail", (Level) davmailLoggingLevelField.getSelectedItem()); Settings.setLoggingLevel("org.apache.commons.httpclient", (Level) httpclientLoggingLevelField.getSelectedItem()); Settings.setLoggingLevel("httpclient.wire", (Level) wireLoggingLevelField.getSelectedItem()); Settings.setProperty("davmail.logFilePath", logFilePathField.getText()); Settings.setProperty("davmail.logFileSize", logFileSizeField.getText()); setVisible(false); Settings.save(); if (osxHideFromDockCheckBox != null) { OSXInfoPlist.setOSXHideFromDock(osxHideFromDockCheckBox.isSelected()); } // restart listeners with new config DavGateway.restart(); } }; ok.addActionListener(save); cancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { reload(); setVisible(false); } }); help.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { DesktopBrowser.browse("http://davmail.sourceforge.net"); } }); buttonPanel.add(ok); buttonPanel.add(cancel); buttonPanel.add(help); add(BorderLayout.SOUTH, buttonPanel); pack(); //setResizable(false); // center frame setLocation(getToolkit().getScreenSize().width / 2 - getSize().width / 2, getToolkit().getScreenSize().height / 2 - getSize().height / 2); urlField.requestFocus(); }
From source file:io.heming.accountbook.ui.MainFrame.java
private void initTablePopupMenu() { JPopupMenu popupMenu = new JPopupMenu(); JMenuItem deleteMenuItem = new JMenuItem("(D)", new ImageIcon(getClass().getResource("edit-delete-6.png"))); deleteMenuItem.setMnemonic('D'); popupMenu.add(deleteMenuItem);/*from w w w. ja va 2 s . co m*/ deleteMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { deleteRecord(); } }); popupMenu.addSeparator(); JMenuItem editMenuItem = new JMenuItem("(E)", new ImageIcon(getClass().getResource("edit-4.png"))); editMenuItem.setMnemonic('E'); popupMenu.add(editMenuItem); editMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Record record = model.getRecord(table.convertRowIndexToModel(table.getSelectedRow())); showUpdateRecordDialog(record); } }); // ??popup menu table.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (disable) return; JTable table = (JTable) e.getSource(); Point point = e.getPoint(); int row = table.rowAtPoint(point); int col = table.columnAtPoint(e.getPoint()); if (SwingUtilities.isRightMouseButton(e)) { if (row >= 0 && col >= 0) { table.setRowSelectionInterval(row, row); } popupMenu.show(e.getComponent(), e.getX(), e.getY()); } else if (SwingUtilities.isLeftMouseButton(e)) { if (e.getClickCount() == 2) { if (row >= 0 && col >= 0) { // Record record = model.getRecord(table.convertRowIndexToModel(row)); // showUpdateRecordDialog(record); } } } } }); table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) .put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "Enter"); table.getActionMap().put("Enter", new AbstractAction() { @Override public void actionPerformed(ActionEvent ae) { if (disable) return; //do something on JTable enter pressed int row = table.getSelectedRow(); if (row >= 0) { Record record = model.getRecord(table.convertRowIndexToModel(row)); showUpdateRecordDialog(record); } } }); }
From source file:com.haulmont.cuba.desktop.sys.DesktopWindowManager.java
protected void assignDialogShortcuts(final JDialog dialog, JPanel panel, final Action[] actions) { ClientConfig clientConfig = configuration.getConfig(ClientConfig.class); InputMap inputMap = panel.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); ActionMap actionMap = panel.getActionMap(); String commitShortcut = getConfigValueIfConnected(clientConfig::getCommitShortcut, "cuba.gui.commitShortcut", "CTRL-ENTER"); KeyCombination okCombination = KeyCombination.create(commitShortcut); KeyStroke okKeyStroke = DesktopComponentsHelper.convertKeyCombination(okCombination); inputMap.put(okKeyStroke, "okAction"); actionMap.put("okAction", new javax.swing.AbstractAction() { @Override//from w ww . ja v a 2 s . c om public void actionPerformed(ActionEvent e) { for (Action action : actions) { if (action instanceof DialogAction) { switch (((DialogAction) action).getType()) { case OK: case YES: action.actionPerform(null); dialog.setVisible(false); cleanupAfterModalDialogClosed(null); return; } } } } }); String closeShortcut = getConfigValueIfConnected(clientConfig::getCloseShortcut, "cuba.gui.closeShortcut", "ESCAPE"); KeyCombination closeCombination = KeyCombination.create(closeShortcut); KeyStroke closeKeyStroke = DesktopComponentsHelper.convertKeyCombination(closeCombination); inputMap.put(closeKeyStroke, "closeAction"); actionMap.put("closeAction", new javax.swing.AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (actions.length == 1) { actions[0].actionPerform(null); dialog.setVisible(false); cleanupAfterModalDialogClosed(null); } else { for (Action action : actions) { if (action instanceof DialogAction) { switch (((DialogAction) action).getType()) { case CANCEL: case CLOSE: case NO: action.actionPerform(null); dialog.setVisible(false); cleanupAfterModalDialogClosed(null); return; } } } } } }); }
From source file:edu.ku.brc.specify.tasks.subpane.wb.WorkbenchPaneSS.java
/** * Adds a Key mappings./* w w w. ja v a 2s .co m*/ * @param comp comp * @param keyCode keyCode * @param actionName actionName * @param action action * @return the action */ public Action addRecordKeyMappings(final JComponent comp, final int keyCode, final String actionName, final Action action, int modifiers) { InputMap inputMap = comp.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); ActionMap actionMap = comp.getActionMap(); inputMap.put(KeyStroke.getKeyStroke(keyCode, modifiers), actionName); actionMap.put(actionName, action); //UIRegistry.registerAction(actionName, action); return action; }
From source file:edmondskarp.Gui.EdmondsKarpGui.java
private void setupUndoHotkeys() { String UNDO = "Undo action key"; String REDO = "Redo action key"; Action undoAction = new AbstractAction() { @Override//w w w.j a va2 s . co m public void actionPerformed(ActionEvent e) { controller.restoreState(true); } }; Action redoAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { controller.restoreState(false); } }; myPanel.getActionMap().put(UNDO, undoAction); myPanel.getActionMap().put(REDO, redoAction); InputMap[] inputMaps = new InputMap[] { myPanel.getInputMap(JComponent.WHEN_FOCUSED), myPanel.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT), myPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW), }; for (InputMap i : inputMaps) { i.put(KeyStroke.getKeyStroke("control Z"), UNDO); i.put(KeyStroke.getKeyStroke("control Y"), REDO); i.put(KeyStroke.getKeyStroke(KeyEvent.VK_Z, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), UNDO); } }
From source file:com.android.tools.idea.uibuilder.handlers.ui.AppBarConfigurationDialog.java
public AppBarConfigurationDialog(@NotNull ViewEditor editor) { myEditor = editor;/*from w ww . j a v a 2s. c o m*/ setTitle(DIALOG_TITLE); setContentPane(myContentPane); setModal(true); getRootPane().setDefaultButton(myButtonOK); myBackgroundImage = DEFAULT_BACKGROUND_IMAGE; myFloatingActionButtonImage = DEFAULT_FAB_IMAGE; final ActionListener updatePreviewListener = event -> { updateControls(); generatePreviews(); }; myWithTabs.addActionListener(updatePreviewListener); myTabCount.setValue(3); myCollapsing.addActionListener(updatePreviewListener); myShowBackgroundImage.addActionListener(updatePreviewListener); myFloatingActionButton.addActionListener(updatePreviewListener); myFitStatusBar.addActionListener(updatePreviewListener); myParallax.addActionListener(updatePreviewListener); myContentOverlap.addActionListener(updatePreviewListener); myContentOverlapAmount.addActionListener(updatePreviewListener); ((GridLayoutManager) myPreviewPanel.getLayout()).setRowStretch(0, 2); myTabCount.addChangeListener(event -> generatePreviews()); final ActionListener actionListener = event -> { if (event.getSource() == myBackgroundImageSelector) { String src = myEditor.displayResourceInput(EnumSet.of(ResourceType.DRAWABLE)); if (src != null) { myBackgroundImage = src; generatePreviews(); } } else if (event.getSource() == myFloatingActionButtonImageSelector) { String src = myEditor.displayResourceInput(EnumSet.of(ResourceType.DRAWABLE)); if (src != null) { myFloatingActionButtonImage = src; generatePreviews(); } } else if (event.getSource() == myButtonOK) { onOK(); } else if (event.getSource() == myButtonCancel || event.getSource() == myContentPane) { onCancel(); } }; myBackgroundImageSelector.addActionListener(actionListener); myFloatingActionButtonImageSelector.addActionListener(actionListener); myButtonOK.addActionListener(actionListener); myButtonCancel.addActionListener(actionListener); myContentPane.registerKeyboardAction(actionListener, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); myPreviewPanel.addComponentListener(new ComponentAdapter() { @Override public void componentResized(final ComponentEvent e) { updatePreviewImages(); } }); setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { onCancel(); } }); }
From source file:org.alex73.skarynka.scan.ui.scan.ScanDialogController.java
void addAction(int keyCode, Action action) { InputMap im = dialog.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); im.put(KeyStroke.getKeyStroke(keyCode, 0), action.getValue(Action.NAME)); dialog.getRootPane().getActionMap().put(action.getValue(Action.NAME), action); }
From source file:org.codinjutsu.tools.jenkins.view.BuildParamDialog.java
private void registerListeners() { buttonOK.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { onOK();/* w w w . j a v a 2 s. com*/ } }); buttonCancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { onCancel(); } }); setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { onCancel(); } }); contentPane.registerKeyboardAction(new ActionListener() { public void actionPerformed(ActionEvent e) { onCancel(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); }
From source file:org.interreg.docexplore.management.manage.ManageComponent.java
@SuppressWarnings("serial") public ManageComponent(MainWindow win, final ManageHandler handler, boolean editable, boolean showPages) { super(new BorderLayout()); this.win = win; this.handler = handler; this.bookList = new JList(new CollectionNode(this)); setBorder(BorderFactory.createLineBorder(Color.black, 1)); bookList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); bookList.setCellRenderer(new ManageCellRenderer()); //tree.setRowHeight(52); add(new JScrollPane(bookList), BorderLayout.CENTER); if (editable) { bookList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) { int index = bookList.locationToIndex(e.getPoint()); if (index < 0 || !bookList.getCellBounds(index, index).contains(e.getPoint())) return; handler.bookOpened((Book) bookList.getModel().getElementAt(index)); }//www . j a va 2 s .c om } }); this.toolbar = new ManageToolbar(this); add(toolbar, BorderLayout.NORTH); bookList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) return; int count = bookList.getSelectedIndices().length; toolbar.deleteButton.setEnabled(count > 0); toolbar.editButton.setEnabled(count == 1); // toolbar.processButton.setEnabled(count == 1); toolbar.exportButton.setEnabled(count == 1); } }); } bookList.setBackground(new JPanel().getBackground()); getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) .put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "DEL"); getActionMap().put("DEL", new AbstractAction() { public void actionPerformed(ActionEvent arg0) { @SuppressWarnings({ "unchecked", "rawtypes" }) Vector<Book> books = new Vector(Arrays.asList(bookList.getSelectedValues())); if (books.size() > 0 && handler.booksDeleted(books)) { ((CollectionNode) bookList.getModel()).reload(); bookList.clearSelection(); bookList.repaint(); } } }); }
From source file:org.kepler.gui.KeplerGraphFrame.java
/** * Override BasicGraphFrame._initBasicGraphFrame() *//* w w w. j a v a2 s .co m*/ @Override protected void _initBasicGraphFrame() { /** * @todo - FIXME - Need to move this further up the hierarchy, so other * types of frames use it too. Don't put it in a launcher class * like KeplerApplication, because it then gets overridden later, * elsewhere in PTII */ StaticGUIResources.setLookAndFeel(); _initBasicGraphFrameInitialization(); _dropTarget = BasicGraphFrameExtension.getDropTarget(_jgraph); // add a CanvasDropTargetListener so that other classes can get CanvasDropTargetListener listener = CanvasDropTargetListener.getInstance(); _dropTarget.registerAdditionalListener(listener); ActionListener deletionListener = new DeletionListener(); _rightComponent.registerKeyboardAction(deletionListener, "Delete", KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); _rightComponent.registerKeyboardAction(deletionListener, "BackSpace", KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); _initBasicGraphFrameRightComponent(); _jgraph.setRequestFocusEnabled(true); // Background color is parameterizable by preferences. Configuration configuration = getConfiguration(); if (configuration != null) { try { // Set the PtolemyPreference to the desired background. // See // http://bugzilla.ecoinformatics.org/show_bug.cgi?id=2321#c14 PtolemyPreferences preferences = PtolemyPreferences .getPtolemyPreferencesWithinConfiguration(configuration); if (_isDebugging) { _log.debug("bg: " + BACKGROUND_COLOR); } if (preferences != null) { float[] components = new float[4]; // Make sure we get only 4 elements in case the color space // is bigger than 4 components = BACKGROUND_COLOR.getComponents(components); preferences.backgroundColor.setExpression("{" + components[0] + "," + components[1] + "," + components[2] + "," + components[3] + "}"); _rightComponent.setBackground(preferences.backgroundColor.asColor()); if (_isDebugging) { _log.debug("desired background: " + BACKGROUND_COLOR + " actual background: " + preferences.backgroundColor.asColor()); } } } catch (IllegalActionException e1) { // Ignore the exception and use the default color. } } _initBasicGraphFrameRightComponentMouseListeners(); try { // The SizeAttribute property is used to specify the size // of the JGraph component. Unfortunately, with Swing's // mysterious and undocumented handling of component sizes, // there appears to be no way to control the size of the // JGraph from the size of the Frame, which is specified // by the WindowPropertiesAttribute. SizeAttribute size = (SizeAttribute) getModel().getAttribute("_vergilSize", SizeAttribute.class); if (size != null) { size.setSize(_jgraph); } else { // Set the default size. // Note that the location is of the frame, while the size // is of the scrollpane. _jgraph.setPreferredSize(new Dimension(600, 400)); } _initBasicGraphFrameSetZoomAndPan(); } catch (Exception ex) { // Ignore problems here. Errors simply result in a default // size and location. } // Create the panner. _graphPanner = new JCanvasPanner(_jgraph); _horizontalScrollBar = new JScrollBar(Adjustable.HORIZONTAL); _verticalScrollBar = new JScrollBar(Adjustable.VERTICAL); // see if we want scrollbars on the canvas or not // the answer defaults to 'no' CanvasNavigationModifierFactory CNMfactory = (CanvasNavigationModifierFactory) getConfiguration() .getAttribute("canvasNavigationModifier"); if (CNMfactory != null) { // get the scrollbar flag from the factory if // it exists in the config ScrollBarModifier modifier = CNMfactory.createScrollBarModifier(); _scrollBarFlag = modifier.getScrollBarModifier(); } _canvasPanel = new JPanel(); _canvasPanel.setBorder(null); _canvasPanel.setLayout(new BorderLayout()); if (_scrollBarFlag) { _canvasPanel.add(_horizontalScrollBar, BorderLayout.SOUTH); _canvasPanel.add(_verticalScrollBar, BorderLayout.EAST); _horizontalScrollBar.setModel(_jgraph.getGraphPane().getCanvas().getHorizontalRangeModel()); _verticalScrollBar.setModel(_jgraph.getGraphPane().getCanvas().getVerticalRangeModel()); _horizontalScrollBarListener = new ScrollBarListener(_horizontalScrollBar); _verticalScrollBarListener = new ScrollBarListener(_verticalScrollBar); _horizontalScrollBar.addAdjustmentListener(_horizontalScrollBarListener); _verticalScrollBar.addAdjustmentListener(_verticalScrollBarListener); } // NOTE: add _rightComponent instead of _jgraph since _rightComponent // may be sub-divided into tabbed panes. // see http://bugzilla.ecoinformatics.org/show_bug.cgi?id=3708 _canvasPanel.add(_rightComponent, BorderLayout.CENTER); TabManager tabman = TabManager.getInstance(); tabman.initializeTabs(this); ViewManager viewman = ViewManager.getInstance(); viewman.initializeViews(this); try { viewman.addCanvasToLocation(_canvasPanel, this); } catch (Exception e) { throw new RuntimeException("Could not add canvas panel: " + e.getMessage()); } // _jgraph.setMinimumSize(new Dimension(0, 0)); getContentPane().add(viewman.getViewArea(this), BorderLayout.CENTER); // The toolbar panel is the container that contains the main toolbar and // any additional toolbars JPanel toolbarPanel = new JPanel(); toolbarPanel.setLayout(new BoxLayout(toolbarPanel, BoxLayout.Y_AXIS)); // They // stack _toolbar = new JToolBar(); // The main Kepler toolbar toolbarPanel.add(_toolbar); getContentPane().add(toolbarPanel, BorderLayout.NORTH); // Place the // toolbar panel _initBasicGraphFrameToolBarZoomButtons(); _initBasicGraphFrameActions(); // Add a weak reference to this to keep track of all // the graph frames that have been created. _openGraphFrames.add(this); System.gc(); }