List of usage examples for javax.swing JComponent WHEN_IN_FOCUSED_WINDOW
int WHEN_IN_FOCUSED_WINDOW
To view the source code for javax.swing JComponent WHEN_IN_FOCUSED_WINDOW.
Click Source Link
registerKeyboardAction
that means that the command should be invoked when the receiving component is in the window that has the focus or is itself the focused component. From source file:org.apache.jmeter.gui.MainFrame.java
private void addQuickComponentHotkeys(JTree treevar) { Action quickComponent = new AbstractAction("Quick Component") { private static final long serialVersionUID = 1L; @Override//from ww w . j a v a 2s . co m public void actionPerformed(ActionEvent actionEvent) { String propname = "gui.quick_" + actionEvent.getActionCommand(); String comp = JMeterUtils.getProperty(propname); log.debug("Event " + propname + ": " + comp); if (comp == null) { log.warn("No component set through property: " + propname); return; } GuiPackage guiPackage = GuiPackage.getInstance(); try { guiPackage.updateCurrentNode(); TestElement testElement = guiPackage.createTestElement(SaveService.aliasToClass(comp)); JMeterTreeNode parentNode = guiPackage.getCurrentNode(); while (!MenuFactory.canAddTo(parentNode, testElement)) { parentNode = (JMeterTreeNode) parentNode.getParent(); } if (parentNode.getParent() == null) { log.debug("Cannot add element on very top level"); } else { JMeterTreeNode node = guiPackage.getTreeModel().addComponent(testElement, parentNode); guiPackage.getMainFrame().getTree().setSelectionPath(new TreePath(node.getPath())); } } catch (Exception err) { log.warn("Failed to perform quick component add: " + comp, err); // $NON-NLS-1$ } } }; InputMap inputMap = treevar.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); KeyStroke[] keyStrokes = new KeyStroke[] { KeyStrokes.CTRL_0, KeyStrokes.CTRL_1, KeyStrokes.CTRL_2, KeyStrokes.CTRL_3, KeyStrokes.CTRL_4, KeyStrokes.CTRL_5, KeyStrokes.CTRL_6, KeyStrokes.CTRL_7, KeyStrokes.CTRL_8, KeyStrokes.CTRL_9, }; for (int n = 0; n < keyStrokes.length; n++) { treevar.getActionMap().put(ActionNames.QUICK_COMPONENT + String.valueOf(n), quickComponent); inputMap.put(keyStrokes[n], ActionNames.QUICK_COMPONENT + String.valueOf(n)); } }
From source file:org.apache.log4j.chainsaw.LogUI.java
/** * Initialises the menu's and toolbars, but does not actually create any of * the main panel components./*from w w w .j a va 2 s. co m*/ * */ private void initGUI() { setupHelpSystem(); statusBar = new ChainsawStatusBar(this); setupReceiverPanel(); setToolBarAndMenus(new ChainsawToolBarAndMenus(this)); toolbar = getToolBarAndMenus().getToolbar(); setJMenuBar(getToolBarAndMenus().getMenubar()); setTabbedPane(new ChainsawTabbedPane()); getSettingsManager().addSettingsListener(getTabbedPane()); getSettingsManager().configure(getTabbedPane()); /** * This adds Drag & Drop capability to Chainsaw */ FileDnDTarget dnDTarget = new FileDnDTarget(tabbedPane); dnDTarget.addPropertyChangeListener("fileList", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { final List fileList = (List) evt.getNewValue(); Thread thread = new Thread(new Runnable() { public void run() { logger.debug("Loading files: " + fileList); for (Iterator iter = fileList.iterator(); iter.hasNext();) { File file = (File) iter.next(); final Decoder decoder = new XMLDecoder(); try { getStatusBar().setMessage("Loading " + file.getAbsolutePath() + "..."); FileLoadAction.importURL(handler, decoder, file.getName(), file.toURI().toURL()); } catch (Exception e) { String errorMsg = "Failed to import a file"; logger.error(errorMsg, e); getStatusBar().setMessage(errorMsg); } } } }); thread.setPriority(Thread.MIN_PRIORITY); thread.start(); } }); applicationPreferenceModelPanel = new ApplicationPreferenceModelPanel(applicationPreferenceModel); applicationPreferenceModelPanel.setOkCancelActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { preferencesFrame.setVisible(false); } }); KeyStroke escape = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false); Action closeAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { preferencesFrame.setVisible(false); } }; preferencesFrame.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escape, "ESCAPE"); preferencesFrame.getRootPane().getActionMap().put("ESCAPE", closeAction); OSXIntegration.init(this); }
From source file:org.apache.log4j.chainsaw.LogUI.java
/** * Activates itself as a viewer by configuring Size, and location of itself, * and configures the default Tabbed Pane elements with the correct layout, * table columns, and sets itself viewable. *///from w w w. j a v a2s. c o m public void activateViewer() { LoggerRepository repo = LogManager.getLoggerRepository(); if (repo instanceof LoggerRepositoryEx) { this.pluginRegistry = ((LoggerRepositoryEx) repo).getPluginRegistry(); } initGUI(); initPrefModelListeners(); /** * We add a simple appender to the MessageCenter logger * so that each message is displayed in the Status bar */ MessageCenter.getInstance().getLogger().addAppender(new AppenderSkeleton() { protected void append(LoggingEvent event) { getStatusBar().setMessage(event.getMessage().toString()); } public void close() { } public boolean requiresLayout() { return false; } }); initSocketConnectionListener(); if (pluginRegistry.getPlugins(Receiver.class).size() == 0) { noReceiversDefined = true; } getFilterableColumns().add(ChainsawConstants.LEVEL_COL_NAME); getFilterableColumns().add(ChainsawConstants.LOGGER_COL_NAME); getFilterableColumns().add(ChainsawConstants.THREAD_COL_NAME); getFilterableColumns().add(ChainsawConstants.NDC_COL_NAME); getFilterableColumns().add(ChainsawConstants.PROPERTIES_COL_NAME); getFilterableColumns().add(ChainsawConstants.CLASS_COL_NAME); getFilterableColumns().add(ChainsawConstants.METHOD_COL_NAME); getFilterableColumns().add(ChainsawConstants.FILE_COL_NAME); getFilterableColumns().add(ChainsawConstants.NONE_COL_NAME); JPanel panePanel = new JPanel(); panePanel.setLayout(new BorderLayout(2, 2)); getContentPane().setLayout(new BorderLayout()); getTabbedPane().addChangeListener(getToolBarAndMenus()); getTabbedPane().addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { LogPanel thisLogPanel = getCurrentLogPanel(); if (thisLogPanel != null) { thisLogPanel.updateStatusBar(); } } }); KeyStroke ksRight = KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); KeyStroke ksLeft = KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); KeyStroke ksGotoLine = KeyStroke.getKeyStroke(KeyEvent.VK_G, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); getTabbedPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(ksRight, "MoveRight"); getTabbedPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(ksLeft, "MoveLeft"); getTabbedPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(ksGotoLine, "GotoLine"); Action moveRight = new AbstractAction() { public void actionPerformed(ActionEvent e) { int temp = getTabbedPane().getSelectedIndex(); ++temp; if (temp != getTabbedPane().getTabCount()) { getTabbedPane().setSelectedTab(temp); } } }; Action moveLeft = new AbstractAction() { public void actionPerformed(ActionEvent e) { int temp = getTabbedPane().getSelectedIndex(); --temp; if (temp > -1) { getTabbedPane().setSelectedTab(temp); } } }; Action gotoLine = new AbstractAction() { public void actionPerformed(ActionEvent e) { String inputLine = JOptionPane.showInputDialog(LogUI.this, "Enter the line number to go:", "Goto Line", -1); try { int lineNumber = Integer.parseInt(inputLine); int row = getCurrentLogPanel().setSelectedEvent(lineNumber); if (row == -1) { JOptionPane.showMessageDialog(LogUI.this, "You have entered an invalid line number", "Error", 0); } } catch (NumberFormatException nfe) { JOptionPane.showMessageDialog(LogUI.this, "You have entered an invalid line number", "Error", 0); } } }; getTabbedPane().getActionMap().put("MoveRight", moveRight); getTabbedPane().getActionMap().put("MoveLeft", moveLeft); getTabbedPane().getActionMap().put("GotoLine", gotoLine); /** * We listen for double clicks, and auto-undock currently selected Tab if * the mouse event location matches the currently selected tab */ getTabbedPane().addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { super.mouseClicked(e); if ((e.getClickCount() > 1) && ((e.getModifiers() & InputEvent.BUTTON1_MASK) > 0)) { int tabIndex = getTabbedPane().getSelectedIndex(); if ((tabIndex != -1) && (tabIndex == getTabbedPane().getSelectedIndex())) { LogPanel logPanel = getCurrentLogPanel(); if (logPanel != null) { logPanel.undock(); } } } } }); panePanel.add(getTabbedPane()); addWelcomePanel(); getContentPane().add(toolbar, BorderLayout.NORTH); getContentPane().add(statusBar, BorderLayout.SOUTH); mainReceiverSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panePanel, receiversPanel); dividerSize = mainReceiverSplitPane.getDividerSize(); mainReceiverSplitPane.setDividerLocation(-1); getContentPane().add(mainReceiverSplitPane, BorderLayout.CENTER); /** * We need to make sure that all the internal GUI components have been added to the * JFrame so that any plugns that get activated during initPlugins(...) method * have access to inject menus */ initPlugins(pluginRegistry); mainReceiverSplitPane.setResizeWeight(1.0); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent event) { exit(); } }); preferencesFrame.setTitle("'Application-wide Preferences"); preferencesFrame.setIconImage(((ImageIcon) ChainsawIcons.ICON_PREFERENCES).getImage()); preferencesFrame.getContentPane().add(applicationPreferenceModelPanel); preferencesFrame.setSize(750, 520); Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize(); preferencesFrame.setLocation(new Point((screenDimension.width / 2) - (preferencesFrame.getSize().width / 2), (screenDimension.height / 2) - (preferencesFrame.getSize().height / 2))); pack(); final JPopupMenu tabPopup = new JPopupMenu(); final Action hideCurrentTabAction = new AbstractAction("Hide") { public void actionPerformed(ActionEvent e) { Component selectedComp = getTabbedPane().getSelectedComponent(); if (selectedComp instanceof LogPanel) { displayPanel(getCurrentLogPanel().getIdentifier(), false); tbms.stateChange(); } else { getTabbedPane().remove(selectedComp); } } }; final Action hideOtherTabsAction = new AbstractAction("Hide Others") { public void actionPerformed(ActionEvent e) { Component selectedComp = getTabbedPane().getSelectedComponent(); String currentName; if (selectedComp instanceof LogPanel) { currentName = getCurrentLogPanel().getIdentifier(); } else if (selectedComp instanceof WelcomePanel) { currentName = ChainsawTabbedPane.WELCOME_TAB; } else { currentName = ChainsawTabbedPane.ZEROCONF; } int count = getTabbedPane().getTabCount(); int index = 0; for (int i = 0; i < count; i++) { String name = getTabbedPane().getTitleAt(index); if (getPanelMap().keySet().contains(name) && !name.equals(currentName)) { displayPanel(name, false); tbms.stateChange(); } else { index++; } } } }; Action showHiddenTabsAction = new AbstractAction("Show All Hidden") { public void actionPerformed(ActionEvent e) { for (Iterator iter = getPanels().entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); Boolean docked = (Boolean) entry.getValue(); if (docked.booleanValue()) { String identifier = (String) entry.getKey(); int count = getTabbedPane().getTabCount(); boolean found = false; for (int i = 0; i < count; i++) { String name = getTabbedPane().getTitleAt(i); if (name.equals(identifier)) { found = true; break; } } if (!found) { displayPanel(identifier, true); tbms.stateChange(); } } } } }; tabPopup.add(hideCurrentTabAction); tabPopup.add(hideOtherTabsAction); tabPopup.addSeparator(); tabPopup.add(showHiddenTabsAction); final PopupListener tabPopupListener = new PopupListener(tabPopup); getTabbedPane().addMouseListener(tabPopupListener); this.handler.addPropertyChangeListener("dataRate", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { double dataRate = ((Double) evt.getNewValue()).doubleValue(); statusBar.setDataRate(dataRate); } }); getSettingsManager().addSettingsListener(this); getSettingsManager().addSettingsListener(MRUFileListPreferenceSaver.getInstance()); getSettingsManager().addSettingsListener(receiversPanel); try { //if an uncaught exception is thrown, allow the UI to continue to load getSettingsManager().loadSettings(); } catch (Exception e) { e.printStackTrace(); } //app preferences have already been loaded (and configuration url possibly set to blank if being overridden) //but we need a listener so the settings will be saved on exit (added after loadsettings was called) getSettingsManager().addSettingsListener(new ApplicationPreferenceModelSaver(applicationPreferenceModel)); setVisible(true); if (applicationPreferenceModel.isReceivers()) { showReceiverPanel(); } else { hideReceiverPanel(); } removeSplash(); synchronized (initializationLock) { isGUIFullyInitialized = true; initializationLock.notifyAll(); } if (noReceiversDefined && applicationPreferenceModel.isShowNoReceiverWarning()) { SwingHelper.invokeOnEDT(new Runnable() { public void run() { showReceiverConfigurationPanel(); } }); } Container container = tutorialFrame.getContentPane(); final JEditorPane tutorialArea = new JEditorPane(); tutorialArea.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); tutorialArea.setEditable(false); container.setLayout(new BorderLayout()); try { tutorialArea.setPage(ChainsawConstants.TUTORIAL_URL); JTextComponentFormatter.applySystemFontAndSize(tutorialArea); container.add(new JScrollPane(tutorialArea), BorderLayout.CENTER); } catch (Exception e) { MessageCenter.getInstance().getLogger().error("Error occurred loading the Tutorial", e); } tutorialFrame.setIconImage(new ImageIcon(ChainsawIcons.HELP).getImage()); tutorialFrame.setSize(new Dimension(640, 480)); final Action startTutorial = new AbstractAction("Start Tutorial", new ImageIcon(ChainsawIcons.ICON_RESUME_RECEIVER)) { public void actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog(null, "This will start 3 \"Generator\" receivers for use in the Tutorial. Is that ok?", "Confirm", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { new Thread(new Tutorial()).start(); putValue("TutorialStarted", Boolean.TRUE); } else { putValue("TutorialStarted", Boolean.FALSE); } } }; final Action stopTutorial = new AbstractAction("Stop Tutorial", new ImageIcon(ChainsawIcons.ICON_STOP_RECEIVER)) { public void actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog(null, "This will stop all of the \"Generator\" receivers used in the Tutorial, but leave any other Receiver untouched. Is that ok?", "Confirm", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { new Thread(new Runnable() { public void run() { LoggerRepository repo = LogManager.getLoggerRepository(); if (repo instanceof LoggerRepositoryEx) { PluginRegistry pluginRegistry = ((LoggerRepositoryEx) repo).getPluginRegistry(); List list = pluginRegistry.getPlugins(Generator.class); for (Iterator iter = list.iterator(); iter.hasNext();) { Plugin plugin = (Plugin) iter.next(); pluginRegistry.stopPlugin(plugin.getName()); } } } }).start(); setEnabled(false); startTutorial.putValue("TutorialStarted", Boolean.FALSE); } } }; stopTutorial.putValue(Action.SHORT_DESCRIPTION, "Removes all of the Tutorials Generator Receivers, leaving all other Receivers untouched"); startTutorial.putValue(Action.SHORT_DESCRIPTION, "Begins the Tutorial, starting up some Generator Receivers so you can see Chainsaw in action"); stopTutorial.setEnabled(false); final SmallToggleButton startButton = new SmallToggleButton(startTutorial); PropertyChangeListener pcl = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { stopTutorial.setEnabled(((Boolean) startTutorial.getValue("TutorialStarted")).equals(Boolean.TRUE)); startButton.setSelected(stopTutorial.isEnabled()); } }; startTutorial.addPropertyChangeListener(pcl); stopTutorial.addPropertyChangeListener(pcl); pluginRegistry.addPluginListener(new PluginListener() { public void pluginStarted(PluginEvent e) { } public void pluginStopped(PluginEvent e) { List list = pluginRegistry.getPlugins(Generator.class); if (list.size() == 0) { startTutorial.putValue("TutorialStarted", Boolean.FALSE); } } }); final SmallButton stopButton = new SmallButton(stopTutorial); final JToolBar tutorialToolbar = new JToolBar(); tutorialToolbar.setFloatable(false); tutorialToolbar.add(startButton); tutorialToolbar.add(stopButton); container.add(tutorialToolbar, BorderLayout.NORTH); tutorialArea.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { if (e.getDescription().equals("StartTutorial")) { startTutorial.actionPerformed(null); } else if (e.getDescription().equals("StopTutorial")) { stopTutorial.actionPerformed(null); } else { try { tutorialArea.setPage(e.getURL()); } catch (IOException e1) { MessageCenter.getInstance().getLogger() .error("Failed to change the URL for the Tutorial", e1); } } } } }); /** * loads the saved tab settings and if there are hidden tabs, * hide those tabs out of currently loaded tabs.. */ if (!getTabbedPane().tabSetting.isWelcome()) { displayPanel(ChainsawTabbedPane.WELCOME_TAB, false); } if (!getTabbedPane().tabSetting.isZeroconf()) { displayPanel(ChainsawTabbedPane.ZEROCONF, false); } tbms.stateChange(); }
From source file:org.domainmath.gui.FileTreePanel.java
/** * Handle key events like F5,DELETE etc. * @param e // w w w . j ava2 s. co m */ private void addGlobalAction(MouseEvent e) { TreePath path2 = fileTree.getPathForLocation(e.getX(), e.getY()); Rectangle pathBounds2 = fileTree.getUI().getPathBounds(fileTree, path2); if (pathBounds2 != null && pathBounds2.contains(e.getX(), e.getY())) { TreePath[] selectionPaths = fileTree.getSelectionModel().getSelectionPaths(); openAction = new OpenAction((File) fileTree.getLastSelectedPathComponent()); refreshAction = new RefreshAction((File) fileTree.getLastSelectedPathComponent()); deleteAction = new DeleteAction(selectionPaths); InputMap inputMap = getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); ActionMap actionMap = getRootPane().getActionMap(); inputMap.put(keyDeleteItem, "DeleteAction"); actionMap.put("DeleteAction", deleteAction); inputMap.put(keyOpenItem, "OpenAction"); actionMap.put("OpenAction", openAction); inputMap.put(keyRefreshItem, "RefreshAction"); actionMap.put("RefreshAction", refreshAction); } }
From source file:org.eurocarbdb.application.glycoworkbench.plugin.s3.gui.SignedGetUrlDialog.java
public SignedGetUrlDialog(Frame ownerFrame, HyperlinkActivatedListener hyperlinkListener, S3Service s3Service, S3Object[] objects) {//w w w .ja va2 s .c o m super(ownerFrame, "Generate Signed GET URLs", true); this.ownerFrame = ownerFrame; this.hyperlinkListener = hyperlinkListener; this.s3Service = s3Service; this.objects = objects; String introductionText = "<html><center>Generate signed GET URLs that you can provide to anyone<br>" + "who needs to access objects in your bucket for a limited time.</center></html>"; JHtmlLabel introductionLabel = new JHtmlLabel(introductionText, hyperlinkListener); introductionLabel.setHorizontalAlignment(JLabel.CENTER); JHtmlLabel expiryTimeLabel = new JHtmlLabel("<html><b>Expiry Time</b> (Hours)</html>", hyperlinkListener); expiryTimeLabel.setHorizontalAlignment(JLabel.RIGHT); JHtmlLabel httpsUrlsLabel = new JHtmlLabel("<html><b>Secure HTTPS URLs?</b></html>", hyperlinkListener); httpsUrlsLabel.setHorizontalAlignment(JLabel.RIGHT); JHtmlLabel virtualHostLabel = new JHtmlLabel("<html><b>Bucket is a Virtual Host?</b></html>", hyperlinkListener); virtualHostLabel.setHorizontalAlignment(JLabel.RIGHT); JHtmlLabel requesterPaysLabel = new JHtmlLabel("<html><b>Bucket is Requester Pays?</b></html>", hyperlinkListener); requesterPaysLabel.setHorizontalAlignment(JLabel.RIGHT); expiryTimeTextField = new JTextField("1.0"); expiryTimeTextField.setToolTipText("How long in hours until the URL will expire"); expiryTimeTextField.getDocument().addDocumentListener(this); httpsUrlsCheckBox = new JCheckBox(); httpsUrlsCheckBox.setSelected(false); httpsUrlsCheckBox.setToolTipText("Check this box to generate secure HTTPS URLs."); httpsUrlsCheckBox.addActionListener(this); virtualHostCheckBox = new JCheckBox(); virtualHostCheckBox.setSelected(false); virtualHostCheckBox.setToolTipText("Check this box if your bucket is configured as a virtual host."); virtualHostCheckBox.addActionListener(this); requesterPaysCheckBox = new JCheckBox(); requesterPaysCheckBox.setSelected(false); requesterPaysCheckBox.setToolTipText("Check this box if the bucket has Requester Pays enabled."); requesterPaysCheckBox.addActionListener(this); finishedButton = new JButton("Finished"); finishedButton.setActionCommand("Finished"); finishedButton.addActionListener(this); signedUrlsTextArea = new JTextArea(); signedUrlsTextArea.setEditable(false); // Set default ENTER and ESCAPE buttons. this.getRootPane().setDefaultButton(finishedButton); this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "ESCAPE"); this.getRootPane().getActionMap().put("ESCAPE", new AbstractAction() { private static final long serialVersionUID = -6225706489569112809L; public void actionPerformed(ActionEvent actionEvent) { setVisible(false); } }); JPanel panel = new JPanel(new GridBagLayout()); int row = 0; panel.add(introductionLabel, new GridBagConstraints(0, row, 6, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); panel.add(expiryTimeLabel, new GridBagConstraints(0, ++row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); panel.add(expiryTimeTextField, new GridBagConstraints(1, row, 5, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); panel.add(httpsUrlsLabel, new GridBagConstraints(0, ++row, 1, 1, 0.3, 0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); panel.add(httpsUrlsCheckBox, new GridBagConstraints(1, row, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insetsDefault, 0, 0)); panel.add(virtualHostLabel, new GridBagConstraints(2, row, 1, 1, 0.3, 0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); panel.add(virtualHostCheckBox, new GridBagConstraints(3, row, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insetsDefault, 0, 0)); panel.add(requesterPaysLabel, new GridBagConstraints(4, row, 1, 1, 0.3, 0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); panel.add(requesterPaysCheckBox, new GridBagConstraints(5, row, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insetsDefault, 0, 0)); panel.add(new JScrollPane(signedUrlsTextArea), new GridBagConstraints(0, ++row, 6, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsDefault, 0, 0)); panel.add(finishedButton, new GridBagConstraints(0, ++row, 6, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, insetsDefault, 0, 0)); this.getContentPane().setLayout(new GridBagLayout()); this.getContentPane().add(panel, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsDefault, 0, 0)); this.setSize(700, 450); this.setResizable(true); this.setLocationRelativeTo(ownerFrame); generateSignedUrls(); }
From source file:org.eurocarbdb.application.glycoworkbench.plugin.s3.gui.StartupDialog.java
/** * Initialises all GUI elements.// w ww . j ava2 s . c o m */ private void initGui() { this.setResizable(false); this.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); cancelButton = new JButton("Don't log in"); cancelButton.setActionCommand("Cancel"); cancelButton.addActionListener(this); storeCredentialsButton = new JButton("Store Credentials"); storeCredentialsButton.setActionCommand("StoreCredentials"); storeCredentialsButton.addActionListener(this); okButton = new JButton("Log in"); okButton.setActionCommand("LogIn"); okButton.addActionListener(this); // Set default ENTER and ESCAPE buttons. this.getRootPane().setDefaultButton(okButton); this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "ESCAPE"); this.getRootPane().getActionMap().put("ESCAPE", new AbstractAction() { private static final long serialVersionUID = -1742280851624947873L; public void actionPerformed(ActionEvent actionEvent) { setVisible(false); } }); JPanel buttonsPanel = new JPanel(new GridBagLayout()); buttonsPanel.add(cancelButton, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insetsZero, 0, 0)); buttonsPanel.add(storeCredentialsButton, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsZero, 0, 0)); buttonsPanel.add(okButton, new GridBagConstraints(2, 0, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsZero, 0, 0)); loginPassphrasePanel = new LoginPassphrasePanel(hyperlinkListener); loginLocalFolderPanel = new LoginLocalFolderPanel(ownerFrame, hyperlinkListener); loginCredentialsPanel = new LoginCredentialsPanel(false, hyperlinkListener); // Tabbed Pane. tabbedPane = new JTabbedPane(); tabbedPane.addChangeListener(this); tabbedPane.add(loginPassphrasePanel, "S3 Online"); tabbedPane.add(loginLocalFolderPanel, "Local Folder"); tabbedPane.add(loginCredentialsPanel, "Direct Login"); int row = 0; this.getContentPane().setLayout(new GridBagLayout()); this.getContentPane().add(tabbedPane, new GridBagConstraints(0, row++, 2, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsZero, 0, 0)); this.getContentPane().add(buttonsPanel, new GridBagConstraints(0, row++, 2, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); this.pack(); this.setSize(500, 400); this.setLocationRelativeTo(this.getOwner()); }
From source file:org.executequery.ApplicationLauncher.java
public void startup() { try {//from w ww . j a va 2s . c o m applySystemProperties(); macSettings(); x11Settings(); boolean dirsCreated = SystemResources.createUserHomeDirSettings(); aaFonts(); if (!dirsCreated) { System.exit(0); } System.setProperty("executequery.minor.version", stringApplicationProperty("eq.minor.version")); System.setProperty("executequery.minor.version", stringApplicationProperty("eq.minor.version")); SplashPanel splash = null; if (displaySplash()) { splash = createSplashPanel(); } advanceSplash(splash); // set the version number to display on the splash panel System.setProperty("executequery.major.version", stringApplicationProperty("eq.major.version")); System.setProperty("executequery.help.version", stringApplicationProperty("help.version")); advanceSplash(splash); // reset the log level from the user properties Log.setLevel(stringUserProperty("system.log.level")); advanceSplash(splash); applyKeyboardFocusManager(); if (hasLocaleSettings()) { setSystemLocaleProperties(); } else { if (Log.isDebugEnabled()) { Log.debug("User locale settings not available - resetting"); } storeSystemLocaleProperties(); } advanceSplash(splash); // set the look and feel LookAndFeelLoader lookAndFeelLoader = new LookAndFeelLoader(); loadLookAndFeel(lookAndFeelLoader); lookAndFeelLoader.decorateDialogsAndFrames(booleanUserProperty("decorate.dialog.look"), booleanUserProperty("decorate.frame.look")); advanceSplash(splash); GUIUtilities.startLogger(); advanceSplash(splash); // initialise the frame final ExecuteQueryFrame frame = createFrame(); GUIUtilities.initDesktop(frame); // initialise the actions from actions.xml ActionBuilder.build(GUIUtilities.getActionMap(), GUIUtilities.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW), Constants.ACTION_CONF_PATH); advanceSplash(splash); // build the tool bar GUIUtilities.createToolBar(); JMenuBar menuBar = new ExecuteQueryMenu(); frame.setJMenuBar(menuBar); advanceSplash(splash); boolean openConnection = booleanUserProperty("startup.connection.connect"); advanceSplash(splash); printVersionInfo(); advanceSplash(splash); frame.position(); // set proxy server settings initProxySettings(); ActionBuilder.setActionMaps(frame.getRootPane(), SystemResources.getUserActionShortcuts()); GUIUtilities.initPanels(); advanceSplash(splash); // kill the splash panel if (splash != null) { splash.dispose(); } ThreadUtils.invokeLater(new Runnable() { public void run() { frame.setVisible(true); } }); printSystemProperties(); // auto-login if selected if (openConnection) { openStartupConnection(); } doCheckForUpdate(); } catch (Exception e) { e.printStackTrace(); } }
From source file:org.executequery.gui.browser.FindAction.java
public void install(JComponent component) { this.component = component; component.registerKeyboardAction(this, INVOKE_KEY_STROKE, JComponent.WHEN_IN_FOCUSED_WINDOW); // comp.registerKeyboardAction(this, KeyStroke.getKeyStroke('I', // KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK), // JComponent.WHEN_FOCUSED); }
From source file:org.geopublishing.atlasViewer.swing.ClickInfoDialog.java
/** * Since the registerKeyboardAction() method is part of the JComponent class * definition, you must define the Escape keystroke and register the * keyboard action with a JComponent, not with a JDialog. The JRootPane for * the JDialog serves as an excellent choice to associate the registration, * as this will always be visible. If you override the protected * createRootPane() method of JDialog, you can return your custom JRootPane * with the keystroke enabled:/*from w w w. j a v a 2 s.co m*/ */ @Override protected JRootPane createRootPane() { KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); JRootPane rootPane = new JRootPane(); rootPane.registerKeyboardAction(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setVisible(false); } }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); return rootPane; }
From source file:org.jets3t.apps.cockpit.gui.StartupDialog.java
/** * Initialises all GUI elements./*from w w w.ja v a 2s. co m*/ */ private void initGui() { this.setResizable(false); this.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); cancelButton = new JButton("Don't log in"); cancelButton.setActionCommand("Cancel"); cancelButton.addActionListener(this); storeCredentialsButton = new JButton("Store Credentials"); storeCredentialsButton.setActionCommand("StoreCredentials"); storeCredentialsButton.addActionListener(this); okButton = new JButton("Log in"); okButton.setActionCommand("LogIn"); okButton.addActionListener(this); // Set default ENTER and ESCAPE buttons. this.getRootPane().setDefaultButton(okButton); this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "ESCAPE"); this.getRootPane().getActionMap().put("ESCAPE", new AbstractAction() { private static final long serialVersionUID = -1742280851624947873L; public void actionPerformed(ActionEvent actionEvent) { setVisible(false); } }); JPanel buttonsPanel = new JPanel(new GridBagLayout()); buttonsPanel.add(cancelButton, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insetsZero, 0, 0)); buttonsPanel.add(storeCredentialsButton, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsZero, 0, 0)); buttonsPanel.add(okButton, new GridBagConstraints(2, 0, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsZero, 0, 0)); loginPassphrasePanel = new LoginPassphrasePanel(hyperlinkListener); loginLocalFolderPanel = new LoginLocalFolderPanel(ownerFrame, hyperlinkListener); loginCredentialsPanel = new LoginCredentialsPanel(false, hyperlinkListener); // Target storage service selection targetS3 = new JRadioButton("Amazon S3"); targetS3.setSelected(true); targetGS = new JRadioButton("Google Storage"); ButtonGroup targetButtonGroup = new ButtonGroup(); targetButtonGroup.add(targetS3); targetButtonGroup.add(targetGS); JPanel targetServicePanel = new JPanel(new GridBagLayout()); targetServicePanel.add(targetS3, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsZero, 0, 0)); targetServicePanel.add(targetGS, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insetsZero, 0, 0)); // Tabbed Pane. tabbedPane = new JTabbedPane(); tabbedPane.addChangeListener(this); tabbedPane.add(loginPassphrasePanel, "Online"); tabbedPane.add(loginLocalFolderPanel, "Local Folder"); tabbedPane.add(loginCredentialsPanel, "Direct Login"); int row = 0; this.getContentPane().setLayout(new GridBagLayout()); this.getContentPane().add(targetServicePanel, new GridBagConstraints(0, row++, 2, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); this.getContentPane().add(tabbedPane, new GridBagConstraints(0, row++, 2, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsZero, 0, 0)); this.getContentPane().add(buttonsPanel, new GridBagConstraints(0, row++, 2, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); this.pack(); this.setSize(500, 430); this.setLocationRelativeTo(this.getOwner()); }