List of usage examples for java.awt.event MouseAdapter MouseAdapter
MouseAdapter
From source file:de.codesourcery.jasm16.ide.ui.views.SourceEditorView.java
private void setupASTInspector() { astInspector = new JFrame("AST"); final MouseAdapter treeMouseListener = new MouseAdapter() { @Override/*from w ww.ja va 2 s. c o m*/ public void mouseMoved(MouseEvent e) { String text = null; TreePath path = astTree.getClosestPathForLocation(e.getX(), e.getY()); if (path != null) { ASTNode node = (ASTNode) path.getLastPathComponent(); if (node instanceof InstructionNode) { // TODO: debug code, remove when done text = null; } try { text = getCurrentCompilationUnit().getSource(node.getTextRegion()); } catch (Exception ex) { text = "Node " + node.getClass().getSimpleName() + " has invalid text region " + node.getTextRegion(); } text = "<HTML>" + text.replace("\n", "<BR>") + "</HTML>"; } if (!ObjectUtils.equals(astTree.getToolTipText(), text)) { astTree.setToolTipText(text); } } }; astTree.addMouseMotionListener(treeMouseListener); astTree.setCellRenderer(new ASTTreeCellRenderer()); final JScrollPane pane = new JScrollPane(astTree); setColors(pane); pane.setPreferredSize(new Dimension(400, 600)); GridBagConstraints cnstrs = constraints(0, 0, true, false, GridBagConstraints.REMAINDER); cnstrs.weighty = 0.9; panel.add(pane, cnstrs); // add symbol table symbolTable.setFillsViewportHeight(true); MouseAdapter mouseListener = new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { int viewRow = symbolTable.rowAtPoint(e.getPoint()); if (viewRow != -1) { final int modelRow = symbolTable.convertRowIndexToModel(viewRow); final ISymbol symbol = symbolTableModel.getSymbolForRow(modelRow); final int caretPosition = symbol.getLocation().getStartingOffset(); IEditorView editor = null; if (DefaultResourceMatcher.INSTANCE.isSame(symbol.getCompilationUnit().getResource(), getSourceFromMemory())) { editor = SourceEditorView.this; } else if (getViewContainer() instanceof EditorContainer) { final EditorContainer parent = (EditorContainer) getViewContainer(); try { editor = parent.openResource(workspace, getCurrentProject(), symbol.getCompilationUnit().getResource(), caretPosition); } catch (IOException e1) { LOG.error("mouseClicked(): Failed top open " + symbol.getCompilationUnit().getResource(), e1); return; } } if (editor instanceof SourceCodeView) { ((SourceCodeView) editor).moveCursorTo(caretPosition, true); } } } } }; symbolTable.addMouseListener(mouseListener); final JScrollPane tablePane = new JScrollPane(symbolTable); setColors(tablePane); tablePane.setPreferredSize(new Dimension(400, 200)); cnstrs = constraints(0, 1, true, true, GridBagConstraints.REMAINDER); cnstrs.weighty = 0.1; panel.add(pane, cnstrs); final JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, pane, tablePane); setColors(split); // setup content pane astInspector.getContentPane().add(split); setColors(astInspector.getContentPane()); astInspector.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); astInspector.pack(); }
From source file:edu.ku.brc.af.tasks.subpane.StatsPane.java
/** * Loads all the panels./*from w ww .j av a 2s . c om*/ */ protected void init() { JComponent parentComp = upperDisplayComp != null ? upperDisplayComp : this; for (Component c : comps) { parentComp.remove(c); } comps.clear(); if (centerPanel != null) { remove(centerPanel); } Element rootElement = null; try { rootElement = AppContextMgr.getInstance().getResourceAsDOM(resourceName); if (rootElement == null) { throw new RuntimeException("Couldn't find resource [" + resourceName + "]"); //$NON-NLS-1$ //$NON-NLS-2$ } // count up rows and column StringBuilder rowsDef = new StringBuilder(128); boolean hasResBundle = false; Element panelEl = (Element) rootElement.selectObject("/panel"); String resBundleName = XMLHelper.getAttr(panelEl, "resource", null); if (StringUtils.isNotEmpty(resBundleName)) { hasResBundle = true; UIRegistry.loadAndPushResourceBundle(resBundleName); } List<?> rows = rootElement.selectNodes("/panel/row"); //$NON-NLS-1$ int maxCols = 0; for (Object obj : rows) { Element rowElement = (Element) obj; List<?> boxes = rowElement.selectNodes("box"); //$NON-NLS-1$ maxCols = Math.max(maxCols, boxes.size()); if (rowsDef.length() > 0) { rowsDef.append(",15dlu,"); //$NON-NLS-1$ } rowsDef.append("top:p"); //$NON-NLS-1$ } int preferredWidth = PREFERREDWIDTH; int spacing = SPACING; String colDefs = createDuplicateJGoodiesDef("f:min(" + preferredWidth + "px;p)", spacing + "px", //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ maxCols); FormLayout formLayout = new FormLayout(colDefs, rowsDef.toString()); PanelBuilder builder = new PanelBuilder(formLayout); CellConstraints cc = new CellConstraints(); int y = 1; for (Object obj : rows) { Element rowElement = (Element) obj; int x = 1; List<?> boxes = rowElement.selectNodes("box"); //$NON-NLS-1$ for (Object bo : boxes) { Element boxElement = (Element) bo; String type = getAttr(boxElement, "type", "box"); //$NON-NLS-1$ //$NON-NLS-2$ int colSpan = getAttr(boxElement, "colspan", 1); //$NON-NLS-1$ Component comp = null; if (type.equalsIgnoreCase("bar chart")) //$NON-NLS-1$ { String statName = getAttr(boxElement, "name", null); //$NON-NLS-1$ if (isNotEmpty(statName)) { BarChartPanel bcp = (BarChartPanel) StatsMgr.createStatPane(statName); int width = colSpan > 1 ? ((maxCols * preferredWidth) + ((maxCols - 1) * spacing)) : preferredWidth; // We start by assuming the chart will be square which is why we use // preferredWidth as the height, and then we calculate the new width bcp.setPreferredChartSize(width, preferredWidth); comp = bcp; //comp.setSize(new Dimension(preferredWidth, preferredWidth)); //comp.setPreferredSize(new Dimension(preferredWidth, preferredWidth)); //comp.invalidate(); //comp.doLayout(); //System.out.println(comp.getSize()); validate(); doLayout(); repaint(); } } else // The default is "Box" { comp = processBox(boxElement, hasResBundle); } if (comp != null) { comps.add(comp); if (colSpan == 1) { builder.add(comp, cc.xy(x, y)); } else { builder.add(comp, cc.xywh(x, y, colSpan, 1)); } x += 2; } } // boxes y += 2; } if (hasResBundle) { UIRegistry.popResourceBundle(); } setBackground(bgColor); JPanel statPanel = builder.getPanel(); statPanel.setBackground(Color.WHITE); boolean hasUpper = upperDisplayComp != null; builder = new PanelBuilder(new FormLayout("C:P:G", hasUpper ? "50px,p,20px,p" : "p")); //$NON-NLS-1$ //$NON-NLS-2$ if (hasUpper) { y = 2; builder.add(upperDisplayComp, cc.xy(1, y)); y += 2; } else { y = 1; } builder.add(statPanel, cc.xy(1, y)); centerPanel = builder.getPanel(); centerPanel.setBackground(Color.WHITE); //For Tiling if (isTiled()) { centerPanel.setOpaque(false); setOpaque(false); statPanel.setOpaque(false); } centerPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); add(centerPanel, BorderLayout.CENTER); if (updateBtn == null) { PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g,p,4px", "4px,p,4px")); //pb.setOpaque(false); updateBtn = new FadeBtn(UIRegistry.getResourceString("STS_UPDATE")); pb.add(updateBtn, cc.xy(2, 2)); pb.getPanel().setBackground(bgColor); add(pb.getPanel(), BorderLayout.SOUTH); updateBtn.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { init(); } }); } centerPanel.validate(); validate(); doLayout(); } catch (Exception ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(StatsPane.class, ex); log.error(ex); ex.printStackTrace(); } }
From source file:net.sf.jabref.groups.GroupSelector.java
private void definePopup() { // These key bindings are just to have the shortcuts displayed // in the popup menu. The actual keystroke processing is in // BasePanel (entryTable.addKeyListener(...)). groupsContextMenu.add(editGroupPopupAction); groupsContextMenu.add(addGroupPopupAction); groupsContextMenu.add(addSubgroupPopupAction); groupsContextMenu.addSeparator();//from w w w . ja v a 2s .c o m groupsContextMenu.add(removeGroupAndSubgroupsPopupAction); groupsContextMenu.add(removeGroupKeepSubgroupsPopupAction); groupsContextMenu.add(removeSubgroupsPopupAction); groupsContextMenu.addSeparator(); groupsContextMenu.add(expandSubtreePopupAction); groupsContextMenu.add(collapseSubtreePopupAction); groupsContextMenu.addSeparator(); groupsContextMenu.add(moveSubmenu); sortSubmenu.add(sortDirectSubgroupsPopupAction); sortSubmenu.add(sortAllSubgroupsPopupAction); groupsContextMenu.add(sortSubmenu); moveSubmenu.add(moveNodeUpPopupAction); moveSubmenu.add(moveNodeDownPopupAction); moveSubmenu.add(moveNodeLeftPopupAction); moveSubmenu.add(moveNodeRightPopupAction); groupsContextMenu.addSeparator(); groupsContextMenu.add(addToGroup); groupsContextMenu.add(moveToGroup); groupsContextMenu.add(removeFromGroup); groupsTree.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { showPopup(e); } } @Override public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) { showPopup(e); } } @Override public void mouseClicked(MouseEvent e) { TreePath path = groupsTree.getPathForLocation(e.getPoint().x, e.getPoint().y); if (path == null) { return; } GroupTreeNode node = (GroupTreeNode) path.getLastPathComponent(); // the root node is "AllEntries" and cannot be edited if (node.isRoot()) { return; } if ((e.getClickCount() == 2) && (e.getButton() == MouseEvent.BUTTON1)) { // edit editGroupAction.actionPerformed(null); // dummy event } else if ((e.getClickCount() == 1) && (e.getButton() == MouseEvent.BUTTON1)) { annotationEvent(node); } } }); // be sure to remove a possible border highlight when the popup menu // disappears groupsContextMenu.addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { // nothing to do } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { groupsTree.setHighlightBorderCell(null); } @Override public void popupMenuCanceled(PopupMenuEvent e) { groupsTree.setHighlightBorderCell(null); } }); }
From source file:com.jwmsolutions.timeCheck.gui.TodoForm.java
private JLabel getJlblLink() { if (jlblLink == null) { jlblLink = new JLabel(); jlblLink.setText("User Feedback"); jlblLink.setForeground(Color.blue); jlblLink.addMouseListener(new MouseAdapter() { public void mouseExited(MouseEvent evt) { jlblLinkMouseExited(evt); }//from ww w . j a v a2 s. co m public void mouseEntered(MouseEvent evt) { jlblLinkMouseEntered(evt); } public void mouseClicked(MouseEvent evt) { jlblLinkMouseClicked(evt); } }); } return jlblLink; }
From source file:me.paddingdun.gen.code.gui.view.dbtable.TableView.java
private void afterShow(java.awt.event.ComponentEvent evt) {// GEN-FIRST:event_afterShow // table.addPropertyChangeListener("tableCellEditor", new // PropertyChangeListener() { ///* w w w . j ava2 s . co m*/ // @Override // public void propertyChange(PropertyChangeEvent evt) { // System.out.println("1[" +evt.getPropertyName()); // System.out.println("2[" +evt.getSource()); // System.out.println("3[" +(evt.getOldValue())); // System.out.println("4[" +evt.getNewValue()); // System.out.println("5[" +table.getCellEditor()); // } // }); // table.getCellEditor().addCellEditorListener(new CellEditorListener() // { // // @Override // public void editingStopped(ChangeEvent e) { // System.out.println("stop"); // } // // @Override // public void editingCanceled(ChangeEvent e) { // System.out.println("cancel"); // } // }); tableColumnTable.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { changeTableRow(); } }); // 38 up; // 40 down; // 37 left; // 39 right; // 10 enter; tableColumnTable.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { int keyCode = e.getKeyCode(); if (keyCode == 10 || keyCode == 38 || keyCode == 40) changeTableRow(); } }); listColumnTable.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { changeListTableRow(); } }); // 38 up; // 40 down; // 37 left; // 39 right; // 10 enter; listColumnTable.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { int keyCode = e.getKeyCode(); if (keyCode == 10 || keyCode == 38 || keyCode == 40) changeListTableRow(); } }); p.setDividerLocation(0.5); EventQueue.invokeLater(new Runnable() { public void run() { pt.setDividerLocation(0.5); EventQueue.invokeLater(new Runnable() { public void run() { pb.setDividerLocation(0.5); } }); } }); }
From source file:com.ibm.soatf.gui.SOATestingFrameworkGUI.java
/** * initialization stuff like models, listeners, ... for GUI components and configuration initialization *///from www . j a v a2 s . c o m private void setupGUIComponents() { //called asynchronuously so that the GUI shows up much sooner while the initialization is going on in background //why is it in the AWT invokeLater? because AsyncWorker tasks have to be called from within the EventDispatch thread java.awt.EventQueue.invokeLater(new Runnable() { @Override public void run() { AsyncWorker.post(new AdditionalInitAsyncTask()); } }); //table with operation results jtResults.setModel(jtResultsModel); jtResults.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() > 1) { displayResultDetails(); } } }); //middle panel, with the interface details (tree) jtInterfaceDetails.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); }
From source file:JXTransformer.java
private JPanel createDemoPanel() { JPanel buttonPanel = new JPanel(new GridLayout(3, 2)); TitledBorder titledBorder = BorderFactory.createTitledBorder("Try three sliders below !"); Font titleFont = titledBorder.getTitleFont(); titledBorder.setTitleFont(titleFont.deriveFont(titleFont.getSize2D() + 10)); titledBorder.setTitleJustification(TitledBorder.CENTER); buttonPanel.setBorder(titledBorder); JButton b = new JButton("JButton"); b.setPreferredSize(new Dimension(100, 50)); buttonPanel.add(createTransformer(b)); Vector<String> v = new Vector<String>(); v.add("One"); v.add("Two"); v.add("Three"); JList list = new JList(v); buttonPanel.add(createTransformer(list)); buttonPanel.add(createTransformer(new JCheckBox("JCheckBox"))); JSlider slider = new JSlider(0, 100); slider.setLabelTable(slider.createStandardLabels(25, 0)); slider.setPaintLabels(true);//w ww . j ava2 s . co m slider.setPaintTicks(true); slider.setMajorTickSpacing(10); buttonPanel.add(createTransformer(slider)); buttonPanel.add(createTransformer(new JRadioButton("JRadioButton"))); final JLabel label = new JLabel("JLabel"); label.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { Font font = label.getFont(); label.setFont(font.deriveFont(font.getSize2D() + 10)); } public void mouseExited(MouseEvent e) { Font font = label.getFont(); label.setFont(font.deriveFont(font.getSize2D() - 10)); } }); buttonPanel.add(createTransformer(label)); return buttonPanel; }
From source file:com.mirth.connect.connectors.http.HttpListener.java
private void initComponentsManual() { staticResourcesTable.setModel(new RefreshTableModel(StaticResourcesColumn.getNames(), 0) { @Override/*from w w w .j av a2 s .co m*/ public boolean isCellEditable(int rowIndex, int columnIndex) { return true; } }); staticResourcesTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); staticResourcesTable.setRowHeight(UIConstants.ROW_HEIGHT); staticResourcesTable.setFocusable(true); staticResourcesTable.setSortable(false); staticResourcesTable.setOpaque(true); staticResourcesTable.setDragEnabled(false); staticResourcesTable.getTableHeader().setReorderingAllowed(false); staticResourcesTable.setShowGrid(true, true); staticResourcesTable.setAutoCreateColumnsFromModel(false); staticResourcesTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); staticResourcesTable.setRowSelectionAllowed(true); staticResourcesTable.setCustomEditorControls(true); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { staticResourcesTable.setHighlighters(HighlighterFactory .createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR)); } class ContextPathCellEditor extends TextFieldCellEditor { public ContextPathCellEditor() { getTextField().setDocument(new MirthFieldConstraints("^\\S*$")); } @Override protected boolean valueChanged(String value) { if (StringUtils.isEmpty(value) || value.equals("/")) { return false; } if (value.equals(getOriginalValue())) { return false; } for (int i = 0; i < staticResourcesTable.getRowCount(); i++) { if (value.equals(fixContentPath((String) staticResourcesTable.getValueAt(i, StaticResourcesColumn.CONTEXT_PATH.getIndex())))) { return false; } } parent.setSaveEnabled(true); return true; } @Override public Object getCellEditorValue() { String value = fixContentPath((String) super.getCellEditorValue()); String baseContextPath = getBaseContextPath(); if (value.equals(baseContextPath)) { return null; } else { return fixContentPath(StringUtils.removeStartIgnoreCase(value, baseContextPath + "/")); } } @Override public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { String resourceContextPath = fixContentPath((String) value); setOriginalValue(resourceContextPath); getTextField().setText(getBaseContextPath() + resourceContextPath); return getTextField(); } } ; staticResourcesTable.getColumnExt(StaticResourcesColumn.CONTEXT_PATH.getIndex()) .setCellEditor(new ContextPathCellEditor()); staticResourcesTable.getColumnExt(StaticResourcesColumn.CONTEXT_PATH.getIndex()) .setCellRenderer(new DefaultTableCellRenderer() { @Override protected void setValue(Object value) { super.setValue(getBaseContextPath() + fixContentPath((String) value)); } }); class ResourceTypeCellEditor extends MirthComboBoxTableCellEditor implements ActionListener { private Object originalValue; public ResourceTypeCellEditor(JTable table, Object[] items, int clickCount, boolean focusable) { super(table, items, clickCount, focusable, null); for (ActionListener actionListener : comboBox.getActionListeners()) { comboBox.removeActionListener(actionListener); } comboBox.addActionListener(this); } @Override public boolean stopCellEditing() { if (ObjectUtils.equals(getCellEditorValue(), originalValue)) { cancelCellEditing(); } else { parent.setSaveEnabled(true); } return super.stopCellEditing(); } @Override public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { originalValue = value; return super.getTableCellEditorComponent(table, value, isSelected, row, column); } @Override public void actionPerformed(ActionEvent evt) { ((AbstractTableModel) staticResourcesTable.getModel()).fireTableCellUpdated( staticResourcesTable.getSelectedRow(), StaticResourcesColumn.VALUE.getIndex()); stopCellEditing(); fireEditingStopped(); } } String[] resourceTypes = ResourceType.stringValues(); staticResourcesTable.getColumnExt(StaticResourcesColumn.RESOURCE_TYPE.getIndex()).setMinWidth(100); staticResourcesTable.getColumnExt(StaticResourcesColumn.RESOURCE_TYPE.getIndex()).setMaxWidth(100); staticResourcesTable.getColumnExt(StaticResourcesColumn.RESOURCE_TYPE.getIndex()) .setCellEditor(new ResourceTypeCellEditor(staticResourcesTable, resourceTypes, 1, false)); staticResourcesTable.getColumnExt(StaticResourcesColumn.RESOURCE_TYPE.getIndex()) .setCellRenderer(new MirthComboBoxTableCellRenderer(resourceTypes)); class ValueCellEditor extends AbstractCellEditor implements TableCellEditor { private JPanel panel; private JLabel label; private JTextField textField; private String text; private String originalValue; public ValueCellEditor() { panel = new JPanel(new MigLayout("insets 0 1 0 0, novisualpadding, hidemode 3")); panel.setBackground(UIConstants.BACKGROUND_COLOR); label = new JLabel(); label.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent evt) { new ValueDialog(); stopCellEditing(); } }); panel.add(label, "grow, pushx, h 19!"); textField = new JTextField(); panel.add(textField, "grow, pushx, h 19!"); } @Override public boolean isCellEditable(EventObject evt) { if (evt == null) { return false; } if (evt instanceof MouseEvent) { return ((MouseEvent) evt).getClickCount() >= 2; } return true; } @Override public Object getCellEditorValue() { if (label.isVisible()) { return text; } else { return textField.getText(); } } @Override public boolean stopCellEditing() { if (ObjectUtils.equals(getCellEditorValue(), originalValue)) { cancelCellEditing(); } else { parent.setSaveEnabled(true); } return super.stopCellEditing(); } @Override public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { boolean custom = table.getValueAt(row, StaticResourcesColumn.RESOURCE_TYPE.getIndex()) .equals(ResourceType.CUSTOM.toString()); label.setVisible(custom); textField.setVisible(!custom); panel.setBackground(table.getSelectionBackground()); label.setBackground(panel.getBackground()); label.setMaximumSize(new Dimension(table.getColumnModel().getColumn(column).getWidth(), 19)); String text = (String) value; this.text = text; originalValue = text; label.setText(text); textField.setText(text); return panel; } class ValueDialog extends MirthDialog { public ValueDialog() { super(parent, true); setTitle("Custom Value"); setPreferredSize(new Dimension(600, 500)); setLayout(new MigLayout("insets 12, novisualpadding, hidemode 3, fill", "", "[grow]7[]")); setBackground(UIConstants.BACKGROUND_COLOR); getContentPane().setBackground(getBackground()); final MirthSyntaxTextArea textArea = new MirthSyntaxTextArea(); textArea.setSaveEnabled(false); textArea.setText(text); textArea.setBorder(BorderFactory.createEtchedBorder()); add(textArea, "grow"); add(new JSeparator(), "newline, grow"); JPanel buttonPanel = new JPanel(new MigLayout("insets 0, novisualpadding, hidemode 3")); buttonPanel.setBackground(getBackground()); JButton openFileButton = new JButton("Open File..."); openFileButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { String content = parent.browseForFileString(null); if (content != null) { textArea.setText(content); } } }); buttonPanel.add(openFileButton); JButton okButton = new JButton("OK"); okButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { text = textArea.getText(); label.setText(text); textField.setText(text); staticResourcesTable.getModel().setValueAt(text, staticResourcesTable.getSelectedRow(), StaticResourcesColumn.VALUE.getIndex()); parent.setSaveEnabled(true); dispose(); } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { dispose(); } }); buttonPanel.add(cancelButton); add(buttonPanel, "newline, right"); pack(); setLocationRelativeTo(parent); setVisible(true); } } } ; staticResourcesTable.getColumnExt(StaticResourcesColumn.VALUE.getIndex()) .setCellEditor(new ValueCellEditor()); staticResourcesTable.getColumnExt(StaticResourcesColumn.CONTENT_TYPE.getIndex()).setMinWidth(100); staticResourcesTable.getColumnExt(StaticResourcesColumn.CONTENT_TYPE.getIndex()).setMaxWidth(150); staticResourcesTable.getColumnExt(StaticResourcesColumn.CONTENT_TYPE.getIndex()) .setCellEditor(new TextFieldCellEditor() { @Override protected boolean valueChanged(String value) { if (value.equals(getOriginalValue())) { return false; } parent.setSaveEnabled(true); return true; } }); staticResourcesTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent evt) { if (getSelectedRow(staticResourcesTable) != -1) { staticResourcesLastIndex = getSelectedRow(staticResourcesTable); staticResourcesDeleteButton.setEnabled(true); } else { staticResourcesDeleteButton.setEnabled(false); } } }); contextPathField.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent evt) { changedUpdate(evt); } @Override public void removeUpdate(DocumentEvent evt) { changedUpdate(evt); } @Override public void changedUpdate(DocumentEvent evt) { ((AbstractTableModel) staticResourcesTable.getModel()).fireTableDataChanged(); } }); staticResourcesDeleteButton.setEnabled(false); }
From source file:gov.nih.nci.nbia.StandaloneDMV3.java
/** * Create the panel./*from w w w . j ava 2 s .c om*/ */ private JPanel createloginPanelV2() { JPanel contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(36, 36, 36, 36)); contentPane.setLayout(null); JPanel loginUserPanel = new JPanel(); loginUserPanel.setBounds(40, 91, 825, 306); contentPane.add(loginUserPanel); loginUserPanel .setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, new Color(153, 180, 209), null), "", TitledBorder.CENTER, TitledBorder.TOP, null, new Color(0, 120, 215))); loginUserPanel.setLayout(null); JLabel lblNewLabel_1 = new JLabel("User Name"); lblNewLabel_1.setBounds(70, 80, 118, 36); loginUserPanel.add(lblNewLabel_1); JButton submitBtn = new JButton(SubmitBtnLbl); submitBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { userId = userNameFld.getText(); password = passwdFld.getText(); if ((userId.length() < 1) || (password.length() < 1)) { setStatus(statusLbl, "Please enter a valid user name and password.", Color.red); } else { setStatus(statusLbl, "Checking your access permission...", Color.blue); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { submitRequest(userId, password); } }); } } }); submitBtn.setBounds(606, 238, 140, 36); loginUserPanel.add(submitBtn); userNameFld = new JTextField(); userNameFld.setBounds(200, 80, 333, 36); loginUserPanel.add(userNameFld); userNameFld.setColumns(10); JLabel lblPassword = new JLabel("Password"); lblPassword.setBounds(70, 156, 118, 36); loginUserPanel.add(lblPassword); passwdFld = new JPasswordField(); passwdFld.setBounds(200, 156, 333, 36); loginUserPanel.add(passwdFld); statusLbl = new JLabel(""); statusLbl.setBounds(70, 226, 524, 36); statusLbl.setFont(new Font("SansSerif", Font.PLAIN, 13)); statusLbl.setVerticalAlignment(SwingConstants.BOTTOM); loginUserPanel.add(statusLbl); JLabel versionLabel = new JLabel("Release " + DownloaderProperties.getAppVersion() + " Build \"" + DownloaderProperties.getBuildTime() + "\""); versionLabel.setHorizontalAlignment(SwingConstants.CENTER); versionLabel.setForeground(new Color(70, 130, 180)); versionLabel.setBounds(318, 427, 266, 20); contentPane.add(versionLabel); JLabel infoLbl = new JLabel( "This download contains restricted data. Log in or contact the help desk for access."); infoLbl.setForeground(new Color(105, 105, 105)); infoLbl.setFont(new Font("SansSerif", Font.BOLD, 13)); infoLbl.setBounds(40, 34, 796, 42); contentPane.add(infoLbl); JLabel helpDeskLbl; helpDeskLbl = new JLabel(); ImageIcon image = new ImageIcon(this.getClass().getClassLoader().getResource("info.png")); helpDeskLbl = new JLabel(image); helpDeskLbl.setToolTipText("Click to get phone number/email address of the Help Desk."); helpDeskLbl.setBounds(826, 20, 36, 36); contentPane.add(helpDeskLbl); helpDeskLbl.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { System.out.println("mouse clicked"); //BrowserLauncher.openUrl(DownloaderProperties.getHelpDeskUrl()); BrowserLauncher.openUrlForHelpDesk(); } }); userNameFld.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { passwdFld.requestFocus(); } }); userNameFld.addFocusListener(new FocusListener() { @Override public void focusGained(FocusEvent e) { statusLbl.setText(""); } @Override public void focusLost(FocusEvent e) { } }); passwdFld.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { userId = userNameFld.getText(); password = passwdFld.getText(); if ((userId.length() < 1) || (password.length() < 1)) { setStatus(statusLbl, "Please enter a valid user name and password.", Color.red); } else { setStatus(statusLbl, "Checking your access permission...", Color.blue); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { submitRequest(userId, password); } }); } } }); passwdFld.addFocusListener(new FocusListener() { @Override public void focusGained(FocusEvent e) { statusLbl.setText(""); } @Override public void focusLost(FocusEvent e) { } }); return contentPane; }