List of usage examples for javax.swing.event DocumentListener DocumentListener
DocumentListener
From source file:com.konifar.material_icon_generator.MaterialDesignIconGenerateDialog.java
private void initFileName() { textFieldFileName.getDocument().addDocumentListener(new DocumentListener() { @Override/*from w w w.j a v a 2 s. c o m*/ public void insertUpdate(DocumentEvent event) { setText(); } @Override public void removeUpdate(DocumentEvent event) { setText(); } @Override public void changedUpdate(DocumentEvent event) { setText(); } private void setText() { if (model != null) model.setFileName(textFieldFileName.getText()); } }); }
From source file:com.microsoft.alm.plugin.idea.ui.checkout.CheckoutForm.java
private void ensureInitialized() { if (!initialized) { // Ensure that the commands are set up correctly repositoryFilter.setActionCommand(CMD_REPO_FILTER_CHANGED); refreshButton.setActionCommand(CMD_REFRESH); // Fix HiDPI scaling for table SwingHelper.scaleTableRowHeight(repositoryTable); // Fix tabbing in table SwingHelper.fixTabKeys(repositoryTable); // Set help text and popup text helpPanel.addPopupCommand(TfPluginBundle.message(TfPluginBundle.KEY_VSO_LOOKUP_HELP_ENTER_URL), CMD_GOTO_TFS);/*from w ww . j a v a 2s . co m*/ helpPanel.addPopupCommand(TfPluginBundle.message(TfPluginBundle.KEY_VSO_LOOKUP_HELP_VIEW_ACCOUNTS), CMD_GOTO_SPS_PROFILE); helpPanel.setVisible(false); // Don't show this help panel until we know if it's vs.com // Set hint text repositoryFilter.setUI( new HintTextFieldUI(TfPluginBundle.message(TfPluginBundle.KEY_CHECKOUT_DIALOG_FILTER_HINT))); // Setup folder browser parentDirectory.getInsets().right = 0; parentDirectory.addBrowseFolderListener( TfPluginBundle.message(TfPluginBundle.KEY_CHECKOUT_DIALOG_PARENT_FOLDER_DIALOG_TITLE), null, null, new FileChooserDescriptor(false, true, false, false, false, false)); // Align the busy spinner and the refresh button with the height of the text box refreshButton.putClientProperty("JButton.buttonType", "square"); // This is a magical property that tells IntelliJ to draw the button like an image button final int textBoxHeight = (int) repositoryFilter.getPreferredSize().getHeight(); final Dimension size = new Dimension(textBoxHeight, textBoxHeight); refreshButton.setMinimumSize(size); refreshButton.setPreferredSize(size); busySpinner.setMinimumSize(size); busySpinner.setPreferredSize(size); // Setup document events for filter // Using a timer so that we don't respond to every character typed // The timer is created in the create components method repositoryFilter.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(final DocumentEvent e) { onFilterChanged(); } @Override public void removeUpdate(final DocumentEvent e) { onFilterChanged(); } @Override public void changedUpdate(final DocumentEvent e) { onFilterChanged(); } private void onFilterChanged() { if (timer.isRunning()) { timer.restart(); } else { timer.start(); } } }); repositoryTableScrollPane.setMinimumSize(new Dimension(JBUI.scale(200), JBUI.scale(70))); initialized = true; } }
From source file:gtu._work.ui.TextScanUI.java
private void initGUI() { try {/*from w ww. jav a 2 s. com*/ BorderLayout thisLayout = new BorderLayout(); getContentPane().setLayout(thisLayout); this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); this.addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent evt) { thisComponentResized(evt); } }); this.addWindowStateListener(new WindowStateListener() { public void windowStateChanged(WindowEvent evt) { System.out.println("this.windowStateChanged, event=" + evt); // TODO add your code for this.windowStateChanged } }); this.addWindowListener(new WindowAdapter() { public void windowIconified(WindowEvent evt) { System.out.println("this.windowIconified, event=" + evt); // TODO add your code for this.windowIconified } }); this.setTitle(TITLE); { jPanel1 = new JPanel(); getContentPane().add(jPanel1, BorderLayout.NORTH); GroupLayout jPanel1Layout = new GroupLayout((JComponent) jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1.setPreferredSize(new java.awt.Dimension(521, 89)); jPanel1.setBounds(0, 0, 521, 89); { jButton1 = new JButton(); jButton1.setText("File"); jButton1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jButton1ActionPerformed(evt); } }); } { jButton2 = new JButton(); jButton2.setText("Clipboard"); jButton2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jButton2ActionPerformed(evt); } }); } { contentFilter = new JTextField(); contentFilter.getDocument().addDocumentListener(new DocumentListener() { public void insertUpdate(DocumentEvent paramDocumentEvent) { jTextField2filterAgain(); } public void removeUpdate(DocumentEvent paramDocumentEvent) { jTextField2filterAgain(); } public void changedUpdate(DocumentEvent paramDocumentEvent) { jTextField2filterAgain(); } }); } { fileFilter = new JTextField(); fileFilter.getDocument().addDocumentListener(new DocumentListener() { public void insertUpdate(DocumentEvent paramDocumentEvent) { jTextField1DocumentListener(paramDocumentEvent); } public void removeUpdate(DocumentEvent paramDocumentEvent) { jTextField1DocumentListener(paramDocumentEvent); } public void changedUpdate(DocumentEvent paramDocumentEvent) { jTextField1DocumentListener(paramDocumentEvent); } }); } { totalLabel = new JLabel(); } { matchLabel = new JLabel(); } { jLabel4 = new JLabel(); jLabel4.setText("Match : "); } { jLabel2 = new JLabel(); jLabel2.setText("Total : "); } { ComboBoxModel jComboBox1Model = new DefaultComboBoxModel(new String[] { "All", "Match" }); contextFilter = new JComboBox(); contextFilter.setModel(jComboBox1Model); contextFilter.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jTextField2filterAgain(); } }); } { ComboBoxModel jComboBox1Model = new DefaultComboBoxModel(new String[] { "Regex", "find" }); fileChk = new JComboBox(); fileChk.setModel(jComboBox1Model); fileChk.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { fileChkActionPerformed(evt); } }); } { jScrollPane2 = new JScrollPane(); { ListModel groupListModel = new DefaultComboBoxModel(); groupList = new JList(); jScrollPane2.setViewportView(groupList); groupList.setModel(groupListModel); groupList.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { groupListKeyPressed(evt); } }); } } jPanel1Layout.setVerticalGroup(jPanel1Layout.createSequentialGroup().addContainerGap(16, 16) .addGroup(jPanel1Layout.createParallelGroup() .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(jButton1, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(fileFilter, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE) .addComponent(fileChk, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel1Layout.createParallelGroup().addGroup(jPanel1Layout .createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(jButton2, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(contentFilter, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(jLabel4, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE) .addComponent(contextFilter, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addComponent(matchLabel, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE))) .addGroup(jPanel1Layout.createParallelGroup() .addComponent(totalLabel, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE) .addComponent(jScrollPane2, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 61, GroupLayout.PREFERRED_SIZE))) .addContainerGap(12, 12)); jPanel1Layout.setHorizontalGroup(jPanel1Layout.createSequentialGroup().addContainerGap(12, 12) .addGroup(jPanel1Layout.createParallelGroup() .addComponent(contextFilter, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 87, GroupLayout.PREFERRED_SIZE) .addComponent(fileChk, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 87, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup() .addComponent(jLabel4, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 45, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup() .addComponent(matchLabel, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 67, GroupLayout.PREFERRED_SIZE) .addComponent(totalLabel, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 67, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup() .addComponent(contentFilter, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 266, GroupLayout.PREFERRED_SIZE) .addComponent(fileFilter, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 266, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel1Layout.createParallelGroup() .addComponent(jButton1, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 91, GroupLayout.PREFERRED_SIZE) .addComponent(jButton2, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 91, GroupLayout.PREFERRED_SIZE)) .addGap(19) .addComponent(jScrollPane2, GroupLayout.PREFERRED_SIZE, 36, GroupLayout.PREFERRED_SIZE) .addContainerGap(16, 16)); } { jScrollPane1 = new JScrollPane(); getContentPane().add(jScrollPane1, BorderLayout.CENTER); jScrollPane1.setPreferredSize(new java.awt.Dimension(581, 235)); { ListModel jList1Model = new DefaultComboBoxModel(); matchList = new JList(); jScrollPane1.setViewportView(matchList); // matchList.setPreferredSize(new java.awt.Dimension(575, // 232));// ??? // ?? // XXX // TODO // IMPORT // !!!! matchList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { jList1MouseClicked(evt); } }); matchList.setModel(jList1Model); } } this.setSize(697, 440); } catch (Exception e) { e.printStackTrace(); } }
From source file:es.uvigo.ei.sing.adops.views.TextFileViewer.java
public TextFileViewer(final File file) { super(new BorderLayout()); this.file = file; // TEXT AREA/*from www . jav a2 s. c o m*/ this.textArea = new JTextArea(TextFileViewer.loadFile(file)); this.textArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, this.textArea.getFont().getSize())); this.textArea.setLineWrap(true); this.textArea.setWrapStyleWord(true); this.textArea.setEditable(false); this.highlightPatiner = new DefaultHighlighter.DefaultHighlightPainter(Color.YELLOW); // OPTIONS PANEL final JPanel panelOptions = new JPanel(new BorderLayout()); final JPanel panelOptionsEast = new JPanel(new FlowLayout()); final JPanel panelOptionsWest = new JPanel(new FlowLayout()); final JCheckBox chkLineWrap = new JCheckBox("Line wrap", true); final JButton btnChangeFont = new JButton("Change Font"); final JLabel lblSearch = new JLabel("Search"); this.txtSearch = new JTextField(); this.chkRegularExpression = new JCheckBox("Reg. exp.", true); final JButton btnSearch = new JButton("Search"); final JButton btnClear = new JButton("Clear"); this.txtSearch.setColumns(12); // this.txtSearch.setOpaque(true); panelOptionsEast.add(btnChangeFont); panelOptionsEast.add(chkLineWrap); panelOptionsWest.add(lblSearch); panelOptionsWest.add(this.txtSearch); panelOptionsWest.add(this.chkRegularExpression); panelOptionsWest.add(btnSearch); panelOptionsWest.add(btnClear); if (FastaUtils.isFasta(file)) { panelOptionsWest.add(new JSeparator()); final JButton btnExport = new JButton("Export..."); panelOptionsWest.add(btnExport); btnExport.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { new ExportDialog(file).setVisible(true); } catch (Exception e1) { JOptionPane.showMessageDialog(Workbench.getInstance().getMainFrame(), "Error reading fasta file: " + e1.getMessage(), "Export Error", JOptionPane.ERROR_MESSAGE); } } }); } panelOptions.add(panelOptionsWest, BorderLayout.WEST); panelOptions.add(panelOptionsEast, BorderLayout.EAST); this.fontChooser = new JFontChooser(); this.add(new JScrollPane(this.textArea), BorderLayout.CENTER); this.add(panelOptions, BorderLayout.NORTH); chkLineWrap.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { textArea.setLineWrap(chkLineWrap.isSelected()); } }); btnChangeFont.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { changeFont(); } }); this.textArea.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { TextFileViewer.this.wasModified = true; } @Override public void insertUpdate(DocumentEvent e) { TextFileViewer.this.wasModified = true; } @Override public void changedUpdate(DocumentEvent e) { TextFileViewer.this.wasModified = true; } }); this.textArea.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { if (TextFileViewer.this.wasModified) { try { FileUtils.write(TextFileViewer.this.file, TextFileViewer.this.textArea.getText()); TextFileViewer.this.wasModified = false; } catch (IOException e1) { e1.printStackTrace(); } } } }); final ActionListener alSearch = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { updateSearch(); } }; txtSearch.addActionListener(alSearch); btnSearch.addActionListener(alSearch); btnClear.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { clearSearch(); } }); }
From source file:eu.delving.sip.frames.OutputFrame.java
private JPanel createOutputPanel() { final JPanel p = new JPanel(new BorderLayout()); p.setBorder(BorderFactory.createTitledBorder("Output record")); outputArea = new JTextArea(sipModel.getRecordCompileModel().getOutputDocument()); outputArea.setLineWrap(true);/*from w ww . j a v a 2 s .c o m*/ outputArea.setFont(MONOSPACED); outputArea.setWrapStyleWord(true); outputArea.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent documentEvent) { try { String first = documentEvent.getDocument().getText(0, 1); final boolean error = first.startsWith("#"); setError(outputArea, error); sipModel.exec(new Swing() { @Override public void run() { outputArea.setCaretPosition(0); } }); } catch (BadLocationException e) { // who cares } } @Override public void removeUpdate(DocumentEvent documentEvent) { } @Override public void changedUpdate(DocumentEvent documentEvent) { } }); outputArea.getInputMap().put(KeystrokeHelper.DOWN, "next"); outputArea.getInputMap().put(KeystrokeHelper.RIGHT, "next"); outputArea.getInputMap().put(KeystrokeHelper.UP, "prev"); outputArea.getInputMap().put(KeystrokeHelper.LEFT, "prev"); outputArea.getActionMap().put("next", new NextAction()); outputArea.getActionMap().put("prev", new PrevAction()); searchField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { found.clear(); foundSelected = 0; String xml = outputArea.getText().toLowerCase(); String sought = searchField.getText().toLowerCase(); if (!sought.isEmpty()) { int start = 0; while (found.size() < 30) { int pos = xml.indexOf(sought, start); if (pos < 0) break; found.add(pos); start = pos + sought.length(); } } selectFound(); } }); JPanel sp = new JPanel(); JLabel label = new JLabel("Search:", JLabel.RIGHT); label.setLabelFor(searchField); sp.add(label); sp.add(searchField); sp.add(new JLabel("Press ENTER, then use arrow keys")); p.add(scrollVH(outputArea), BorderLayout.CENTER); p.add(sp, BorderLayout.SOUTH); return p; }
From source file:org.nekorp.workflow.desktop.view.DatosAutoView.java
@Override public void iniciaVista() { initComponents();/* w w w . ja va2s .com*/ bindComponents(); searchModel = new AutoSearchJListModel(); search.setModel(searchModel); //esto resuelve el problema de regresar el foco a la caja de texto. search.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (search.hasFocus()) { numeroSerie.requestFocus(); } } }); this.numeroSerie.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { actualizarNumeroSerie(); } @Override public void removeUpdate(DocumentEvent e) { actualizarNumeroSerie(); } @Override public void changedUpdate(DocumentEvent e) { actualizarNumeroSerie(); } }); this.cancelIcon.add(iconProvider.getIcon(cancelSearchIconRaw)); this.searchIcon.add(iconProvider.getIcon(searchIconRaw)); }
From source file:com.diversityarrays.kdxplore.trialdesign.RscriptFinderPanel.java
public RscriptFinderPanel(BackgroundRunner br, Component component, String initialScriptPath, Consumer<Either<Throwable, String>> onScriptPathChecked) { super(new BorderLayout()); backgroundRunner = br;/* ww w . j av a 2 s. c o m*/ this.onScriptPathChecked = onScriptPathChecked; scriptPathField.setText(initialScriptPath); scriptPathField.addMouseListener(clickAdapter); Box scriptPathBox = Box.createHorizontalBox(); Consumer<Void> updateFindScriptButton = new Consumer<Void>() { @Override public void accept(Void t) { checkScriptPath.setEnabled(!scriptPathField.getText().trim().isEmpty()); } }; scriptPathBox.add(scriptPathField); scriptPathBox.add(new JButton(checkScriptPath)); scriptPathField.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { updateFindScriptButton.accept(null); } @Override public void insertUpdate(DocumentEvent e) { updateFindScriptButton.accept(null); } @Override public void changedUpdate(DocumentEvent e) { updateFindScriptButton.accept(null); } }); updateFindScriptButton.accept(null); add(scriptPathBox, BorderLayout.NORTH); if (component != null) { add(component, BorderLayout.CENTER); } }
From source file:es.emergya.ui.gis.popups.SDSDialog.java
public SDSDialog(Recurso r) { super();/* w ww . j a v a 2s.c o m*/ setAlwaysOnTop(true); setResizable(false); iconTransparente = LogicConstants.getIcon("48x48_transparente"); iconEnviando = LogicConstants.getIcon("anim_enviando"); destino = r; setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { super.windowClosing(e); cancel.doClick(); } }); // setPreferredSize(new Dimension(400, 150)); setTitle(i18n.getString("window.sds.titleBar") + " " + r.getIdentificador()); try { setIconImage(((BasicWindow) GoClassLoader.getGoClassLoader().load(BasicWindow.class)).getFrame() .getIconImage()); } catch (Throwable e) { LOG.error("There is no icon image", e); } JPanel base = new JPanel(); base.setBackground(Color.WHITE); base.setLayout(new BoxLayout(base, BoxLayout.Y_AXIS)); // Icono del titulo JPanel title = new JPanel(new FlowLayout(FlowLayout.LEADING)); final JLabel titleLabel = new JLabel(i18n.getString("window.sds.title"), LogicConstants.getIcon("tittleventana_icon_enviarsds"), JLabel.LEFT); titleLabel.setFont(LogicConstants.deriveBoldFont(12f)); title.add(titleLabel); title.setOpaque(false); base.add(title); // Espacio para el mensaje sds = new JTextArea(7, 40); sds.setLineWrap(true); final JScrollPane sdsp = new JScrollPane(sds); sdsp.setOpaque(false); sdsp.setBorder(new TitledBorder(BorderFactory.createLineBorder(Color.BLACK), i18n.getString("Admin.message") + "\t (0/" + maxChars + ")")); sds.setDocument(new PlainDocument() { @Override public void insertString(int offs, String str, AttributeSet a) throws BadLocationException { if (this.getLength() + str.length() <= maxChars) { super.insertString(offs, str, a); } } }); sds.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { updateChars(e); } @Override public void insertUpdate(DocumentEvent e) { updateChars(e); } @Override public void changedUpdate(DocumentEvent e) { updateChars(e); } private void updateChars(DocumentEvent e) { ((TitledBorder) sdsp.getBorder()).setTitle( i18n.getString("Admin.message") + "\t (" + sds.getText().length() + "/" + maxChars + ")"); sdsp.repaint(); send.setEnabled(!sds.getText().isEmpty()); notification.setForeground(Color.WHITE); notification.setText("PLACEHOLDER"); } }); base.add(sdsp); // Area para mensajes JPanel notificationArea = new JPanel(); notificationArea.setOpaque(false); notification = new JLabel("TEXT"); notification.setForeground(Color.WHITE); notificationArea.add(notification); base.add(notificationArea); JPanel buttons = new JPanel(); buttons.setOpaque(false); buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS)); send = new JButton(i18n.getString("Buttons.send"), LogicConstants.getIcon("ventanacontextual_button_enviarsds")); send.addActionListener(this); send.setEnabled(false); buttons.add(send); buttons.add(Box.createHorizontalGlue()); progressIcon = new JLabel(iconTransparente); buttons.add(progressIcon); buttons.add(Box.createHorizontalGlue()); cancel = new JButton(i18n.getString("Buttons.cancel"), LogicConstants.getIcon("button_cancel")); cancel.addActionListener(this); buttons.add(cancel); base.add(buttons); getContentPane().add(base); pack(); int x; int y; Container myParent; try { myParent = ((BasicWindow) GoClassLoader.getGoClassLoader().load(BasicWindow.class)).getFrame() .getContentPane(); java.awt.Point topLeft = myParent.getLocationOnScreen(); Dimension parentSize = myParent.getSize(); Dimension mySize = getSize(); if (parentSize.width > mySize.width) x = ((parentSize.width - mySize.width) / 2) + topLeft.x; else x = topLeft.x; if (parentSize.height > mySize.height) y = ((parentSize.height - mySize.height) / 2) + topLeft.y; else y = topLeft.y; setLocation(x, y); } catch (Throwable e1) { LOG.error("There is no basic window!", e1); } this.addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent arg0) { deleteErrorMessage(); } @Override public void windowClosed(WindowEvent arg0) { deleteErrorMessage(); } private void deleteErrorMessage() { SwingWorker<Object, Object> sw = new SwingWorker<Object, Object>() { @Override protected Object doInBackground() throws Exception { if (bandejaSalida != null) { MessageGenerator.remove(bandejaSalida.getId()); } bandejaSalida = null; return null; } @Override protected void done() { super.done(); SDSDialog.this.sds.setText(""); SDSDialog.this.sds.setEnabled(true); SDSDialog.this.sds.repaint(); SDSDialog.this.progressIcon.setIcon(iconTransparente); SDSDialog.this.progressIcon.repaint(); SDSDialog.this.notification.setText(""); SDSDialog.this.notification.repaint(); } }; sw.execute(); } }); }
From source file:com.microsoft.alm.plugin.idea.common.ui.checkout.CheckoutForm.java
private void ensureInitialized() { if (!initialized) { // Ensure that the commands are set up correctly repositoryFilter.setActionCommand(CMD_REPO_FILTER_CHANGED); refreshButton.setActionCommand(CMD_REFRESH); // Fix HiDPI scaling for table SwingHelper.scaleTableRowHeight(repositoryTable); // Fix tabbing in table SwingHelper.fixTabKeys(repositoryTable); repositoryTable.addFocusListener(new TableFocusListener(repositoryTable)); // Set help text and popup text helpPanel.addPopupCommand(TfPluginBundle.message(TfPluginBundle.KEY_VSO_LOOKUP_HELP_ENTER_URL), CMD_GOTO_TFS);//from ww w.j a v a2 s. c o m helpPanel.addPopupCommand(TfPluginBundle.message(TfPluginBundle.KEY_VSO_LOOKUP_HELP_VIEW_ACCOUNTS), CMD_GOTO_SPS_PROFILE); helpPanel.setVisible(false); // Don't show this help panel until we know if it's vs.com // Set hint text repositoryFilter.setUI( new HintTextFieldUI(TfPluginBundle.message(TfPluginBundle.KEY_CHECKOUT_DIALOG_FILTER_HINT))); // Setup folder browser parentDirectory.getInsets().right = 0; parentDirectory.addBrowseFolderListener( TfPluginBundle.message(TfPluginBundle.KEY_CHECKOUT_DIALOG_PARENT_FOLDER_DIALOG_TITLE), null, null, new FileChooserDescriptor(false, true, false, false, false, false)); // Align the busy spinner and the refresh button with the height of the text box refreshButton.putClientProperty("JButton.buttonType", "square"); // This is a magical property that tells IntelliJ to draw the button like an image button final int textBoxHeight = (int) repositoryFilter.getPreferredSize().getHeight(); final Dimension size = new Dimension(textBoxHeight, textBoxHeight); refreshButton.setMinimumSize(size); refreshButton.setPreferredSize(size); busySpinner.setMinimumSize(size); busySpinner.setPreferredSize(size); // Setup document events for filter // Using a timer so that we don't respond to every character typed // The timer is created in the create components method repositoryFilter.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(final DocumentEvent e) { onFilterChanged(); } @Override public void removeUpdate(final DocumentEvent e) { onFilterChanged(); } @Override public void changedUpdate(final DocumentEvent e) { onFilterChanged(); } private void onFilterChanged() { if (timer.isRunning()) { timer.restart(); } else { timer.start(); } } }); repositoryTableScrollPane.setMinimumSize(new Dimension(JBUI.scale(200), JBUI.scale(70))); // Initialize the advanced button (only used for TFVC right now) advancedCheckBox.setSelected(false); if (repositoryType == RepositoryContext.Type.TFVC) { advancedCheckBox.setVisible(true); advancedCheckBox.setText(TfPluginBundle.message(TfPluginBundle.KEY_CHECKOUT_DIALOG_TFVC_ADVANCED)); } else { // There are no advanced features for our Git checkout dialog advancedCheckBox.setVisible(false); } initialized = true; } }
From source file:captureplugin.drivers.DeviceCreatorDialog.java
/** * Create the GUI/*from www. jav a 2s. c o m*/ */ private void createGUI() { UiUtilities.registerForClosing(this); DriverIf[] drivers = DriverFactory.getInstance().getDrivers(); mDriverCombo = new JComboBox(drivers); mDriverCombo.setRenderer(new DefaultListCellRenderer() { public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { if (value instanceof DriverIf) { value = ((DriverIf) value).getDriverName(); } return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); } }); JPanel panel = (JPanel) getContentPane(); panel.setLayout(new GridBagLayout()); GridBagConstraints label = new GridBagConstraints(); label.insets = new Insets(5, 5, 5, 5); label.anchor = GridBagConstraints.NORTHWEST; GridBagConstraints input = new GridBagConstraints(); input.fill = GridBagConstraints.HORIZONTAL; input.weightx = 1.0; input.gridwidth = GridBagConstraints.REMAINDER; input.insets = new Insets(5, 5, 5, 5); panel.add(new JLabel(mLocalizer.msg("Name", "Name")), label); mName = new JTextField(); panel.add(mName, input); panel.add(new JLabel(mLocalizer.msg("Driver", "Driver")), label); panel.add(mDriverCombo, input); mDesc = UiUtilities.createHtmlHelpTextArea(""); mDesc.setEditable(false); panel.add(new JLabel(mLocalizer.msg("Description", "Description")), input); GridBagConstraints descC = new GridBagConstraints(); descC.weightx = 1.0; descC.weighty = 1.0; descC.fill = GridBagConstraints.BOTH; descC.gridwidth = GridBagConstraints.REMAINDER; descC.insets = new Insets(5, 5, 5, 5); panel.add(new JScrollPane(mDesc, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER), descC); final Font font = new JLabel().getFont(); String desc = ((DriverIf) mDriverCombo.getSelectedItem()).getDriverDesc(); desc = "<html><div style=\"color:#000000;font-family:" + font.getName() + "; font-size:" + font.getSize() + ";\">" + desc + "</div></html>"; mDesc.setText(desc); mDesc.setFont(font); mDriverCombo.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { String description = ((DriverIf) mDriverCombo.getSelectedItem()).getDriverDesc(); description = "<html><div style=\"color:#000000;font-family:" + font.getName() + "; font-size:" + font.getSize() + ";\">" + description + "</div></html>"; mDesc.setText(description); mDesc.setFont(font); } }); final JButton ok = new JButton(Localizer.getLocalization(Localizer.I18N_OK)); ok.setEnabled(false); final JButton cancel = new JButton(Localizer.getLocalization(Localizer.I18N_CANCEL)); ok.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { okPressed(); } }); cancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setVisible(false); } }); mName.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { updateButtons(); } @Override public void insertUpdate(DocumentEvent e) { updateButtons(); } @Override public void changedUpdate(DocumentEvent e) { updateButtons(); } private void updateButtons() { ok.setEnabled(!mName.getText().trim().isEmpty()); } }); ButtonBarBuilder2 builder = new ButtonBarBuilder2(); builder.addGlue(); builder.addButton(new JButton[] { ok, cancel }); getRootPane().setDefaultButton(ok); input.insets = new Insets(5, 5, 5, 5); panel.add(builder.getPanel(), input); setSize(400, 300); }