use of javax.swing.event.DocumentEvent in project knime-core by knime.
the class JavaSnippet method getDocument.
@Override
public GuardedDocument getDocument() {
// Lazy initialization of the document
if (m_document == null) {
m_document = createDocument();
m_document.addDocumentListener(new DocumentListener() {
@Override
public void removeUpdate(final DocumentEvent e) {
m_dirty = true;
}
@Override
public void insertUpdate(final DocumentEvent e) {
m_dirty = true;
}
@Override
public void changedUpdate(final DocumentEvent e) {
m_dirty = true;
}
});
initDocument(m_document);
}
return m_document;
}
use of javax.swing.event.DocumentEvent 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.DocumentEvent 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.DocumentEvent 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.DocumentEvent 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);
}
Aggregations