use of java.awt.event.ActionEvent in project neo4j by neo4j.
the class MainWindow method createStopButton.
private JButton createStopButton() {
return Components.createTextButton("Stop", new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updateStatus(DatabaseStatus.STOPPING);
invokeLater(new Runnable() {
@Override
public void run() {
databaseActions.stop();
updateStatus(STOPPED);
}
});
}
});
}
use of java.awt.event.ActionEvent in project neo4j by neo4j.
the class SysTray method setupTrayIcon.
private void setupTrayIcon() {
PopupMenu popUpMenu = createPopupMenu();
trayIcon.setPopupMenu(popUpMenu);
trayIcon.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
listener.open();
}
});
trayIcon.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
listener.open();
}
});
}
use of java.awt.event.ActionEvent in project jphp by jphp-compiler.
the class UIElement method setAction.
@Signature({ @Arg("name"), @Arg(value = "callback", type = HintType.CALLABLE, optional = @Optional("null")) })
public Memory setAction(Environment env, Memory... args) {
if (args[1].isNull()) {
getJComponent().getActionMap().remove(args[0].toString());
return Memory.NULL;
}
final Invoker invoker = Invoker.valueOf(env, null, args[1]);
getJComponent().getActionMap().put(args[0].toString(), new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
invoker.callNoThrow();
}
});
return Memory.NULL;
}
use of java.awt.event.ActionEvent in project zaproxy by zaproxy.
the class CertificateView method initComponents.
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
private void initComponents() {
closeButton = new JButton();
certificateScrollPane = new JScrollPane();
certificateTextArea = new ZapTextArea();
//TODO: Constant for messages.properties
setTitle("Certificate");
//TODO: Constant for messages.properties
closeButton.setText("Close");
closeButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
closeButtonActionPerformed(evt);
}
});
certificateScrollPane.setViewportView(certificateTextArea);
GroupLayout layout = new GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING).addComponent(closeButton, GroupLayout.PREFERRED_SIZE, 93, GroupLayout.PREFERRED_SIZE).addComponent(certificateScrollPane, GroupLayout.DEFAULT_SIZE, 658, Short.MAX_VALUE)).addContainerGap()));
layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap().addComponent(certificateScrollPane, GroupLayout.DEFAULT_SIZE, 439, Short.MAX_VALUE).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(closeButton).addContainerGap()));
pack();
}
use of java.awt.event.ActionEvent in project pcgen by PCGen.
the class SourceSelectionPanel method setupDisplay.
@Override
public void setupDisplay(JPanel panel, final CDOMObject pc) {
panel.setLayout(new GridBagLayout());
JLabel label = new JLabel("Please select the Source Directory to Convert: ");
GridBagConstraints gbc = new GridBagConstraints();
Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 1.0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTHWEST);
gbc.insets = new Insets(50, 25, 10, 25);
panel.add(label, gbc);
JButton button = new JButton("Browse...");
button.setMnemonic('r');
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
JFileChooser chooser = new JFileChooser(SourceFolder.OTHER.getFile());
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
chooser.setDialogType(JFileChooser.OPEN_DIALOG);
chooser.setSelectedFile(path);
while (true) {
int open = chooser.showOpenDialog(null);
if (open == JFileChooser.APPROVE_OPTION) {
File fileToOpen = chooser.getSelectedFile();
if (fileToOpen.isDirectory()) {
path = fileToOpen;
SourceFolder.OTHER.setFile(fileToOpen);
pc.put(ObjectKey.DIRECTORY, path);
PCGenSettings context = PCGenSettings.getInstance();
context.setProperty(PCGenSettings.CONVERT_INPUT_PATH, path.getAbsolutePath());
JRadioButton button = radioButtons[SourceFolder.OTHER.ordinal()];
button.setSelected(true);
button.setText(buildFolderText(SourceFolder.OTHER, fileToOpen.getAbsolutePath()));
break;
}
JOptionPane.showMessageDialog(null, "Selection must be a valid Directory");
chooser.setSelectedFile(path);
} else if (open == JFileChooser.CANCEL_OPTION) {
break;
}
}
}
});
radioButtons = new JRadioButton[SourceFolder.values().length];
String selectedPath = null;
File selectedFile = pc.get(ObjectKey.DIRECTORY);
if (selectedFile != null) {
selectedPath = selectedFile.getAbsolutePath();
} else {
PCGenSettings context = PCGenSettings.getInstance();
selectedPath = context.getProperty(PCGenSettings.CONVERT_INPUT_PATH, null);
}
ButtonGroup group = new ButtonGroup();
boolean haveSelected = false;
Font font = panel.getFont();
font = FontManipulation.plain(font);
for (SourceFolder folder : SourceFolder.values()) {
JRadioButton pathButton = new JRadioButton();
final SourceFolder buttonFolder = folder;
pathButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
PCGenSettings context = PCGenSettings.getInstance();
context.setProperty(PCGenSettings.CONVERT_INPUT_PATH, buttonFolder.getFile().getAbsolutePath());
pc.put(ObjectKey.DIRECTORY, buttonFolder.getFile());
}
});
String path;
if (folder.getFile() == null) {
path = "Undefined";
pathButton.setEnabled(false);
} else {
path = folder.getFile().getAbsolutePath();
if (path.equals(selectedPath)) {
pathButton.setSelected(true);
haveSelected = true;
PCGenSettings context = PCGenSettings.getInstance();
context.setProperty(PCGenSettings.CONVERT_INPUT_PATH, path);
selectedFile = folder.getFile();
}
}
pathButton.setText(buildFolderText(folder, path));
pathButton.setFont(font);
radioButtons[folder.ordinal()] = pathButton;
group.add(pathButton);
if (folder == SourceFolder.OTHER) {
Utility.buildRelativeConstraints(gbc, 1, GridBagConstraints.REMAINDER, 1.0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTHWEST);
} else {
Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 1.0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTHWEST);
}
gbc.insets = new Insets(10, 25, 10, 25);
panel.add(pathButton, gbc);
if (folder == SourceFolder.OTHER) {
Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.NORTHEAST);
gbc.insets = new Insets(10, 25, 10, 25);
panel.add(button, gbc);
}
}
Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, GridBagConstraints.REMAINDER, 1.0, 1.0, GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST);
panel.add(new JLabel(" "), gbc);
if (!haveSelected) {
if (selectedPath != null) {
JRadioButton btn = radioButtons[SourceFolder.OTHER.ordinal()];
btn.setSelected(true);
selectedFile = new File(selectedPath);
SourceFolder.OTHER.setFile(selectedFile);
path = selectedFile;
btn.setText(buildFolderText(SourceFolder.OTHER, selectedFile.getAbsolutePath()));
} else if (radioButtons[SourceFolder.VENDORDATA.ordinal()].isEnabled()) {
JRadioButton btn = radioButtons[SourceFolder.VENDORDATA.ordinal()];
btn.setSelected(true);
selectedFile = SourceFolder.VENDORDATA.getFile();
} else if (radioButtons[SourceFolder.HOMEBREWDATA.ordinal()].isEnabled()) {
JRadioButton btn = radioButtons[SourceFolder.HOMEBREWDATA.ordinal()];
btn.setSelected(true);
selectedFile = SourceFolder.HOMEBREWDATA.getFile();
} else {
JRadioButton btn = radioButtons[SourceFolder.DATA.ordinal()];
btn.setSelected(true);
selectedFile = SourceFolder.DATA.getFile();
}
}
pc.put(ObjectKey.DIRECTORY, selectedFile);
}
Aggregations