use of javax.swing.JTextArea in project aerospike-client-java by aerospike.
the class GuiDisplay method initialize.
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frmAerospikeExamples = new JFrame();
frmAerospikeExamples.setTitle("Aerospike Java Client Examples");
frmAerospikeExamples.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frmAerospikeExamples.pack();
frmAerospikeExamples.getContentPane().setLayout(new BorderLayout(0, 0));
splitPane = new JSplitPane();
splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
frmAerospikeExamples.getContentPane().add(splitPane, BorderLayout.CENTER);
mainPanel = new JPanel();
splitPane.setLeftComponent(mainPanel);
mainPanel.setLayout(new BorderLayout(0, 0));
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
runButton = new JButton("Run");
runButton.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent ev) {
consoleTextArea.setText("");
run_selected_examples();
}
});
buttonPanel.add(runButton);
mainPanel.add(buttonPanel, BorderLayout.SOUTH);
exitButton = new JButton("Quit");
exitButton.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent arg0) {
Container Frame = exitButton.getParent();
do {
Frame = Frame.getParent();
} while (!(Frame instanceof JFrame));
((JFrame) Frame).dispose();
}
});
buttonPanel.add(exitButton);
sourceTextPane = new JTextArea();
sourceTextPane.setTabSize(2);
sourceTextPane.setEditable(false);
scrollPane = new JScrollPane(sourceTextPane);
scrollPane.setViewportBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
scrollPane.setPreferredSize(new Dimension(600, 100));
mainPanel.add(scrollPane, BorderLayout.CENTER);
connectionPanel = new JPanel();
connectionPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
lblServerHost = new JLabel("Server Host");
connectionPanel.add(lblServerHost);
seedHostTextField = new JTextField();
seedHostTextField.addKeyListener(new KeyAdapter() {
@Override
public void keyTyped(KeyEvent e) {
params.host = seedHostTextField.getText();
}
});
connectionPanel.add(seedHostTextField);
seedHostTextField.setColumns(10);
lblPort = new JLabel("Port");
connectionPanel.add(lblPort);
portTextField = new JTextField();
portTextField.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent arg0) {
String newValue = namespaceTextField.getText();
if (newValue != null && newValue != "") {
try {
params.port = Integer.parseInt(newValue);
} catch (NumberFormatException ne) {
// ne.printStackTrace();
}
}
}
});
connectionPanel.add(portTextField);
portTextField.setColumns(4);
lblusername = new JLabel("User");
connectionPanel.add(lblusername);
usernameTextField = new JTextField();
usernameTextField.addKeyListener(new KeyAdapter() {
@Override
public void keyTyped(KeyEvent e) {
params.user = usernameTextField.getText();
}
});
connectionPanel.add(usernameTextField);
usernameTextField.setColumns(8);
lblpassword = new JLabel("Password");
connectionPanel.add(lblpassword);
passwordTextField = new JPasswordField();
passwordTextField.addKeyListener(new KeyAdapter() {
@Override
public void keyTyped(KeyEvent e) {
params.user = new String(passwordTextField.getPassword());
}
});
connectionPanel.add(passwordTextField);
passwordTextField.setColumns(8);
lblnameSpace = new JLabel("Namespace");
connectionPanel.add(lblnameSpace);
namespaceTextField = new JTextField();
namespaceTextField.addKeyListener(new KeyAdapter() {
@Override
public void keyTyped(KeyEvent e) {
params.namespace = namespaceTextField.getText();
}
});
connectionPanel.add(namespaceTextField);
namespaceTextField.setColumns(8);
lblSet = new JLabel("Set");
connectionPanel.add(lblSet);
txtSetTextfield = new JTextField();
txtSetTextfield.addKeyListener(new KeyAdapter() {
@Override
public void keyTyped(KeyEvent e) {
params.set = txtSetTextfield.getText();
}
});
connectionPanel.add(txtSetTextfield);
txtSetTextfield.setColumns(8);
mainPanel.add(connectionPanel, BorderLayout.NORTH);
examplePanel = new JPanel();
examplePanel.setLayout(new BoxLayout(examplePanel, BoxLayout.Y_AXIS));
exampleScrollPane = new JScrollPane(examplePanel);
mainPanel.add(exampleScrollPane, BorderLayout.WEST);
// init values
seedHostTextField.setText(params.host);
portTextField.setText(Integer.toString(params.port));
namespaceTextField.setText(params.namespace);
txtSetTextfield.setText(params.set);
// int width = 785;
int width = 1000;
int height = 180;
consoleTextArea = new JTextArea();
consoleTextArea.setSize(new Dimension(width, height));
consoleTextArea.setEditable(false);
consoleScrollPane = new JScrollPane(consoleTextArea);
consoleScrollPane.setPreferredSize(new Dimension(width, height));
consoleScrollPane.setSize(new Dimension(width, height));
splitPane.setRightComponent(consoleScrollPane);
buttonGroup = new ButtonGroup();
JRadioButton jrb;
for (String example : Main.getAllExampleNames()) {
jrb = new JRadioButton(example);
jrb.setActionCommand(example);
jrb.addActionListener(this);
buttonGroup.add(jrb);
examplePanel.add(jrb);
}
frmAerospikeExamples.pack();
}
use of javax.swing.JTextArea in project suite by stupidsing.
the class EditorView method run.
public JFrame run(EditorController controller, String title) {
JTextField searchTextField = this.searchTextField = applyDefaults(new JTextField(32));
DefaultListModel<String> listModel = this.listModel = new DefaultListModel<>();
listModel.addElement("<Empty>");
JList<String> searchList = this.searchList = applyDefaults(new JList<>(listModel));
searchList.setFont(sansFont);
JLabel rightLabel = this.rightLabel = applyDefaults(new JLabel("Right"));
rightLabel.setVisible(false);
JTextField filenameTextField = this.filenameTextField = applyDefaults(new JTextField("pad"));
filenameTextField.setVisible(false);
JTextArea messageTextArea = this.messageTextArea = applyDefaults(new JTextArea("Bottom"));
messageTextArea.setEditable(false);
messageTextArea.setRows(12);
JScrollPane messageScrollPane = this.messageScrollPane = newScrollPane(messageTextArea);
messageScrollPane.setVisible(false);
JEditorPane editor = this.editor = applyDefaults(new EditorPane(model));
JScrollPane editorScrollPane = newScrollPane(editor);
JButton okButton = applyDefaults(new JButton("OK"));
Listen.mouseClicked(okButton).wire(controller::evaluate);
JFrame frame = this.frame = new JFrame(title);
frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
frame.setJMenuBar(newMenuBar(controller));
frame.setSize(new Dimension(windowWidth, windowHeight));
frame.setVisible(true);
int u = 64, u3 = u * 3;
lay = new LayoutCalculator(frame.getContentPane());
layout = //
lay.boxh(lay.ex(u, //
lay.boxv(//
lay.fx(24, lay.c(searchTextField)), //
lay.ex(u, lay.c(searchList)))), lay.ex(u3, //
lay.boxv(//
lay.fx(24, lay.c(filenameTextField)), //
lay.ex(u3, lay.c(editorScrollPane)), //
lay.fx(8, lay.b()), lay.fx(24, //
lay.boxh(//
lay.ex(u3, lay.b()), //
lay.fx(64, lay.c(okButton)), //
lay.ex(u3, lay.b()))), //
lay.ex(u, lay.c(messageScrollPane)))), lay.ex(u, lay.c(rightLabel)));
Listen.action(searchTextField).wire(event -> controller.searchFiles(model.searchText()));
Listen.componentResized(frame).wire(this::refresh);
Listen.documentChanged(filenameTextField).wire(event -> model.changeFilename(filenameTextField.getText()));
Listen.documentChanged(searchTextField).wire(event -> model.changeSearchText(searchTextField.getText()));
Listen.keyPressed(searchTextField, KeyEvent.VK_DOWN).wire(event -> controller.downToSearchList());
Listen.keyPressed(searchList, KeyEvent.VK_ENTER).wire(event -> controller.selectList(searchList.getSelectedValue()));
Listen.mouseDoubleClicked(searchList).wire(event -> controller.selectList(searchList.getSelectedValue()));
Listen.windowClosing(frame).wire(controller::close);
model.filenameChanged().wire(filename -> {
filenameTextField.setText(filename);
repaint();
});
model.isModifiedChanged().wire(this::repaint);
controller.newFile();
refresh();
editor.requestFocusInWindow();
return frame;
}
use of javax.swing.JTextArea in project knime-core by knime.
the class ColumnRowFilterPanel method instantiateComponents.
@SuppressWarnings("unchecked")
private void instantiateComponents(final RowFilterNodeDialogPane parentPane, final DataTableSpec tSpec) throws NotConfigurableException {
/* instantiate the col idx selector, depending on the table spec */
assert ((tSpec != null) && (tSpec.getNumColumns() > 0));
Vector<String> colNames = new Vector<String>();
for (int c = 0; c < tSpec.getNumColumns(); c++) {
colNames.add(tSpec.getColumnSpec(c).getName());
}
m_colCombo = new ColumnSelectionComboxBox((Border) null, DataValue.class);
m_colCombo.update(tSpec, null);
m_colCombo.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
selectedColChanged();
}
});
m_deepFiltering = new JCheckBox("filter based on collection elements");
/* the selectors for what kind of checking will be done */
m_useRange = new JRadioButton("use range checking");
m_useRegExpr = new JRadioButton("use pattern matching");
m_useMissValue = new JRadioButton("only missing values match");
m_useRange.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
radiosChanged();
}
});
m_useRegExpr.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
radiosChanged();
}
});
m_useMissValue.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
radiosChanged();
}
});
m_radios = new ButtonGroup();
m_radios.add(m_useRange);
m_radios.add(m_useRegExpr);
m_radios.add(m_useMissValue);
/* the bound edit fields */
m_lowerLabel = new JLabel("lower bound:");
m_lowerLabel.setToolTipText("Smallest value of the range to be filtered.");
m_lowerBound = new JTextField();
m_upperLabel = new JLabel("upper bound:");
m_upperLabel.setToolTipText("Largest value of the range to be filtered.");
m_upperBound = new JTextField();
m_lowerBound.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void insertUpdate(final DocumentEvent e) {
boundsChanged();
}
@Override
public void removeUpdate(final DocumentEvent e) {
boundsChanged();
}
@Override
public void changedUpdate(final DocumentEvent e) {
boundsChanged();
}
});
m_upperBound.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void insertUpdate(final DocumentEvent e) {
boundsChanged();
}
@Override
public void removeUpdate(final DocumentEvent e) {
boundsChanged();
}
@Override
public void changedUpdate(final DocumentEvent e) {
boundsChanged();
}
});
/* the regular expression stuff */
m_regLabel = new JLabel("pattern:");
// it's important that the column selection is created before!
m_regExpr = new JComboBox(getPossibleValuesOfSelectedColumn());
m_regExpr.setEditable(true);
m_regExpr.setSelectedItem("");
m_regExpr.setMinimumSize(new Dimension(50, m_regExpr.getPreferredSize().height));
// m_regExpr.setPreferredSize(new Dimension(200, 50));
m_regExpr.setMaximumSize(new Dimension(300, 50));
JTextField ed = (JTextField) m_regExpr.getEditor().getEditorComponent();
ed.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void insertUpdate(final DocumentEvent e) {
regExprChanged();
}
@Override
public void removeUpdate(final DocumentEvent e) {
regExprChanged();
}
@Override
public void changedUpdate(final DocumentEvent e) {
regExprChanged();
}
});
m_regExpr.addItemListener(this);
/* add flow variable button for the pattern/regexpr */
FlowVariableModel fvm = parentPane.createFlowVariableModel(new String[] { RowFilterNodeModel.CFGFILTER, StringCompareRowFilter.CFGKEY_PATTERN }, FlowVariable.Type.STRING);
fvm.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(final ChangeEvent evt) {
FlowVariableModel fvm = (FlowVariableModel) (evt.getSource());
m_regExpr.setEnabled(!fvm.isVariableReplacementEnabled());
if (fvm.isVariableReplacementEnabled() && m_regExpr.getSelectedItem().equals("")) {
// TODO: replace with more meaningful default - empty
// pattern are rejected by dialog.
m_regExpr.setSelectedItem(fvm.getInputVariableName());
}
}
});
m_regExprVarButton = new FlowVariableModelButton(fvm);
m_caseSensitive = new JCheckBox("case sensitive match");
m_isRegExpr = new JCheckBox("regular expression");
m_hasWildCards = new JCheckBox("contains wild cards");
m_hasWildCards.setToolTipText("insert '?' or '*' to match any one " + "character or any sequence (including none) of characters.");
m_isRegExpr.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
wildRegExprChanged(e);
// also trigger regular expression recompile
regExprChanged();
}
});
m_hasWildCards.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
wildRegExprChanged(e);
// also trigger regular expression recompile
regExprChanged();
}
});
/* and a label to display errors/warnings */
m_errText = new JTextArea();
m_errText.setEditable(false);
m_errText.setLineWrap(true);
m_errText.setWrapStyleWord(true);
m_errText.setBackground(getBackground());
m_errText.setFont(new Font(m_errText.getFont().getName(), Font.BOLD, m_errText.getFont().getSize()));
m_errText.setMinimumSize(new Dimension(350, 50));
m_errText.setMaximumSize(new Dimension(350, 100));
m_errText.setForeground(Color.RED);
/* set the default values */
m_useRegExpr.setSelected(true);
}
use of javax.swing.JTextArea in project eclipse.platform.swt by eclipse.
the class Bug306490_SwingDisposeError method createSwing.
static void createSwing() {
JFrame frame = new JFrame("Swing, close me (before or after closing the other window)");
frame.setBounds(0, 0, 600, 100);
frame.addWindowListener(new // same bug with using setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE) instead
WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
e.getWindow().dispose();
System.out.println("Swing: disposed");
}
});
// remark 1: comment out the following line (do not add textArea) and all works fine
frame.getContentPane().add(new JTextArea());
frame.setVisible(true);
}
use of javax.swing.JTextArea 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);
}
Aggregations