use of javax.swing.event.DocumentListener in project vcell by virtualcell.
the class BNGLDebugger method initialize.
@Deprecated
public void initialize() {
// -------------------------------------------------- bngl panel
JScrollPane bnglPanel = new JScrollPane();
bnglTextArea = new JTextArea();
bnglTextArea.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
// bnglTextArea.setFont(new Font("monospaced", Font.PLAIN, 14));
lineNumberArea = new JTextArea("1");
lineNumberArea.setBackground(Color.LIGHT_GRAY);
lineNumberArea.setEditable(false);
lineNumberArea.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
bnglTextArea.getDocument().addDocumentListener(new DocumentListener() {
public String getNr() {
lines = 1;
int caretPosition = bnglTextArea.getDocument().getLength();
Element root = bnglTextArea.getDocument().getDefaultRootElement();
String nr = "1" + System.getProperty("line.separator");
for (int i = 2; i < root.getElementIndex(caretPosition) + 2; i++) {
nr += i + System.getProperty("line.separator");
lines++;
}
return nr;
}
@Override
public void changedUpdate(DocumentEvent de) {
int oldLines = lines;
String numbers = getNr();
if (oldLines != lines) {
lineNumberArea.setText(numbers);
}
lineNumberArea.getHighlighter().removeAllHighlights();
}
@Override
public void insertUpdate(DocumentEvent de) {
int oldLines = lines;
String numbers = getNr();
if (oldLines != lines) {
lineNumberArea.setText(numbers);
}
lineNumberArea.getHighlighter().removeAllHighlights();
}
@Override
public void removeUpdate(DocumentEvent de) {
int oldLines = lines;
String numbers = getNr();
if (oldLines != lines) {
lineNumberArea.setText(numbers);
}
lineNumberArea.getHighlighter().removeAllHighlights();
}
});
bnglPanel.getViewport().add(bnglTextArea);
bnglPanel.setRowHeaderView(lineNumberArea);
bnglPanel.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
JPanel upperPanel = new JPanel();
upperPanel.setLayout(new BorderLayout());
upperPanel.add(bnglPanel, BorderLayout.CENTER);
// ---------------------------------------------------- exception panel
JScrollPane exceptionPanel = new JScrollPane();
exceptionTextArea = new JTextArea();
exceptionTextArea.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
exceptionTextArea.setFont(new Font("monospaced", Font.PLAIN, 14));
exceptionPanel.getViewport().add(exceptionTextArea);
exceptionPanel.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
JPanel lowerPanel = new JPanel();
lowerPanel.setLayout(new BorderLayout());
lowerPanel.add(exceptionPanel, BorderLayout.CENTER);
// ---------------------------------------------------- all together now :)
JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
splitPane.setOneTouchExpandable(true);
splitPane.setDividerLocation(350);
splitPane.setResizeWeight(0.9);
splitPane.setTopComponent(upperPanel);
splitPane.setBottomComponent(lowerPanel);
// ... Create menubar
JMenuBar menuBar = new JMenuBar();
JMenu fileMenu = menuBar.add(new JMenu("File"));
// fileMenu.setMnemonic('F');
// fileMenu.add(openAction); // Note use of actions, not text.
// fileMenu.add(saveAction);
// fileMenu.addSeparator();
fileMenu.add(exitAction);
JPanel buttonPane = new JPanel();
buttonParse.addActionListener(this);
buttonSave.addActionListener(this);
buttonExit.addActionListener(this);
buttonPane.add(buttonParse);
buttonPane.add(buttonSave);
buttonPane.add(buttonExit);
JPanel framePanel = new JPanel();
framePanel.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.gridwidth = 1;
gbc.weightx = 1;
gbc.weighty = 1;
gbc.fill = GridBagConstraints.BOTH;
framePanel.add(splitPane, gbc);
gbc.gridx = 0;
gbc.gridy = 1;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.gridwidth = GridBagConstraints.REMAINDER;
framePanel.add(buttonPane, gbc);
frame.add(framePanel);
frame.setJMenuBar(menuBar);
frame.pack();
frame.setName("BnglDebugger");
frame.setSize(900, 650);
frame.setVisible(true);
}
use of javax.swing.event.DocumentListener in project vcell by virtualcell.
the class ApplicationSpecificationsPanel method initialize.
@Override
protected void initialize() {
super.initialize();
InitialConditionsPanel initialConditionsPanel = new InitialConditionsPanel();
ModelProcessSpecsPanel modelProcessSpecsPanel = new ModelProcessSpecsPanel();
networkConstraintsPanel = new NetworkConstraintsPanel();
networkFreePanel = new NetworkFreePanel();
MembraneConditionsPanel membraneConditionsPanel = new MembraneConditionsPanel();
// order of calls determines display order
setupTab("Species", initialConditionsPanel);
setupTab("Reaction", modelProcessSpecsPanel);
setupTab("Membrane", membraneConditionsPanel);
setupTab("Network", networkConstraintsPanel);
setupTab("Network-Free", networkFreePanel);
activate(initialConditionsPanel);
activate(modelProcessSpecsPanel);
if (System.getProperty("showMembrane") != null) {
activate(membraneConditionsPanel);
}
JPanel searchPanel = new JPanel();
GridBagLayout gbl_searchPanel = new GridBagLayout();
gbl_searchPanel.columnWeights = new double[] { 0.0, 1.0 };
searchPanel.setLayout(gbl_searchPanel);
JLabel lblNewLabel = new JLabel("Search");
GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
gbc_lblNewLabel.insets = new Insets(5, 5, 5, 5);
gbc_lblNewLabel.anchor = GridBagConstraints.EAST;
gbc_lblNewLabel.gridx = 0;
gbc_lblNewLabel.gridy = 0;
searchPanel.add(lblNewLabel, gbc_lblNewLabel);
textField_1 = new JTextField();
textField_1.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void removeUpdate(DocumentEvent e) {
searchTable();
}
@Override
public void insertUpdate(DocumentEvent e) {
searchTable();
}
@Override
public void changedUpdate(DocumentEvent e) {
searchTable();
}
});
textField_1.putClientProperty("JTextField.variant", "search");
GridBagConstraints gbc_textField_1 = new GridBagConstraints();
gbc_textField_1.insets = new Insets(5, 5, 5, 5);
gbc_textField_1.weightx = 1.0;
gbc_textField_1.fill = GridBagConstraints.HORIZONTAL;
gbc_textField_1.gridx = 1;
gbc_textField_1.gridy = 0;
searchPanel.add(textField_1, gbc_textField_1);
textField_1.setColumns(10);
add(searchPanel, BorderLayout.SOUTH);
tabbedPane.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
searchTable();
}
});
}
use of javax.swing.event.DocumentListener in project processdash by dtuma.
the class TimeCardDialog method buildTopPanel.
private Component buildTopPanel() {
Box result = Box.createHorizontalBox();
result.add(new JLabel(resources.getString("Time_Card.Month_Label") + " "));
// We have to build our own month name array because the "official"
// one contains 13 month names, the last one empty for Gregorian
// Calendars
String[] monthNames = new String[12];
String[] officialMonthNames = (new DateFormatSymbols()).getMonths();
for (int i = 12; i-- > 0; ) monthNames[i] = officialMonthNames[i];
monthField = new JComboBox(monthNames);
dontGrow(monthField);
monthField.setSelectedIndex(model.getMonth() - Calendar.JANUARY);
monthField.setMaximumRowCount(12);
result.add(monthField);
monthField.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
recalc();
}
});
yearField = new JTextField(5);
dontGrow(yearField);
yearField.setText(Integer.toString(model.getYear()));
result.add(yearField);
yearField.getDocument().addDocumentListener(new DocumentListener() {
public void insertUpdate(DocumentEvent e) {
recalc();
}
public void removeUpdate(DocumentEvent e) {
recalc();
}
public void changedUpdate(DocumentEvent e) {
recalc();
}
});
result.add(Box.createHorizontalGlue());
result.add(new JLabel(resources.getString("Time_Format.Label") + " "));
formatType = new JComboBox();
formatType.addItem(format(75, HOURS_MINUTES));
formatType.addItem(format(75, HOURS));
formatType.addItem(format(75, MINUTES));
dontGrow(formatType);
result.add(formatType);
formatType.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
redraw();
}
});
result.add(Box.createHorizontalGlue());
hideColumns = new JCheckBox();
result.add(new JLabel(" " + resources.getString("Time_Card.Hide_Empty_Columns_Label") + " "));
result.add(hideColumns);
hideColumns.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
resizeColumns();
}
});
result.add(Box.createHorizontalGlue());
JButton closeButton = new JButton(resources.getString("Close"));
dontGrow(closeButton);
result.add(Box.createVerticalStrut(closeButton.getPreferredSize().height + 4));
result.add(closeButton);
closeButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
frame.setVisible(false);
}
});
return result;
}
use of javax.swing.event.DocumentListener in project gephi by gephi.
the class DirectoryChooserUI method createBottomPanel.
private void createBottomPanel(JFileChooser fc) {
bottomPanel = new JPanel();
bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.LINE_AXIS));
JPanel labelPanel = new JPanel();
labelPanel.setLayout(new BoxLayout(labelPanel, BoxLayout.PAGE_AXIS));
labelPanel.add(Box.createRigidArea(verticalStrut1));
JLabel fnl = new JLabel(fileNameLabelText);
fnl.setDisplayedMnemonic(fileNameLabelMnemonic);
fnl.setAlignmentY(0);
labelPanel.add(fnl);
labelPanel.add(Box.createRigidArea(new Dimension(1, 12)));
JLabel ftl = new JLabel(filesOfTypeLabelText);
ftl.setDisplayedMnemonic(filesOfTypeLabelMnemonic);
labelPanel.add(ftl);
bottomPanel.add(labelPanel);
bottomPanel.add(Box.createRigidArea(new Dimension(15, 0)));
JPanel fileAndFilterPanel = new JPanel();
fileAndFilterPanel.add(Box.createRigidArea(verticalStrut3));
fileAndFilterPanel.setLayout(new BoxLayout(fileAndFilterPanel, BoxLayout.Y_AXIS));
filenameTextField = new JTextField(24) {
@Override
public Dimension getMaximumSize() {
return new Dimension(Short.MAX_VALUE, super.getPreferredSize().height);
}
};
filenameTextField.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
updateCompletions();
}
@Override
public void removeUpdate(DocumentEvent e) {
updateCompletions();
}
@Override
public void changedUpdate(DocumentEvent e) {
}
});
filenameTextField.addKeyListener(new TextFieldKeyListener());
fnl.setLabelFor(filenameTextField);
filenameTextField.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
if (!getFileChooser().isMultiSelectionEnabled()) {
tree.clearSelection();
}
}
});
// disable TAB focus transfer, we need it for completion
Set<AWTKeyStroke> tKeys = filenameTextField.getFocusTraversalKeys(java.awt.KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);
Set<AWTKeyStroke> newTKeys = new HashSet<AWTKeyStroke>(tKeys);
newTKeys.remove(AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_TAB, 0));
// #107305: enable at least Ctrl+TAB if we have TAB for completion
newTKeys.add(AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_TAB, KeyEvent.CTRL_DOWN_MASK));
filenameTextField.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, newTKeys);
fileAndFilterPanel.add(filenameTextField);
fileAndFilterPanel.add(Box.createRigidArea(verticalStrut3));
filterTypeComboBoxModel = createFilterComboBoxModel();
fc.addPropertyChangeListener(filterTypeComboBoxModel);
filterTypeComboBox = new JComboBox(filterTypeComboBoxModel);
ftl.setLabelFor(filterTypeComboBox);
filterTypeComboBox.setRenderer(createFilterComboBoxRenderer());
fileAndFilterPanel.add(filterTypeComboBox);
bottomPanel.add(fileAndFilterPanel);
bottomPanel.add(Box.createRigidArea(horizontalStrut1));
createButtonsPanel(fc);
}
use of javax.swing.event.DocumentListener in project libgdx by libgdx.
the class JglfwInput method getTextInput.
public void getTextInput(final TextInputListener listener, final String title, final String text, final String hint) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JPanel panel = new JPanel(new FlowLayout());
JPanel textPanel = new JPanel() {
public boolean isOptimizedDrawingEnabled() {
return false;
}
;
};
textPanel.setLayout(new OverlayLayout(textPanel));
panel.add(textPanel);
final JTextField textField = new JTextField(20);
textField.setText(text);
textField.setAlignmentX(0.0f);
textPanel.add(textField);
final JLabel placeholderLabel = new JLabel(hint);
placeholderLabel.setForeground(Color.GRAY);
placeholderLabel.setAlignmentX(0.0f);
textPanel.add(placeholderLabel, 0);
textField.getDocument().addDocumentListener(new DocumentListener() {
public void removeUpdate(DocumentEvent event) {
this.updated();
}
public void insertUpdate(DocumentEvent event) {
this.updated();
}
public void changedUpdate(DocumentEvent event) {
this.updated();
}
private void updated() {
placeholderLabel.setVisible(textField.getText().length() == 0);
}
});
JOptionPane pane = new JOptionPane(panel, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, null, null);
pane.setComponentOrientation(JOptionPane.getRootFrame().getComponentOrientation());
pane.selectInitialValue();
placeholderLabel.setBorder(new EmptyBorder(textField.getBorder().getBorderInsets(textField)));
JDialog dialog = pane.createDialog(null, title);
dialog.addWindowFocusListener(new WindowFocusListener() {
public void windowLostFocus(WindowEvent arg0) {
}
public void windowGainedFocus(WindowEvent arg0) {
textField.requestFocusInWindow();
}
});
dialog.setVisible(true);
dialog.dispose();
Object selectedValue = pane.getValue();
if (selectedValue != null && (selectedValue instanceof Integer) && (Integer) selectedValue == JOptionPane.OK_OPTION)
listener.input(textField.getText());
else
listener.canceled();
}
});
}
Aggregations