use of javax.swing.AbstractButton in project jdk8u_jdk by JetBrains.
the class Test6524757 method create.
private static Object[] create() {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
frame.setVisible(true);
// show color chooser
JColorChooser chooser = new JColorChooser();
JDialog dialog = JColorChooser.createDialog(frame, null, false, chooser, null, null);
dialog.setVisible(true);
// process all values
List<Object> list = new ArrayList<Object>(KEYS.length);
Component component = getC(getC(dialog.getLayeredPane(), 0), 1);
AbstractButton ok = (AbstractButton) getC(component, 0);
AbstractButton cancel = (AbstractButton) getC(component, 1);
AbstractButton reset = (AbstractButton) getC(component, 2);
list.add(ok.getText());
list.add(cancel.getText());
list.add(reset.getText());
list.add(Integer.valueOf(reset.getMnemonic()));
for (int i = 0; i < 5; i++) {
AbstractColorChooserPanel panel = (AbstractColorChooserPanel) getC(getC(getC(chooser, 0), i), 0);
list.add(panel.getDisplayName());
list.add(Integer.valueOf(panel.getMnemonic()));
if (i == 0) {
JLabel label = (JLabel) getC(getC(panel, 0), 1);
JPanel upper = (JPanel) getC(getC(getC(panel, 0), 0), 0);
JPanel lower = (JPanel) getC(getC(getC(panel, 0), 2), 0);
addSize(list, upper, 1, 1, 31, 9);
list.add(label.getText());
addSize(list, lower, 1, 1, 5, 7);
} else {
Component container = getC(panel, 0);
for (int j = 0; j < 3; j++) {
AbstractButton button = (AbstractButton) getC(container, j);
list.add(button.getText());
}
JLabel label = (JLabel) getC(container, 3);
list.add(label.getText());
if (i == 4) {
label = (JLabel) getC(container, 4);
list.add(label.getText());
}
if (i == 3) {
label = (JLabel) getC(panel, 1);
list.add(label.getText());
list.add(Integer.valueOf(label.getDisplayedMnemonic()));
}
}
}
// close dialog
dialog.setVisible(false);
dialog.dispose();
// close frame
frame.setVisible(false);
frame.dispose();
return list.toArray();
}
use of javax.swing.AbstractButton in project jdk8u_jdk by JetBrains.
the class bug7199708 method main.
public static void main(String[] args) throws Exception {
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(50);
final File folder = createLargeFolder();
UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
SwingUtilities.invokeLater(new Runnable() {
public void run() {
fileChooser = new JFileChooser(folder);
fileChooser.showSaveDialog(null);
}
});
toolkit.realSync();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
final String detailsTooltip = UIManager.getString("FileChooser." + "detailsViewButtonToolTipText", fileChooser.getLocale());
doAction(fileChooser, new ComponentAction() {
@Override
public boolean accept(Component component) {
return (component instanceof AbstractButton) && detailsTooltip.equals(((AbstractButton) component).getToolTipText());
}
@Override
public void perform(Component component) {
((AbstractButton) component).doClick();
}
});
doAction(fileChooser, new ComponentAction() {
@Override
public boolean accept(Component component) {
return (component instanceof JTable);
}
@Override
public void perform(Component component) {
Point tableLocation = component.getLocationOnScreen();
locationX = (int) tableLocation.getX();
locationY = (int) tableLocation.getY();
width = (int) fileChooser.getBounds().getWidth();
}
});
}
});
toolkit.realSync();
int d = 25;
for (int i = 0; i < width / d; i++) {
robot.mouseMove(locationX + i * d, locationY + 5);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
toolkit.realSync();
}
robot.keyPress(KeyEvent.VK_ESCAPE);
robot.keyRelease(KeyEvent.VK_ESCAPE);
}
use of javax.swing.AbstractButton in project JMRI by JMRI.
the class JmriJFrameServlet method sendClick.
void sendClick(String name, Component c, int xg, int yg, Container FrameContentPane) {
// global positions
int x = xg - c.getLocation().x;
int y = yg - c.getLocation().y;
// log.debug("component is {}", c);
log.debug("Local click at {},{}", x, y);
if (c.getClass().equals(JButton.class)) {
((AbstractButton) c).doClick();
} else if (c.getClass().equals(JCheckBox.class)) {
((AbstractButton) c).doClick();
} else if (c.getClass().equals(JRadioButton.class)) {
((AbstractButton) c).doClick();
} else if (MouseListener.class.isAssignableFrom(c.getClass())) {
log.debug("Invoke directly on MouseListener, at {},{}", x, y);
sendClickSequence((MouseListener) c, c, x, y);
} else if (c instanceof jmri.jmrit.display.MultiSensorIcon) {
log.debug("Invoke Clicked on MultiSensorIcon");
MouseEvent e = new MouseEvent(c, MouseEvent.MOUSE_CLICKED, // time
0, // modifiers
0, // this component expects global positions for some reason
xg, // this component expects global positions for some reason
yg, // one click
1, // not a popup
false);
((Positionable) c).doMouseClicked(e);
} else if (Positionable.class.isAssignableFrom(c.getClass())) {
log.debug("Invoke Pressed, Released and Clicked on Positionable");
MouseEvent e = new MouseEvent(c, MouseEvent.MOUSE_PRESSED, // time
0, // modifiers
0, // x, y not in this component?
x, // x, y not in this component?
y, // one click
1, // not a popup
false);
((jmri.jmrit.display.Positionable) c).doMousePressed(e);
e = new MouseEvent(c, MouseEvent.MOUSE_RELEASED, // time
0, // modifiers
0, // x, y not in this component?
x, // x, y not in this component?
y, // one click
1, // not a popup
false);
((jmri.jmrit.display.Positionable) c).doMouseReleased(e);
e = new MouseEvent(c, MouseEvent.MOUSE_CLICKED, // time
0, // modifiers
0, // x, y not in this component?
x, // x, y not in this component?
y, // one click
1, // not a popup
false);
((jmri.jmrit.display.Positionable) c).doMouseClicked(e);
} else {
MouseListener[] la = c.getMouseListeners();
log.debug("Invoke {} contained mouse listeners", la.length);
log.debug("component is {}", c);
// y -= (int)(pc.getY() - pf.getY());
for (MouseListener ml : la) {
log.debug("Send click sequence at {},{}", x, y);
sendClickSequence(ml, c, x, y);
}
}
}
use of javax.swing.AbstractButton in project pcgen by PCGen.
the class OptionsPathDialog method addRadioButton.
private void addRadioButton(String text, String command, ButtonGroup group, ActionListener listener, GridBagConstraints gbc) {
boolean selected = command.equals(selectedDir);
if (selected) {
//for i18n this will need to be handled differently
text += " (default)";
}
AbstractButton rButton = new JRadioButton(text);
rButton.setActionCommand(command);
rButton.setSelected(selected);
rButton.addActionListener(listener);
group.add(rButton);
getContentPane().add(rButton, gbc);
}
use of javax.swing.AbstractButton in project pcgen by PCGen.
the class WriteDirectoryPanel method setupDisplay.
@Override
public void setupDisplay(JPanel panel, final CDOMObject pc) {
panel.setLayout(layout);
Component label = new JLabel("Please select the Directory where Converted files should be written: ");
AbstractButton button = new JButton("Browse...");
button.setMnemonic('r');
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
JFileChooser chooser = new JFileChooser();
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
chooser.setDialogType(JFileChooser.OPEN_DIALOG);
chooser.setCurrentDirectory(path.getParentFile());
chooser.setSelectedFile(path);
while (true) {
int open = chooser.showOpenDialog(null);
if (open == JFileChooser.APPROVE_OPTION) {
File fileToOpen = chooser.getSelectedFile();
if (fileToOpen.isDirectory() && fileToOpen.canRead() && fileToOpen.canWrite()) {
path = fileToOpen;
pc.put(ObjectKey.WRITE_DIRECTORY, path);
fileLabel.setText(path.getAbsolutePath());
PCGenSettings context = PCGenSettings.getInstance();
context.setProperty(PCGenSettings.CONVERT_OUTPUT_SAVE_PATH, path.getAbsolutePath());
showWarning();
break;
}
JOptionPane.showMessageDialog(null, "Selection must be a valid " + "(readable & writeable) Directory");
chooser.setCurrentDirectory(path.getParentFile());
} else if (open == JFileChooser.CANCEL_OPTION) {
break;
}
}
}
});
panel.add(label);
panel.add(fileLabel);
panel.add(button);
panel.add(warningLabel);
showWarning();
layout.putConstraint(SpringLayout.NORTH, label, 50, SpringLayout.NORTH, panel);
layout.putConstraint(SpringLayout.NORTH, fileLabel, 75 + label.getPreferredSize().height, SpringLayout.NORTH, panel);
layout.putConstraint(SpringLayout.NORTH, button, 75 + label.getPreferredSize().height, SpringLayout.NORTH, panel);
layout.putConstraint(SpringLayout.WEST, label, 25, SpringLayout.WEST, panel);
layout.putConstraint(SpringLayout.WEST, fileLabel, 25, SpringLayout.WEST, panel);
layout.putConstraint(SpringLayout.EAST, button, -50, SpringLayout.EAST, panel);
layout.putConstraint(SpringLayout.NORTH, warningLabel, 20, SpringLayout.SOUTH, fileLabel);
layout.putConstraint(SpringLayout.WEST, warningLabel, 25, SpringLayout.WEST, panel);
fileLabel.setText(path.getAbsolutePath());
}
Aggregations