List of usage examples for java.awt.event KeyAdapter KeyAdapter
KeyAdapter
From source file:edu.ku.brc.af.ui.db.JAutoCompTextField.java
/** * Initializes the TextField by setting up all the listeners for auto-complete. *///from w w w. j av a2 s . c o m protected void initAdapter() { if (dbAdapter != null) { addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { addNewItemFromTextField(); } }); addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent ev) { prevCaretPos = getCaretPosition(); if (UIHelper.isMacOS()) { keyReleasedInternal(ev); } } /* (non-Javadoc) * @see java.awt.event.KeyAdapter#keyTyped(java.awt.event.KeyEvent) */ @Override public void keyTyped(KeyEvent arg0) { // TODO Auto-generated method stub super.keyTyped(arg0); } @Override public void keyReleased(KeyEvent ev) { keyReleasedInternal(ev); } }); } }
From source file:org.ut.biolab.medsavant.client.region.RegionWizard.java
private AbstractWizardPage getNamePage() { return new DefaultWizardPage(PAGENAME_NAME) { {/*from www . j a va 2 s.c o m*/ addText("Choose a name for the region list.\nThe name cannot already be in use. "); addComponent(new JTextField() { { addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { if (getText() != null && !getText().equals("")) { listName = getText(); fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.NEXT); } else { fireButtonEvent(ButtonEvent.DISABLE_BUTTON, ButtonNames.NEXT); } } }); } }); } @Override public void setupWizardButtons() { fireButtonEvent(ButtonEvent.HIDE_BUTTON, ButtonNames.FINISH); fireButtonEvent(ButtonEvent.HIDE_BUTTON, ButtonNames.BACK); fireButtonEvent(ButtonEvent.SHOW_BUTTON, ButtonNames.NEXT); if (listName == null || listName.equals("")) { fireButtonEvent(ButtonEvent.DISABLE_BUTTON, ButtonNames.NEXT); } else { fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.NEXT); } } }; }
From source file:com.mirth.connect.client.ui.components.rsta.MirthRSyntaxTextArea.java
public MirthRSyntaxTextArea(ContextType contextType, String styleKey, boolean autoCompleteEnabled) { super(new MirthRSyntaxDocument(styleKey)); this.contextType = contextType; setBackground(UIConstants.BACKGROUND_COLOR); setSyntaxEditingStyle(styleKey);//from w w w . j ava 2s. c o m setCodeFoldingEnabled(true); setAntiAliasingEnabled(true); setWrapStyleWord(true); setAutoIndentEnabled(true); // Add a document listener so that the save button is enabled whenever changes are made. getDocument().addDocumentListener(new DocumentListener() { @Override public void changedUpdate(DocumentEvent e) { onChange(); } @Override public void removeUpdate(DocumentEvent e) { onChange(); } @Override public void insertUpdate(DocumentEvent e) { onChange(); } private void onChange() { if (saveEnabled) { PlatformUI.MIRTH_FRAME.setSaveEnabled(true); } } }); addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (saveEnabled) { boolean isAccelerated = (((e.getModifiers() & Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) > 0) || ((e.getModifiers() & InputEvent.CTRL_MASK) > 0)); if ((e.getKeyCode() == KeyEvent.VK_S) && isAccelerated) { PlatformUI.MIRTH_FRAME.doContextSensitiveSave(); } } } }); undoMenuItem = new CustomMenuItem(this, new UndoAction(), ActionInfo.UNDO); redoMenuItem = new CustomMenuItem(this, new RedoAction(), ActionInfo.REDO); cutMenuItem = new CustomMenuItem(this, new CutAction(this), ActionInfo.CUT); copyMenuItem = new CustomMenuItem(this, new CopyAction(this), ActionInfo.COPY); pasteMenuItem = new CustomMenuItem(this, new PasteAction(), ActionInfo.PASTE); deleteMenuItem = new CustomMenuItem(this, new DeleteAction(), ActionInfo.DELETE); selectAllMenuItem = new CustomMenuItem(this, new SelectAllAction(), ActionInfo.SELECT_ALL); findReplaceMenuItem = new CustomMenuItem(this, new FindReplaceAction(this), ActionInfo.FIND_REPLACE); findNextMenuItem = new CustomMenuItem(this, new FindNextAction(this), ActionInfo.FIND_NEXT); clearMarkedOccurrencesMenuItem = new CustomMenuItem(this, new ClearMarkedOccurrencesAction(this), ActionInfo.CLEAR_MARKED_OCCURRENCES); foldingMenu = new JMenu("Folding"); collapseFoldMenuItem = new CustomMenuItem(this, new CollapseFoldAction(), ActionInfo.FOLD_COLLAPSE); expandFoldMenuItem = new CustomMenuItem(this, new ExpandFoldAction(), ActionInfo.FOLD_EXPAND); collapseAllFoldsMenuItem = new CustomMenuItem(this, new CollapseAllFoldsAction(), ActionInfo.FOLD_COLLAPSE_ALL); collapseAllCommentFoldsMenuItem = new CustomMenuItem(this, new CollapseAllCommentFoldsAction(), ActionInfo.FOLD_COLLAPSE_ALL_COMMENTS); expandAllFoldsMenuItem = new CustomMenuItem(this, new ExpandAllFoldsAction(), ActionInfo.FOLD_EXPAND_ALL); displayMenu = new JMenu("Display"); showTabLinesMenuItem = new CustomJCheckBoxMenuItem(this, new ShowTabLinesAction(this), ActionInfo.DISPLAY_SHOW_TAB_LINES); showWhitespaceMenuItem = new CustomJCheckBoxMenuItem(this, new ShowWhitespaceAction(this), ActionInfo.DISPLAY_SHOW_WHITESPACE); showLineEndingsMenuItem = new CustomJCheckBoxMenuItem(this, new ShowLineEndingsAction(this), ActionInfo.DISPLAY_SHOW_LINE_ENDINGS); wrapLinesMenuItem = new CustomJCheckBoxMenuItem(this, new WrapLinesAction(this), ActionInfo.DISPLAY_WRAP_LINES); macroMenu = new JMenu("Macro"); beginMacroMenuItem = new CustomMenuItem(this, new BeginMacroAction(), ActionInfo.MACRO_BEGIN); endMacroMenuItem = new CustomMenuItem(this, new EndMacroAction(), ActionInfo.MACRO_END); playbackMacroMenuItem = new CustomMenuItem(this, new PlaybackMacroAction(), ActionInfo.MACRO_PLAYBACK); viewUserAPIMenuItem = new CustomMenuItem(this, new ViewUserAPIAction(this), ActionInfo.VIEW_USER_API); // Add actions that wont be in the popup menu getActionMap().put(ActionInfo.DELETE_REST_OF_LINE.getActionMapKey(), new DeleteRestOfLineAction()); getActionMap().put(ActionInfo.DELETE_LINE.getActionMapKey(), new DeleteLineAction()); getActionMap().put(ActionInfo.JOIN_LINE.getActionMapKey(), new JoinLineAction()); getActionMap().put(ActionInfo.GO_TO_MATCHING_BRACKET.getActionMapKey(), new GoToMatchingBracketAction()); getActionMap().put(ActionInfo.TOGGLE_COMMENT.getActionMapKey(), new ToggleCommentAction()); getActionMap().put(ActionInfo.DOCUMENT_START.getActionMapKey(), new DocumentStartAction(false)); getActionMap().put(ActionInfo.DOCUMENT_SELECT_START.getActionMapKey(), new DocumentStartAction(true)); getActionMap().put(ActionInfo.DOCUMENT_END.getActionMapKey(), new DocumentEndAction(false)); getActionMap().put(ActionInfo.DOCUMENT_SELECT_END.getActionMapKey(), new DocumentEndAction(true)); getActionMap().put(ActionInfo.LINE_START.getActionMapKey(), new LineStartAction(false)); getActionMap().put(ActionInfo.LINE_SELECT_START.getActionMapKey(), new LineStartAction(true)); getActionMap().put(ActionInfo.LINE_END.getActionMapKey(), new LineEndAction(false)); getActionMap().put(ActionInfo.LINE_SELECT_END.getActionMapKey(), new LineEndAction(true)); getActionMap().put(ActionInfo.MOVE_LEFT.getActionMapKey(), new MoveLeftAction(false)); getActionMap().put(ActionInfo.MOVE_LEFT_SELECT.getActionMapKey(), new MoveLeftAction(true)); getActionMap().put(ActionInfo.MOVE_LEFT_WORD.getActionMapKey(), new MoveLeftWordAction(false)); getActionMap().put(ActionInfo.MOVE_LEFT_WORD_SELECT.getActionMapKey(), new MoveLeftWordAction(true)); getActionMap().put(ActionInfo.MOVE_RIGHT.getActionMapKey(), new MoveRightAction(false)); getActionMap().put(ActionInfo.MOVE_RIGHT_SELECT.getActionMapKey(), new MoveRightAction(true)); getActionMap().put(ActionInfo.MOVE_RIGHT_WORD.getActionMapKey(), new MoveRightWordAction(false)); getActionMap().put(ActionInfo.MOVE_RIGHT_WORD_SELECT.getActionMapKey(), new MoveRightWordAction(true)); getActionMap().put(ActionInfo.MOVE_UP.getActionMapKey(), new MoveUpAction(false)); getActionMap().put(ActionInfo.MOVE_UP_SELECT.getActionMapKey(), new MoveUpAction(true)); getActionMap().put(ActionInfo.MOVE_UP_SCROLL.getActionMapKey(), new ScrollAction(true)); getActionMap().put(ActionInfo.MOVE_UP_LINE.getActionMapKey(), new MoveLineAction(true)); getActionMap().put(ActionInfo.MOVE_DOWN.getActionMapKey(), new MoveDownAction(false)); getActionMap().put(ActionInfo.MOVE_DOWN_SELECT.getActionMapKey(), new MoveDownAction(true)); getActionMap().put(ActionInfo.MOVE_DOWN_SCROLL.getActionMapKey(), new ScrollAction(false)); getActionMap().put(ActionInfo.MOVE_DOWN_LINE.getActionMapKey(), new MoveLineAction(false)); getActionMap().put(ActionInfo.PAGE_UP.getActionMapKey(), new PageUpAction(false)); getActionMap().put(ActionInfo.PAGE_UP_SELECT.getActionMapKey(), new PageUpAction(true)); getActionMap().put(ActionInfo.PAGE_LEFT_SELECT.getActionMapKey(), new HorizontalPageAction(this, true)); getActionMap().put(ActionInfo.PAGE_DOWN.getActionMapKey(), new PageDownAction(false)); getActionMap().put(ActionInfo.PAGE_DOWN_SELECT.getActionMapKey(), new PageDownAction(true)); getActionMap().put(ActionInfo.PAGE_RIGHT_SELECT.getActionMapKey(), new HorizontalPageAction(this, false)); getActionMap().put(ActionInfo.INSERT_LF_BREAK.getActionMapKey(), new InsertBreakAction("\n")); getActionMap().put(ActionInfo.INSERT_CR_BREAK.getActionMapKey(), new InsertBreakAction("\r")); List<Action> actionList = new ArrayList<Action>(); for (Object key : getActionMap().allKeys()) { actionList.add(getActionMap().get(key)); } actions = actionList.toArray(new Action[actionList.size()]); if (autoCompleteEnabled) { LanguageSupportFactory.get().register(this); // Remove the default auto-completion trigger since we handle that ourselves getInputMap().remove(AutoCompletion.getDefaultTriggerKey()); } }
From source file:com.sec.ose.osi.ui.dialog.setting.JPanProjectAnalysisSetting.java
/** * This method initializes jTextFieldUserHour * /*from ww w. j av a 2 s . c om*/ * @return javax.swing.JTextField */ private JTextField getJTextFieldUserHour() { if (jTextFieldUserHour == null) { jTextFieldUserHour = new JTextField(); jTextFieldUserHour.setPreferredSize(new Dimension(80, 22)); jTextFieldUserHour.addKeyListener(new KeyAdapter() { public void keyTyped(KeyEvent e) { char c = e.getKeyChar(); if (!((Character.isDigit(c) || (c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)))) { getToolkit().beep(); e.consume(); } } }); } return jTextFieldUserHour; }
From source file:de.tbuchloh.kiskis.gui.SecuredElementView.java
private void initCommentField() { _comment = new JTextArea(10, 30); _comment.addKeyListener(new KeyAdapter() { @Override//from w w w . ja v a 2 s . c o m public void keyReleased(final KeyEvent e) { if (!_comment.getText().equals(_element.getComment())) { fireContentChangedEvent(true); } } }); }
From source file:org.openmicroscopy.shoola.agents.util.SelectionWizard.java
/** * Initializes the components composing the display. * //from ww w .jav a 2s .c om * @param userID The id of the user currently logged in. */ private void initComponents() { addLabel = UIUtilities.setTextFont(""); acceptButton = new JButton("Save"); acceptButton.setToolTipText("Save the selection."); cancelButton = new JButton("Cancel"); cancelButton.setToolTipText("Cancel the selection."); resetButton = new JButton("Reset"); resetButton.setToolTipText("Reset the selection."); addNewButton = new JButton("Add"); addNewButton.setEnabled(false); addNewButton.setToolTipText("Add to the selection."); addNewButton.setActionCommand("" + ADD_NEW); addNewButton.addActionListener(this); acceptButton.setActionCommand("" + ACCEPT); acceptButton.addActionListener(this); acceptButton.setEnabled(false); resetButton.setEnabled(false); cancelButton.setActionCommand("" + CANCEL); cancelButton.addActionListener(this); resetButton.setActionCommand("" + RESET); resetButton.addActionListener(this); //Field creation addField = new JTextField(10); addField.setToolTipText("Tag Name"); originalColor = addField.getForeground(); setTextFieldDefault(addField, DEFAULT_TEXT); addField.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { switch (e.getKeyCode()) { case KeyEvent.VK_ENTER: if (addField.isFocusOwner()) { addNewObjects(); } } } }); descriptionField = new JTextField(15); descriptionField.setToolTipText("Tag Description"); setTextFieldDefault(descriptionField, DEFAULT_DESCRIPTION); addField.getDocument().addDocumentListener(this); addField.addFocusListener(this); descriptionField.addFocusListener(this); descriptionField.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { switch (e.getKeyCode()) { case KeyEvent.VK_ENTER: if (descriptionField.isFocusOwner()) { addNewObjects(); } } } }); }
From source file:edu.ku.brc.specify.tasks.subpane.lm.LifeMapperPane.java
/** * Creates the UI./*from w ww . j av a 2 s . co m*/ */ @SuppressWarnings("unchecked") protected void createUI() { currentSize = getCurrentSizeSquare(); searchText = createTextField(25); searchSciNameBtn = createI18NButton("LM_SEARCH"); list = new JList(listModel); imgDisplay = new ImageDisplay(IMG_WIDTH, IMG_HEIGHT, false, true); imgDisplay.setChangeListener(this); wwPanel = new WorldWindPanel(false); wwPanel.setPreferredSize(new Dimension(currentSize, currentSize)); wwPanel.setZoomInMeters(600000.0); imgDisplay.setDoShowText(false); searchMyDataBtn = createI18NButton("LM_SRCH_SP_DATA"); myDataTF = UIHelper.createTextField(); CellConstraints cc = new CellConstraints(); PanelBuilder pb1 = new PanelBuilder(new FormLayout("p,2px,f:p:g,2px,p", "p")); pb1.add(createI18NFormLabel("LM_SRCH_COL"), cc.xy(1, 1)); pb1.add(searchText, cc.xy(3, 1)); pb1.add(searchSciNameBtn, cc.xy(5, 1)); PanelBuilder myPB = new PanelBuilder(new FormLayout("f:p:g,p", "p,2px,p,2px,p")); mySepComp = myPB.addSeparator(getResourceString("LM_MYDATA_TITLE"), cc.xyw(1, 1, 2)); myPB.add(myDataTF, cc.xyw(1, 3, 2)); myPB.add(searchMyDataBtn, cc.xy(2, 5)); PanelBuilder pb2 = new PanelBuilder(new FormLayout("MAX(p;300px),2px,f:p:g", "f:p:g,20px,p")); pb2.add(createScrollPane(list), cc.xy(1, 1)); pb2.add(myPB.getPanel(), cc.xy(1, 3)); PanelBuilder pb3 = new PanelBuilder(new FormLayout("f:p:g,p,f:p:g", "f:p:g,p,4px,p,f:p:g")); pb3.add(createI18NLabel("LM_WRLD_OVRVW", SwingConstants.CENTER), cc.xy(2, 2)); pb3.add(imgDisplay, cc.xy(2, 4)); PanelBuilder pb4 = new PanelBuilder(new FormLayout("f:p:g,p,f:p:g", "f:p:g,p,4px,p,f:p:g")); pb4.add(createI18NLabel("LM_INTRACT_VW", SwingConstants.CENTER), cc.xy(2, 2)); pb4.add(wwPanel, cc.xy(2, 4)); PanelBuilder pb5 = new PanelBuilder(new FormLayout("f:p:g", "f:p:g,p,f:p:g")); pb5.add(pb3.getPanel(), cc.xy(1, 1)); pb5.add(pb4.getPanel(), cc.xy(1, 3)); PanelBuilder pb = new PanelBuilder(new FormLayout("p,8px,f:p:g", "p,8px,f:p:g"), this); pb.add(pb1.getPanel(), cc.xyw(1, 1, 3)); pb.add(pb2.getPanel(), cc.xy(1, 3)); pb.add(pb5.getPanel(), cc.xy(3, 3)); updateMyDataUIState(false); searchText.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { searchSciNameBtn.doClick(); } } }); myDataTF.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { searchMyDataBtn.doClick(); } } }); list.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { if (list.getSelectedIndex() == -1) { wwPanel.reset(); imgDisplay.setImage(blueMarble); } else { SwingWorker<Boolean, Boolean> worker = new SwingWorker<Boolean, Boolean>() { @Override protected Boolean doInBackground() throws Exception { if (doResetWWPanel) { wwPanel.reset(); } doSearchOccur(); return null; } @Override protected void done() { imgDisplay.repaint(); } }; worker.execute(); } } } }); searchMyDataBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { doSearchSpecifyData(myDataTF.getText().trim()); } }); } }); searchSciNameBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doSearchGenusSpecies(); } }); blueMarbleListener = new BufferedImageFetcherIFace() { @Override public void imageFetched(BufferedImage image) { blueMarble = image; imgDisplay.setImage(blueMarble); } @Override public void error() { blueMarbleTries++; if (blueMarbleTries < 5) { blueMarbleRetry(); } } }; blueMarbleURL = BG_URL + String.format("WIDTH=%d&HEIGHT=%d", IMG_WIDTH, IMG_HEIGHT); pointsMapImageListener = new BufferedImageFetcherIFace() { @Override public void imageFetched(final BufferedImage image) { if (renderImage == null) { renderImage = new BufferedImage(IMG_WIDTH, IMG_HEIGHT, BufferedImage.TYPE_INT_ARGB); } Graphics2D g2d = renderImage.createGraphics(); if (g2d != null) { g2d.fillRect(0, 0, IMG_WIDTH, IMG_HEIGHT); if (blueMarble != null) { g2d.drawImage(blueMarble, 0, 0, null); } if (image != null) { g2d.drawImage(image, 0, 0, null); } g2d.dispose(); imgDisplay.setImage(renderImage); } } @Override public void error() { } }; blueMarbleRetry(); }
From source file:org.eobjects.datacleaner.panels.WelcomePanel.java
@Inject protected WelcomePanel(AnalyzerBeansConfiguration configuration, AnalysisJobBuilderWindow analysisJobBuilderWindow, DCGlassPane glassPane, Provider<OptionsDialog> optionsDialogProvider, InjectorBuilder injectorBuilder, OpenAnalysisJobActionListener openAnalysisJobActionListener, DatabaseDriverCatalog databaseDriverCatalog, UserPreferences userPreferences) { super();/*from w ww . j av a 2 s .co m*/ _openAnalysisJobActionListener = openAnalysisJobActionListener; _configuration = configuration; _datastorePanels = new ArrayList<DatastorePanel>(); _datastoreCatalog = (MutableDatastoreCatalog) configuration.getDatastoreCatalog(); _analysisJobBuilderWindow = analysisJobBuilderWindow; _glassPane = glassPane; _optionsDialogProvider = optionsDialogProvider; _injectorBuilder = injectorBuilder; _databaseDriverCatalog = databaseDriverCatalog; _userPreferences = userPreferences; _browseJobsButton = new JButton("Browse jobs", imageManager.getImageIcon(IconUtils.MENU_OPEN, IconUtils.ICON_SIZE_SMALL)); _browseJobsButton.setMargin(new Insets(1, 1, 1, 4)); _browseJobsButton.addActionListener(openAnalysisJobActionListener); // initialize "analyze" button _analyzeButton = new JButton("Build job", imageManager.getImageIcon(IconUtils.MODEL_JOB, IconUtils.ICON_SIZE_SMALL)); _analyzeButton.setMargin(new Insets(1, 1, 1, 1)); _analyzeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { for (DatastorePanel datastorePanel : _datastorePanels) { if (datastorePanel.isSelected()) { Datastore datastore = datastorePanel.getDatastore(); // open the connection here, to make any connection // issues apparent early try (DatastoreConnection datastoreConnection = datastore.openConnection()) { datastoreConnection.getDataContext().getSchemaNames(); _analysisJobBuilderWindow.setDatastore(datastore); } return; } } } }); // initialize search text field _searchDatastoreTextField = WidgetFactory.createTextField("Search/filter datastores"); _searchDatastoreTextField .setBorder(new CompoundBorder(new EmptyBorder(4, 0, 0, 0), WidgetUtils.BORDER_THIN)); _searchDatastoreTextField.setOpaque(false); _searchDatastoreTextField.getDocument().addDocumentListener(new DCDocumentListener() { @Override protected void onChange(DocumentEvent event) { String text = _searchDatastoreTextField.getText(); if (StringUtils.isNullOrEmpty(text)) { // when there is no search query, set all datastores // visible for (DatastorePanel datastorePanel : _datastorePanels) { datastorePanel.setVisible(true); } } else { // do a case insensitive search text = text.trim().toLowerCase(); for (DatastorePanel datastorePanel : _datastorePanels) { String name = datastorePanel.getDatastore().getName().toLowerCase(); datastorePanel.setVisible(name.indexOf(text) != -1); } selectFirstVisibleDatastore(); } } }); _searchDatastoreTextField.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { clickAnalyzeButton(); } else if (e.getKeyCode() == KeyEvent.VK_DOWN) { selectNextVisibleDatastore(); } else if (e.getKeyCode() == KeyEvent.VK_UP) { selectPreviousVisibleDatastore(); } } }); setLayout(new VerticalLayout(4)); add(Box.createVerticalStrut(10)); final DCLabel jobsHeaderLabel = DCLabel.dark("Jobs"); jobsHeaderLabel.setFont(WidgetUtils.FONT_HEADER1); add(jobsHeaderLabel); _jobsListPanel = new DCPanel(); final GridLayout jobsListLayout = new GridLayout(1, MAX_JOB_PANELS); jobsListLayout.setHgap(10); _jobsListPanel.setBorder(new EmptyBorder(10, 10, 4, 0)); _jobsListPanel.setLayout(jobsListLayout); final List<FileObject> recentJobFiles = getRecentJobFiles(); updateJobsListPanel(recentJobFiles); add(_jobsListPanel); _moreRecentJobsButton = new JButton("More", imageManager.getImageIcon(IconUtils.FILE_FOLDER, IconUtils.ICON_SIZE_SMALL)); _moreRecentJobsButton.setMargin(new Insets(1, 1, 1, 4)); if (recentJobFiles.size() <= MAX_JOB_PANELS) { _moreRecentJobsButton.setEnabled(false); } else { _moreRecentJobsButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final JPopupMenu popup = new JPopupMenu(); for (int i = 3; i < recentJobFiles.size(); i++) { final FileObject jobFile = recentJobFiles.get(i); final JMenuItem menuItem = new OpenAnalysisJobMenuItem(jobFile, _openAnalysisJobActionListener); popup.add(menuItem); } popup.show(_moreRecentJobsButton, 0, _moreRecentJobsButton.getHeight()); } }); } final DCPanel jobsButtonPanel = new DCPanel(); jobsButtonPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 0)); jobsButtonPanel.add(_moreRecentJobsButton); jobsButtonPanel.add(_browseJobsButton); add(jobsButtonPanel); add(Box.createVerticalStrut(40)); final DCLabel datastoreHeaderLabel = DCLabel.dark("Datastores"); datastoreHeaderLabel.setFont(WidgetUtils.FONT_HEADER1); add(datastoreHeaderLabel); final DCLabel registerNewDatastoreLabel = DCLabel.dark("Register new:"); registerNewDatastoreLabel.setFont(WidgetUtils.FONT_HEADER2); final DCPanel newDatastorePanel = new DCPanel(); newDatastorePanel.setLayout(new VerticalLayout(4)); newDatastorePanel.setBorder(new EmptyBorder(10, 10, 10, 0)); newDatastorePanel.add(registerNewDatastoreLabel); newDatastorePanel.add(createNewDatastorePanel()); add(newDatastorePanel); _datastoreListPanel = new DCPanel(); _datastoreListPanel.setLayout(new VerticalLayout(4)); _datastoreListPanel.setBorder(new EmptyBorder(10, 10, 4, 0)); add(_datastoreListPanel); updateDatastores(); final DCPanel datastoresButtonPanel = new DCPanel(); datastoresButtonPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); datastoresButtonPanel.setBorder(new EmptyBorder(0, 10, 0, 0)); datastoresButtonPanel.add(_analyzeButton); add(datastoresButtonPanel); }
From source file:edu.ku.brc.specify.plugins.ipadexporter.InstitutionConfigDlg.java
/** * @return/*from w w w.j ava 2 s .co m*/ */ private JPanel createInstitutionPanel() { CellConstraints cc = new CellConstraints(); PanelBuilder pb = new PanelBuilder(new FormLayout("p,2px,f:p:g", "p,2px,p,8px")); DBTableInfo ti = DBTableIdMgr.getInstance().getInfoById(Institution.getClassTableId()); DBFieldInfo fi = ti.getFieldByName("name"); JLabel nmLabel = UIHelper.createFormLabel(fi.getTitle()); instNameLen = fi.getLength(); instTextField = new ValTextField(); int y = 1; pb.add(nmLabel, cc.xy(1, y)); pb.add(instTextField, cc.xy(3, y)); y += 2; KeyAdapter ka = new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { updateOKBtn(); } }; instTextField.addKeyListener(ka); String title = inst != null ? inst.getName() : ""; instTextField.setText(title); return pb.getPanel(); }
From source file:com.rapidminer.gui.new_plotter.gui.dialog.AddParallelLineDialog.java
/** * Setup the GUI./*from ww w. j av a 2 s.c om*/ */ private void setupGUI() { JPanel mainPanel = new JPanel(); this.setContentPane(mainPanel); // start layout mainPanel.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weightx = 1; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 5, 2, 5); horizontalLineRadiobutton = new JRadioButton( I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.horizontal.label")); horizontalLineRadiobutton.setToolTipText( I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.horizontal.tip")); horizontalLineRadiobutton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setHorizontalLineSelected(); } }); horizontalLineRadiobutton.setSelected(true); this.add(horizontalLineRadiobutton, gbc); gbc.gridx = 1; gbc.gridy = 0; gbc.anchor = GridBagConstraints.EAST; verticalLineRadiobutton = new JRadioButton( I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.vertical.label")); verticalLineRadiobutton .setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.vertical.tip")); verticalLineRadiobutton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setVerticalLineSelected(); } }); this.add(verticalLineRadiobutton, gbc); ButtonGroup group = new ButtonGroup(); group.add(horizontalLineRadiobutton); group.add(verticalLineRadiobutton); gbc.gridx = 0; gbc.gridy = 1; gbc.fill = GridBagConstraints.BOTH; gbc.weightx = 1; gbc.gridwidth = 2; gbc.anchor = GridBagConstraints.CENTER; rangeAxisSelectionCombobox = new JComboBox(); rangeAxisSelectionCombobox.setToolTipText( I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.range_axis_combobox.tip")); rangeAxisSelectionCombobox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { updateYFieldValue(); } }); this.add(rangeAxisSelectionCombobox, gbc); gbc.gridx = 0; gbc.gridy = 2; gbc.fill = GridBagConstraints.NONE; gbc.weightx = 1; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 5, 2, 5); JLabel xLabel = new JLabel( I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.width.label")); this.add(xLabel, gbc); gbc.gridx = 1; gbc.gridy = 2; gbc.insets = new Insets(2, 5, 2, 5); gbc.fill = GridBagConstraints.HORIZONTAL; xField = new JTextField(); xField.setText(String.valueOf(x)); xField.setInputVerifier(new InputVerifier() { @Override public boolean verify(JComponent input) { return verifyYInput(input); } }); xField.setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.width.tip")); xField.setEnabled(false); this.add(xField, gbc); gbc.gridx = 0; gbc.gridy = 3; gbc.fill = GridBagConstraints.NONE; JLabel yLabel = new JLabel( I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.height.label")); this.add(yLabel, gbc); gbc.gridx = 1; gbc.gridy = 3; gbc.fill = GridBagConstraints.HORIZONTAL; yField = new JTextField(); yField.setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.height.tip")); yField.setText(String.valueOf(y)); yField.setInputVerifier(new InputVerifier() { @Override public boolean verify(JComponent input) { return verifyXInput(input); } }); this.add(yField, gbc); gbc.gridx = 0; gbc.gridy = 4; gbc.fill = GridBagConstraints.NONE; gbc.insets = new Insets(10, 5, 0, 5); modifyLineButton = new JButton(); modifyLineButton.setToolTipText( I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.modify_line.tip")); modifyLineButton.setIcon(SwingTools.createIcon( "16/" + I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.modify_line.icon"))); modifyLineButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { modifyLine(); } }); this.add(modifyLineButton, gbc); gbc.gridx = 0; gbc.gridy = 5; gbc.gridwidth = 2; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.anchor = GridBagConstraints.CENTER; gbc.insets = new Insets(15, 5, 5, 5); this.add(new JSeparator(), gbc); gbc.gridx = 0; gbc.gridy = 6; gbc.gridwidth = 1; gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 5, 5, 5); okButton = new JButton(I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.ok.label")); okButton.setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.ok.tip")); okButton.setIcon(SwingTools .createIcon("24/" + I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.ok.icon"))); okButton.setMnemonic( I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.ok.mne").toCharArray()[0]); okButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean successful = addSpecifiedLine(); // don't dispose dialog if not successful if (!successful) { return; } AddParallelLineDialog.this.dispose(); } }); okButton.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { okButton.doClick(); } } }); this.add(okButton, gbc); gbc.gridx = 1; gbc.gridy = 6; gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.EAST; cancelButton = new JButton( I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.cancel.label")); cancelButton .setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.cancel.tip")); cancelButton.setIcon(SwingTools.createIcon( "24/" + I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.cancel.icon"))); cancelButton.setMnemonic( I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.cancel.mne").toCharArray()[0]); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // cancel requested, close dialog AddParallelLineDialog.this.dispose(); } }); this.add(cancelButton, gbc); // misc settings this.setMinimumSize(new Dimension(300, 250)); // center dialog this.setLocationRelativeTo(null); this.setTitle(I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.title.label")); this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); this.setModal(true); this.addWindowListener(new WindowAdapter() { @Override public void windowActivated(WindowEvent e) { okButton.requestFocusInWindow(); } }); }