public ActionListener addRoomActionListener() {
ActionListener acl = (ActionEvent e) -> {
final String roomNumber = roomNumCmbBox.getSelectedItem().toString();
final String roomType = roomTypeCmbBox.getSelectedItem().toString();
final String currency = currencyCmbBox.getSelectedItem().toString();
final int personCount = (int) personCountSpinner.getValue();
final String val = priceField.getValue().toString();
priceValue = Double.valueOf(val);
Object[] row = new Object[] { roomNumber, roomType, personCount, val, currency };
roomCountModel.addRow(row);
for (int i = 0; i < personCount; i++) {
model.addRow(new Object[] { roomNumber, roomType });
}
};
return acl;
}
java类java.awt.event.ActionListener的实例源码
UpdateReservationWindow.java 文件源码
项目:Hotel-Properties-Management-System
阅读 26
收藏 0
点赞 0
评论 0
VisualizationActionListenerFactory.java 文件源码
项目:Tarski
阅读 35
收藏 0
点赞 0
评论 0
public static ActionListener deleteAtomActionListener() {
return new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
final IMarker marker =
Visualization.getMarker((AlloyAtom) Visualization.rightClickedAnnotation);
final String sigTypeName = marker.getAttribute(MarkUtilities.MARKER_TYPE, "");
final String relUri = marker.getAttribute(MarkUtilities.RELATIVE_URI, "");
Display.getDefault().syncExec(new DeleteAtomCommand(marker));
Visualization.showViz();
AlloyOtherSolutionReasoning.getInstance().finish();
for (final VisualizationChangeListener listener : VisualizationActionListenerFactory.listeners) {
listener.onAtomRemoved(sigTypeName, relUri);
}
}
};
}
HiddenDefaultButtonTest.java 文件源码
项目:openjdk-jdk10
阅读 28
收藏 0
点赞 0
评论 0
private static void createGUI() {
frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JButton button = new JButton("Default button");
button.setDefaultCapable(true);
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ButtonClickCount++;
}
});
frame.add(button);
button.setVisible(false);
frame.getRootPane().setDefaultButton(button);
frame.setSize(200, 200);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
MultiAlgoScenarioWizard.java 文件源码
项目:alevin-svn2
阅读 32
收藏 0
点赞 0
评论 0
/**
* @return {@link JPopupMenu} for manipulating an entry in the network
* table.
*/
private JPopupMenu createContextMenu() {
JPopupMenu menu = new JPopupMenu();
ActionListener listener = new ContextHandler(this);
String[] menuItems = {
CHANGE_GENERATOR_LBL, CHANGE_GENERATOR_ACTN,
CONFIGURE_GENERATOR_LBL, CONFIGURE_GENERATOR_ACTN,
COPY_CONFIGURATION_LBL, COPY_CONFIGURATION_ACTN,
PASTE_CONFIGURATION_LBL, PASTE_CONFIGURATION_ACTN
};
for (int i = 0; i < menuItems.length / 2; i++) {
JMenuItem item = new JMenuItem(menuItems[i*2]);
item.setActionCommand(menuItems[i*2+1]);
item.addActionListener(listener);
menu.add(item);
if (item.getText().equals(PASTE_CONFIGURATION_LBL)) {
this.paste = item;
item.setEnabled(false);
}
}
return menu;
}
CompositeMenuToggleButton.java 文件源码
项目:rapidminer
阅读 25
收藏 0
点赞 0
评论 0
/**
* Adds the given {@link Action}s to the {@link #popupMenu}.
*
* @param actions
* the actions which should be added to the menu
*/
public void addActions(Action... actions) {
for (Action action : actions) {
JRadioButtonMenuItem item = new JRadioButtonMenuItem(action);
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updateSelectionStatus();
}
});
popupMenuGroup.add(item);
popupMenu.add(item);
}
}
Translation.java 文件源码
项目:AgentWorkbench
阅读 28
收藏 0
点赞 0
评论 0
/**
* This method initializes jComboBoxDestinationLang.
* @return javax.swing.JComboBox
*/
private JComboBox<LanguageListElement> getJComboBoxDestinationLang() {
if (jComboBoxDestinationLang == null) {
jComboBoxDestinationLang = new JComboBox<LanguageListElement>();
jComboBoxDestinationLang.setModel(langSelectionModelDestin);
jComboBoxDestinationLang.setPreferredSize(new Dimension(200, 26));
jComboBoxDestinationLang.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (currDataSet!=null) {
jTextFieldDestination.setText((String) currDataSet.get(jComboBoxDestinationLang.getSelectedIndex()+1));
setGoogleTranslation();
}
}
});
}
return jComboBoxDestinationLang;
}
WorldFrame.java 文件源码
项目:AWGW
阅读 29
收藏 0
点赞 0
评论 0
private void configureMenuItem(JMenuItem item, String resource, ActionListener listener) {
configureAbstractButton(item, resource);
item.addActionListener(listener);
try {
String accel = resources.getString(resource + ".accel");
String metaPrefix = "@";
if (accel.startsWith(metaPrefix)) {
int menuMask = getToolkit().getMenuShortcutKeyMask();
KeyStroke key = KeyStroke.getKeyStroke(
KeyStroke.getKeyStroke(accel.substring(metaPrefix.length())).getKeyCode(), menuMask);
item.setAccelerator(key);
} else {
item.setAccelerator(KeyStroke.getKeyStroke(accel));
}
} catch (MissingResourceException ex) {
// no accelerator
}
}
ServerStatusView.java 文件源码
项目:VASSAL-src
阅读 36
收藏 0
点赞 0
评论 0
private void initComponents() {
JPanel current = new JPanel(new BorderLayout());
JToolBar toolbar = new JToolBar();
toolbar.setFloatable(false);
JButton b = new JButton(Resources.getString("Chat.refresh")); //$NON-NLS-1$
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
refresh();
}
});
toolbar.add(b);
current.add(toolbar, BorderLayout.NORTH);
treeCurrent = createTree();
current.add(new JScrollPane(treeCurrent), BorderLayout.CENTER);
model = (DefaultTreeModel) treeCurrent.getModel();
addTab(Resources.getString("Chat.current"), current); //$NON-NLS-1$
addChangeListener(this);
setBorder(new TitledBorder(Resources.getString("Chat.server_connections"))); //$NON-NLS-1$
setStatusServer(status);
}
EncodedEnumeratedType.java 文件源码
项目:JavaGraph
阅读 34
收藏 0
点赞 0
评论 0
public EnumeratedEditor(GrammarModel grammar, Map<String,String> options) {
super(grammar, new FlowLayout(FlowLayout.LEFT, 0, 0));
setBackground(ExplorationDialog.INFO_BG_COLOR);
this.selector = new JComboBox<>();
// MdM - line below causes selector not to appear at all
// this.selector.setMinimumSize(new Dimension(50, 20));
this.selector.setBackground(ExplorationDialog.INFO_BOX_BG_COLOR);
this.selector.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
notifyTemplateListeners();
}
});
this.keys = new String[options.size()];
this.nrKeys = 0;
if (this.nrKeys == 0) {
this.selector.addItem("<HTML><FONT color=red>"
+ "Error! No valid options available." + "</FONT></HTML>");
}
refresh();
add(this.selector);
}
InstallStep.java 文件源码
项目:incubator-netbeans
阅读 33
收藏 0
点赞 0
评论 0
@Messages({
"# {0} - plugin_name",
"inBackground_WritePermission=You don''t have permission to install plugin {0} into the installation directory.",
"inBackground_WritePermission_Details=details", "cancel=Cancel", "install=Install anyway"})
private void notifyWritePermissionProblem(final OperationException ex, final UpdateElement culprit) {
// lack of privileges for writing
ActionListener onMouseClickAction = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
ProblemPanel problem = new ProblemPanel(ex, culprit, false);
problem.showWriteProblemDialog();
}
};
String title = inBackground_WritePermission(culprit.getDisplayName());
String description = inBackground_WritePermission_Details();
NotificationDisplayer.getDefault().notify(title,
ImageUtilities.loadImageIcon("org/netbeans/modules/autoupdate/ui/resources/error.png", false), // NOI18N
description, onMouseClickAction, NotificationDisplayer.Priority.HIGH, NotificationDisplayer.Category.ERROR);
}
PatternPanel.java 文件源码
项目:dead-code-detector
阅读 29
收藏 0
点赞 0
评论 0
private void initButtons() {
final Insets margin = new Insets(2, 2, 2, 2);
addPatternButton.setMargin(margin);
removePatternButton.setMargin(margin);
addPatternButton.setIcon(DcdUiHelper.createIcon("/images/add.gif"));
removePatternButton.setIcon(DcdUiHelper.createIcon("/images/remove.gif"));
addPatternButton.setHorizontalAlignment(SwingConstants.LEADING);
removePatternButton.setHorizontalAlignment(SwingConstants.LEADING);
addPatternButton.setOpaque(false);
removePatternButton.setOpaque(false);
final ActionListener actionHandler = new ActionListener() {
/** {@inheritDoc} */
@Override
public void actionPerformed(ActionEvent event) {
onAction(event);
}
};
addPatternButton.addActionListener(actionHandler);
removePatternButton.addActionListener(actionHandler);
}
ProblemPanel.java 文件源码
项目:incubator-netbeans
阅读 29
收藏 0
点赞 0
评论 0
private DialogDescriptor getNetworkProblemDescriptor() {
DialogDescriptor descriptor = getProblemDesriptor(NbBundle.getMessage(ProblemPanel.class, "CTL_ShowProxyOptions"));
JButton showProxyOptions = new JButton ();
Mnemonics.setLocalizedText (showProxyOptions, NbBundle.getMessage(ProblemPanel.class, "CTL_ShowProxyOptions"));
showProxyOptions.getAccessibleContext ().setAccessibleDescription (NbBundle.getMessage(ProblemPanel.class, "ACSD_ShowProxyOptions"));
showProxyOptions.addActionListener (new ActionListener () {
@Override
public void actionPerformed (ActionEvent arg0) {
OptionsDisplayer.getDefault ().open ("General"); // NOI18N
}
});
if (isWarning) {
descriptor.setAdditionalOptions(new Object [] {showProxyOptions});
}
return descriptor;
}
RunCentralisedMAS.java 文件源码
项目:code-sentinel
阅读 35
收藏 0
点赞 0
评论 0
protected void createPauseButton() {
final JButton btPause = new JButton("Pause", new ImageIcon(RunCentralisedMAS.class.getResource("/images/resume_co.gif")));
btPause.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if (MASConsoleGUI.get().isPause()) {
btPause.setText("Pause");
MASConsoleGUI.get().setPause(false);
} else {
btPause.setText("Continue");
MASConsoleGUI.get().setPause(true);
}
}
});
MASConsoleGUI.get().addButton(btPause);
}
CreateCourseArchivePanel.java 文件源码
项目:educational-plugin
阅读 28
收藏 0
点赞 0
评论 0
public CreateCourseArchivePanel(@NotNull final Project project, CreateCourseArchiveDialog dlg, String name) {
setLayout(new BorderLayout());
add(myPanel, BorderLayout.CENTER);
myErrorIcon.setIcon(AllIcons.Actions.Lightning);
setState(false);
myDlg = dlg;
String sanitizedName = FileUtil.sanitizeFileName(name);
myNameField.setText(sanitizedName.startsWith("_") ? EduNames.COURSE : sanitizedName);
myLocationField.setText(project.getBasePath());
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
myLocationField.addBrowseFolderListener("Choose Location Folder", null, project, descriptor);
myLocationField.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String location = myLocationField.getText();
File file = new File(location);
if (!file.exists() || !file.isDirectory()) {
myDlg.enableOKAction(false);
setError("Invalid location");
}
myDlg.enableOKAction(true);
}
});
}
ProjectWindow.java 文件源码
项目:AgentWorkbench
阅读 30
收藏 0
点赞 0
评论 0
/**
* Returns the JPopupMenu for the tabs.
*
* @return the JPopupMenu
*/
private JPopupMenu getTabPopupMenu() {
JMenuItem jme = new JMenuItem();
if (isMaximizedTab) {
jme.setText(Language.translate("Wiederherstellen"));
} else {
jme.setText(Language.translate("Maximieren"));
}
jme.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (isMaximizedTab) {
currProject.setNotChangedButNotify(Project.VIEW_Restore);
} else {
currProject.setNotChangedButNotify(Project.VIEW_Maximize);
}
}
});
JPopupMenu pop = new JPopupMenu();
pop.add(jme);
return pop;
}
TimeModelContinuousConfiguration.java 文件源码
项目:AgentWorkbench
阅读 31
收藏 0
点赞 0
评论 0
/**
* This method initializes timeFormater
* @return agentgui.simulationService.time.TimeFormatSelection
*/
protected TimeFormatSelection getJPanelTimeFormater() {
if (jPanelTimeFormater == null) {
jPanelTimeFormater = new TimeFormatSelection();
jPanelTimeFormater.setPreferredSize(new Dimension(360, 80));
jPanelTimeFormater.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ae) {
if (enabledChangeListener==true) {
saveTimeModelToSimulationSetup();
}
}
});
}
return jPanelTimeFormater;
}
GUI_ActionListener.java 文件源码
项目:Java-RPG-Maker-MV-Decrypter
阅读 29
收藏 0
点赞 0
评论 0
/**
* Open an Explorer with the given Path
*
* @param directoryPath - Path to open
* @return Open-Explorer ActionListener
*/
static ActionListener openExplorer(String directoryPath) {
return e -> {
Desktop desktop = Desktop.getDesktop();
try {
desktop.open(new java.io.File(File.ensureDSonEndOfPath(directoryPath)).getAbsoluteFile());
} catch(Exception ex) {
ex.printStackTrace();
ErrorWindow errorWindow = new ErrorWindow(
"Unable to open the File-Explorer with the Directory: " + directoryPath,
ErrorWindow.ERROR_LEVEL_ERROR,
false
);
errorWindow.show();
}
};
}
Manager.java 文件源码
项目:ramus
阅读 38
收藏 0
点赞 0
评论 0
private MenuItem createPreferences() {
MenuItem pItem = new MenuItem(getString("Action.Preferences"));
pItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setup();
}
});
return pItem;
}
MainMenuJPanel.java 文件源码
项目:defense-solutions-proofs-of-concept
阅读 34
收藏 0
点赞 0
评论 0
/**
* Called when a waypoint is added. This implementation adds a waypoint button.
* @param graphic the waypoint graphic, whose ID may or may not be populated.
* @param graphicUid the waypoint graphic's ID.
* @see RouteListener#waypointAdded(com.esri.core.map.Graphic, int)
*/
public void waypointAdded(Graphic graphic, int graphicUid) {
final JToggleButton button = new JToggleButton((String) graphic.getAttributeValue("name"));
waypointButtonToGraphicId.put(button, graphicUid);
graphicIdToWaypointButton.put(graphicUid, button);
Font font = new Font("Arial", Font.PLAIN, 18);
button.setFont(font);
button.setFocusable(false);
button.setSelected(false);
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (button == selectedWaypointButton) {
//Unselect
buttonGroup_waypoints.remove(button);
button.setSelected(false);
buttonGroup_waypoints.add(button);
selectedWaypointButton = null;
routeController.setSelectedWaypoint(null);
} else {
selectedWaypointButton = button;
routeController.setSelectedWaypoint(waypointButtonToGraphicId.get(button));
}
}
});
button.setMaximumSize(new Dimension(Integer.MAX_VALUE, 60));
button.setMinimumSize(new Dimension(0, 60));
jPanel_waypointsList.add(button);
buttonGroup_waypoints.add(button);
}
SuiteRunnerLauncher.java 文件源码
项目:phoenix.webui.suite.runner
阅读 29
收藏 0
点赞 0
评论 0
/**
* @param centerPanel
* @param urlList
*/
private static void createItemsPanel(JPanel centerPanel, List<URL> urlList)
{
JPanel itemsPanel = new JPanel();
centerPanel.add(itemsPanel, BorderLayout.CENTER);
if(CollectionUtils.isEmpty(urlList))
{
return;
}
for(URL url : urlList)
{
String text = url.getFile();
JCheckBox box = new JCheckBox(new File(text).getName());
box.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
JCheckBox source = (JCheckBox) e.getSource();
if(source.isSelected())
{
runnerList.add(source.getText());
}
else
{
runnerList.remove(source.getText());
}
}
});
itemsPanel.add(box);
}
}
Dashboard.java 文件源码
项目:java-swing-template
阅读 32
收藏 0
点赞 0
评论 0
/**
* Creates new form Dashboard
*/
public Dashboard() {
initComponents();
Dashboard.this.setExtendedState(JFrame.MAXIMIZED_BOTH);
initButtons();
initBackground();
Utilities.setWindowIcon(Dashboard.this);
Timer t = new Timer(3000, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (new File("updater.exe").exists()) {
Thread th = new Thread(new Runnable() {
@Override
public void run() {
Utilities.runShellCommand(Updator.COMMAND_UPDATECHECK);
}
});
th.start();
} else {
JOptionPane.showMessageDialog(Dashboard.this, "Your software version is not equipped with the automatic update funcationality.\nPlease install the latest software to get updater facility.\nThank you.", "Outdated software", JOptionPane.INFORMATION_MESSAGE);
}
}
});
t.setRepeats(false);
t.start();
}
RadioInplaceEditor.java 文件源码
项目:incubator-netbeans
阅读 35
收藏 0
点赞 0
评论 0
public synchronized void addActionListener(java.awt.event.ActionListener listener) {
if (actionListenerList == null) {
actionListenerList = new java.util.ArrayList<ActionListener>();
}
actionListenerList.add(listener);
}
OtherElementTableCellEditor.java 文件源码
项目:ramus
阅读 35
收藏 0
点赞 0
评论 0
private JButton createEditButton() {
JButton edit = new JButton();
edit.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
edit();
}
});
edit.setIcon(new ImageIcon(getClass().getResource(
"/com/ramussoft/gui/edit.png")));
edit.setToolTipText(GlobalResourcesManager.getString("edit"));
edit.setFocusable(false);
edit.setPreferredSize(new Dimension(16, 16));
return edit;
}
InfoPanel.java 文件源码
项目:GameOfSet
阅读 37
收藏 0
点赞 0
评论 0
private JButton createAddButton() {
JButton button = new JButton("ADD");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
mainFrame.flipThreeMoreCards();
}
});
return button;
}
ErrorDialog.java 文件源码
项目:GitHub
阅读 33
收藏 0
点赞 0
评论 0
public ErrorDialog(String errorInfo) {
setContentPane(contentPane);
setTitle("Error Info");
getRootPane().setDefaultButton(okButton);
this.setAlwaysOnTop(true);
editTP.setText(errorInfo);
okButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dispose();
}
});
editTP.setCaretPosition(0);
}
RRDraw.java 文件源码
项目:XiaomiRobotVacuumProtocol
阅读 24
收藏 0
点赞 0
评论 0
public RRDraw() {
super("File View Test Frame");
setSize(350, 400);
setDefaultCloseOperation(EXIT_ON_CLOSE);
parent = this;
rrDrawPanel = new RRDrawPanel();
Container c = getContentPane();
// The default BorderLayout will work better.
// c.setLayout(new FlowLayout());
JButton openButton = new JButton("Open");
final JLabel statusbar = new JLabel("Output of your selection will go here");
openButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ae) {
JFileChooser chooser = new JFileChooser("images");
int option = chooser.showOpenDialog(parent);
if (option == JFileChooser.APPROVE_OPTION) {
File file = chooser.getSelectedFile();
BufferedImage loadImage = loadImage(file);
statusbar.setText(file.getName() + " size " + loadImage.getWidth() + "x" + loadImage.getHeight());
// setSize(loadImage.getWidth(), loadImage.getHeight());
rrDrawPanel.setSize(loadImage.getHeight(), loadImage.getWidth());
} else {
statusbar.setText("You cancelled.");
}
}
});
JPanel north = new JPanel();
north.add(openButton);
north.add(statusbar);
north.setBackground(Color.GRAY);
north.setForeground(Color.BLUE);
c.add(north, "First");
c.add(new JScrollPane(rrDrawPanel), "Center");
}
SimulationTreePanel.java 文件源码
项目:featurea
阅读 33
收藏 0
点赞 0
评论 0
/**
* Notifies all the action listeners of the event.
*
* @param command the command
*/
private void notifyActionListeners(String command) {
ActionListener[] listeners = this.getListeners(ActionListener.class);
int size = listeners.length;
ActionEvent event = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, command);
for (int i = 0; i < size; i++) {
listeners[i].actionPerformed(event);
}
}
NBTabbedPane.java 文件源码
项目:incubator-netbeans
阅读 27
收藏 0
点赞 0
评论 0
/**
* Used by Controller to post action events for selection and close
* operations. If the event is consumed, the UI should take no action to
* change the selection or close the tab, and will presume that the receiver
* of the event is handling performing whatever action is appropriate.
*
* @param event The event to be fired
*/
protected final void postActionEvent( TabActionEvent event ) {
List<ActionListener> list;
synchronized( this ) {
if( actionListenerList == null ) {
return;
}
list = Collections.unmodifiableList( actionListenerList );
}
for( ActionListener l : list ) {
l.actionPerformed( event );
}
}
LogAxisPlotDemo.java 文件源码
项目:jtk
阅读 38
收藏 0
点赞 0
评论 0
public static JButton limitsTestButton(final PlotPanel plot){
JButton b = new JButton("setLimits Test");
b.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
plot.setLimits(10,20,100,1000);
}
});
return b;
}
EmployeeView.java 文件源码
项目:DocIT
阅读 35
收藏 0
点赞 0
评论 0
public void showEmployee(Employee employee) {
frame.setTitle("Employee \"" + employee.getName() + "\"");
nameField.setText(employee.getName());
addressField.setText(employee.getAddress());
salaryField.setText(Double.toString(employee.getSalary()));
for (ActionListener al : cutButton.getActionListeners())
cutButton.removeActionListener(al);
cutButton.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
controller.cutEmployeeClicked();
}
});
frame.setVisible(true);
}