use of java.awt.event.FocusEvent in project ceylon-compiler by ceylon.
the class SelectToolTask method createPane.
JOptionPane createPane(final Properties props) {
JPanel body = new JPanel(new GridBagLayout());
GridBagConstraints lc = new GridBagConstraints();
lc.insets.right = 10;
lc.insets.bottom = 3;
GridBagConstraints fc = new GridBagConstraints();
fc.anchor = GridBagConstraints.WEST;
fc.gridx = 1;
fc.gridwidth = GridBagConstraints.REMAINDER;
fc.insets.bottom = 3;
JLabel toolLabel = new JLabel("Tool:");
body.add(toolLabel, lc);
String[] toolChoices = { "apt", "javac", "javadoc", "javah", "javap" };
if (true || toolProperty == null) {
// include empty value in setup mode
List<String> l = new ArrayList<String>(Arrays.asList(toolChoices));
l.add(0, "");
toolChoices = l.toArray(new String[l.size()]);
}
toolChoice = new JComboBox(toolChoices);
if (toolName != null)
toolChoice.setSelectedItem(toolName);
toolChoice.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
String tn = (String) e.getItem();
argsField.setText(getDefaultArgsForTool(props, tn));
if (toolProperty != null)
okButton.setEnabled(!tn.equals(""));
}
});
body.add(toolChoice, fc);
argsField = new JTextField(getDefaultArgsForTool(props, toolName), 40);
if (toolProperty == null || argsProperty != null) {
JLabel argsLabel = new JLabel("Args:");
body.add(argsLabel, lc);
body.add(argsField, fc);
argsField.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
}
public void focusLost(FocusEvent e) {
String toolName = (String) toolChoice.getSelectedItem();
if (toolName.length() > 0)
props.put(toolName + ".args", argsField.getText());
}
});
}
defaultCheck = new JCheckBox("Set as default");
if (toolProperty == null)
defaultCheck.setSelected(true);
else
body.add(defaultCheck, fc);
final JOptionPane p = new JOptionPane(body);
okButton = new JButton("OK");
okButton.setEnabled(toolProperty == null || (toolName != null && !toolName.equals("")));
okButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JDialog d = (JDialog) SwingUtilities.getAncestorOfClass(JDialog.class, p);
d.setVisible(false);
}
});
p.setOptions(new Object[] { okButton });
return p;
}
use of java.awt.event.FocusEvent in project SAGU by brianmcmichael.
the class LogTypesTest method isEventSourceShouldWork.
@Test
public void isEventSourceShouldWork() throws Exception {
final LogTypes logTypes = new LogTypes(menu, 0);
final FocusEvent event = mock(FocusEvent.class);
assertThat(logTypes.isEventSource(event), is(false));
when(event.getSource()).thenReturn(logTypes.getLogRadio());
assertThat(logTypes.isEventSource(event), is(true));
when(event.getSource()).thenReturn(logTypes.getTxtRadio());
assertThat(logTypes.isEventSource(event), is(true));
when(event.getSource()).thenReturn(logTypes.getCsvRadio());
assertThat(logTypes.isEventSource(event), is(true));
when(event.getSource()).thenReturn(logTypes.getYamlRadio());
assertThat(logTypes.isEventSource(event), is(true));
}
use of java.awt.event.FocusEvent in project processdash by dtuma.
the class AbstractCustomProcessEditor method buildHeader.
private Component buildHeader() {
Box header = Box.createHorizontalBox();
header.add(Box.createHorizontalStrut(2));
header.add(new JLabel("Framework Name: "));
header.add(processName = new JTextField(20));
header.add(Box.createHorizontalStrut(10));
header.add(new JLabel("Framework Version: "));
header.add(processVersion = new JTextField(5));
header.add(Box.createHorizontalStrut(2));
// Notify the process of changes to the name and version
FocusListener l = new FocusAdapter() {
public void focusLost(FocusEvent e) {
process.setName(processName.getText());
processName.setText(process.getName());
process.setVersion(processVersion.getText());
processVersion.setText(process.getVersion());
}
};
processName.addFocusListener(l);
processVersion.addFocusListener(l);
Box result = Box.createVerticalBox();
result.add(Box.createVerticalStrut(2));
result.add(header);
result.add(Box.createVerticalStrut(2));
return result;
}
use of java.awt.event.FocusEvent in project processdash by dtuma.
the class BoundTextField method addUpdateFromTextListeners.
protected void addUpdateFromTextListeners() {
addActionListener((ActionListener) EventHandler.create(ActionListener.class, this, "updateFromText"));
addFocusListener(new FocusAdapter() {
public void focusLost(FocusEvent e) {
updateFromText();
}
});
}
use of java.awt.event.FocusEvent in project vcell by virtualcell.
the class ScrollTable method initialize.
private void initialize() {
autoResizeMode = AUTO_RESIZE_OFF;
// make it bigger on Mac
setRowHeight(getRowHeight() + 4);
putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
putClientProperty("JTable.autoStartsEdit", Boolean.FALSE);
scrollTableActionManager = new DefaultScrollTableActionManager(this);
enclosingScrollPane = new JScrollPane(this);
enclosingScrollPane.getViewport().setBackground(Color.WHITE);
contentPanel = new JPanel(new BorderLayout());
contentPanel.add(enclosingScrollPane, BorderLayout.CENTER);
setPreferredScrollableViewportSize(new Dimension(200, 100));
setIntercellSpacing(new Dimension(2, 2));
defaultTableCellRenderer = new DefaultScrollTableCellRenderer();
setDefaultRenderer(Object.class, defaultTableCellRenderer);
setDefaultRenderer(Number.class, defaultTableCellRenderer);
setDefaultRenderer(Double.class, defaultTableCellRenderer);
setDefaultRenderer(Boolean.class, new ScrollTableBooleanCellRenderer());
setDefaultEditor(Boolean.class, new ScrollTableBooleanEditor());
final TableCellRenderer defaultTableCellHeaderRenderer = getTableHeader().getDefaultRenderer();
TableCellRenderer defaultTableHeaderRenderer = new TableCellRenderer() {
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Component component = defaultTableCellHeaderRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (component instanceof JLabel) {
JLabel label = (JLabel) component;
label.setHorizontalAlignment(SwingConstants.CENTER);
label.setBackground(tableHeaderColor);
label.setBorder(BorderFactory.createCompoundBorder(tableCellHeaderBorder, new EmptyBorder(1, 0, 1, 0)));
}
return component;
}
};
getTableHeader().setDefaultRenderer(defaultTableHeaderRenderer);
MouseAdapter mouseListener = new MouseAdapter() {
@Override
public void mouseClicked(final MouseEvent e) {
if (!javaVersion.startsWith("1.5")) {
if (!hasFocus()) {
if (e.getButton() == MouseEvent.BUTTON1) {
addFocusListener(new FocusListener() {
public void focusLost(FocusEvent e) {
}
public void focusGained(FocusEvent e) {
removeFocusListener(this);
Robot robot;
try {
robot = new Robot();
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
} catch (AWTException ex) {
ex.printStackTrace();
}
}
});
}
requestFocusInWindow();
}
}
}
@Override
public void mousePressed(MouseEvent e) {
scrollTableActionManager.triggerPopup(e);
}
@Override
public void mouseReleased(MouseEvent e) {
scrollTableActionManager.triggerPopup(e);
}
@Override
public void mouseEntered(MouseEvent e) {
hoverRow = rowAtPoint(e.getPoint());
hoverColumn = columnAtPoint(e.getPoint());
repaint();
}
@Override
public void mouseExited(MouseEvent e) {
hoverRow = -1;
hoverColumn = -1;
repaint();
}
};
MouseMotionAdapter mouseMotionListener = new MouseMotionAdapter() {
@Override
public void mouseMoved(MouseEvent e) {
hoverRow = rowAtPoint(e.getPoint());
hoverColumn = columnAtPoint(e.getPoint());
repaint();
}
};
addMouseListener(mouseListener);
addMouseMotionListener(mouseMotionListener);
}
Aggregations