Java Code Examples for java.awt.event.ActionListener

The following are top voted examples for showing how to use java.awt.event.ActionListener. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Hotel-Properties-Management-System   File: UpdateReservationWindow.java   View source code 6 votes vote down vote up
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;
}
 
Example 2
Project: Tarski   File: VisualizationActionListenerFactory.java   View source code 6 votes vote down vote up
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);
      }
    }
  };
}
 
Example 3
Project: openjdk-jdk10   File: HiddenDefaultButtonTest.java   View source code 6 votes vote down vote up
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);
}
 
Example 4
Project: alevin-svn2   File: MultiAlgoScenarioWizard.java   View source code 6 votes vote down vote up
/**
 * @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;
}
 
Example 5
Project: rapidminer   File: CompositeMenuToggleButton.java   View source code 6 votes vote down vote up
/**
 * 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);
	}
}
 
Example 6
Project: AgentWorkbench   File: Translation.java   View source code 6 votes vote down vote up
/**
 * 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;
}
 
Example 7
Project: AWGW   File: WorldFrame.java   View source code 6 votes vote down vote up
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
    }
}
 
Example 8
Project: VASSAL-src   File: ServerStatusView.java   View source code 6 votes vote down vote up
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);
}
 
Example 9
Project: JavaGraph   File: EncodedEnumeratedType.java   View source code 6 votes vote down vote up
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);
}
 
Example 10
Project: incubator-netbeans   File: InstallStep.java   View source code 6 votes vote down vote up
@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);
}
 
Example 11
Project: dead-code-detector   File: PatternPanel.java   View source code 6 votes vote down vote up
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);
}
 
Example 12
Project: incubator-netbeans   File: ProblemPanel.java   View source code 6 votes vote down vote up
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;
}
 
Example 13
Project: code-sentinel   File: RunCentralisedMAS.java   View source code 6 votes vote down vote up
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);
}
 
Example 14
Project: educational-plugin   File: CreateCourseArchivePanel.java   View source code 6 votes vote down vote up
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);
    }
  });
}
 
Example 15
Project: AgentWorkbench   File: ProjectWindow.java   View source code 6 votes vote down vote up
/**
 * 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;

}
 
Example 16
Project: AgentWorkbench   File: TimeModelContinuousConfiguration.java   View source code 6 votes vote down vote up
/**
 * 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;
}
 
Example 17
Project: Java-RPG-Maker-MV-Decrypter   File: GUI_ActionListener.java   View source code 6 votes vote down vote up
/**
 * 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();
		}
	};
}
 
Example 18
Project: ramus   File: Manager.java   View source code 5 votes vote down vote up
private MenuItem createPreferences() {
    MenuItem pItem = new MenuItem(getString("Action.Preferences"));
    pItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setup();
        }
    });
    return pItem;
}
 
Example 19
Project: defense-solutions-proofs-of-concept   File: MainMenuJPanel.java   View source code 5 votes vote down vote up
/**
 * 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);
}
 
Example 20
Project: phoenix.webui.suite.runner   File: SuiteRunnerLauncher.java   View source code 5 votes vote down vote up
/**
 * @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);
	}
}
 
Example 21
Project: java-swing-template   File: Dashboard.java   View source code 5 votes vote down vote up
/**
 * 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();
}
 
Example 22
Project: incubator-netbeans   File: RadioInplaceEditor.java   View source code 5 votes vote down vote up
public synchronized void addActionListener(java.awt.event.ActionListener listener) {
    if (actionListenerList == null) {
        actionListenerList = new java.util.ArrayList<ActionListener>();
    }

    actionListenerList.add(listener);
}
 
Example 23
Project: ramus   File: OtherElementTableCellEditor.java   View source code 5 votes vote down vote up
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;
}
 
Example 24
Project: GameOfSet   File: InfoPanel.java   View source code 5 votes vote down vote up
private JButton createAddButton() {
    JButton button = new JButton("ADD");
    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            mainFrame.flipThreeMoreCards();
        }
    });
    return button;
}
 
Example 25
Project: GitHub   File: ErrorDialog.java   View source code 5 votes vote down vote up
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);

}
 
Example 26
Project: XiaomiRobotVacuumProtocol   File: RRDraw.java   View source code 5 votes vote down vote up
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");

}
 
Example 27
Project: featurea   File: SimulationTreePanel.java   View source code 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example 28
Project: incubator-netbeans   File: NBTabbedPane.java   View source code 5 votes vote down vote up
/**
 * 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 );
    }
}
 
Example 29
Project: jtk   File: LogAxisPlotDemo.java   View source code 5 votes vote down vote up
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;
}
 
Example 30
Project: DocIT   File: EmployeeView.java   View source code 5 votes vote down vote up
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);
}
 
Example 31
Project: incubator-netbeans   File: BasicReplaceResultsPanel.java   View source code 5 votes vote down vote up
private void init() {
    JPanel leftPanel = new JPanel();
    replaceButton = new JButton();
    replaceButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            replace();
        }
    });
    updateReplaceButton();
    leftPanel.setLayout(new BoxLayout(leftPanel, BoxLayout.PAGE_AXIS));
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new FlowLayout(FlowLayout.LEADING, 2, 1));
    buttonPanel.add(replaceButton);
    replaceButton.setMaximumSize(replaceButton.getPreferredSize());
    buttonPanel.setMaximumSize(new Dimension( // #225246
            (int) buttonPanel.getMaximumSize().getWidth(),
            (int) buttonPanel.getPreferredSize().getHeight()));
    leftPanel.add(resultsOutlineSupport.getOutlineView());
    leftPanel.add(buttonPanel);

    this.splitPane = new JSplitPane();
    splitPane.setLeftComponent(leftPanel);
    splitPane.setRightComponent(new ContextView(resultModel,
            getExplorerManager()));
    initSplitDividerLocationHandling();

    getContentPanel().add(splitPane);
    initResultModelListener();
    replaceButton.getAccessibleContext().setAccessibleDescription(
            NbBundle.getMessage(ResultView.class,
            "ACS_TEXT_BUTTON_REPLACE"));                            //NOI18N
}
 
Example 32
Project: incubator-netbeans   File: PropertiesDataNode.java   View source code 5 votes vote down vote up
/** Overrides superclass method. */
@Override
public void create() throws IOException {
    final PropertiesDataObject propertiesDataObject =
                      (PropertiesDataObject)getCookie(DataObject.class);

    final Dialog[] dialog = new Dialog[1];
    final LocalePanel panel = new LocalePanel();

    DialogDescriptor dialogDescriptor = new DialogDescriptor(
        panel,
        NbBundle.getBundle(PropertiesDataNode.class).getString("CTL_NewLocaleTitle"),
        true,
        DialogDescriptor.OK_CANCEL_OPTION,
        DialogDescriptor.OK_OPTION,
        new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent evt) {
                if (evt.getSource() == DialogDescriptor.OK_OPTION) {
                    if (containsLocale(propertiesDataObject, panel.getLocale())) {
                        NotifyDescriptor.Message msg = new NotifyDescriptor.Message(
                            MessageFormat.format(NbBundle.getBundle(PropertiesDataNode.class).getString("MSG_LangExists"), panel.getLocale()), 
                            NotifyDescriptor.ERROR_MESSAGE);
                        DialogDisplayer.getDefault().notify(msg);
                    } else {
                        Util.createLocaleFile(propertiesDataObject, panel.getLocale().toString(), true);
                        dialog[0].setVisible(false);
                        dialog[0].dispose();
                    }
                }
            }
        }
    );
    dialogDescriptor.setClosingOptions(new Object [] { DialogDescriptor.CANCEL_OPTION });
    
    dialog[0] = DialogDisplayer.getDefault().createDialog(dialogDescriptor);
    dialog[0].setVisible(true);
}
 
Example 33
Project: KernelHive   File: MainFrame.java   View source code 5 votes vote down vote up
private void initHelpMenu() {
	mnHelp = new JMenu(BUNDLE.getString("MainFrame.mnHelp.text"));
	mnHelp.setMnemonic(KeyEvent.VK_H);
	mainMenuBar.add(mnHelp);

	// mntmContents = new
	// JMenuItem(BUNDLE.getString("MainFrame.mntmContents.text"));
	// mntmContents.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1,
	// 0));
	// mntmContents.setIcon(new
	// ImageIcon(MainFrame.class.getResource("/toolbarButtonGraphics/general/About16.gif")));
	// mntmContents.addActionListener(new ActionListener() {
	//
	// @Override
	// public void actionPerformed(ActionEvent e) {
	// // TODO Auto-generated method stub
	//
	// }
	// });
	// mnHelp.add(mntmContents);

	mntmAbout = new JMenuItem(BUNDLE.getString("MainFrame.mntmAbout.text"));
	mntmAbout
			.setIcon(new ImageIcon(
					MainFrame.class
							.getResource("/toolbarButtonGraphics/general/Information16.gif")));
	mntmAbout.addActionListener(new ActionListener() {

		@Override
		public void actionPerformed(final ActionEvent e) {
			controller.openAboutDialog();
		}
	});
	mnHelp.add(mntmAbout);
}
 
Example 34
Project: openjdk-jdk10   File: bug8025082.java   View source code 5 votes vote down vote up
private static void createUI() {
    frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(500, 500);
    JTextPane textpane = new JTextPane();
    textpane.setText("Select Me");
    textpane.selectAll();

    JPanel panel = new JPanel(new BorderLayout());
    panel.add(textpane, BorderLayout.CENTER);
    button = new JButton("Press Me");
    panel.add(button, BorderLayout.SOUTH);

    button.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (!textpane.getCaret().isSelectionVisible()) {
                throw new RuntimeException("Highlight removed after "
                        + "button click");
            }
        }
    });

    frame.getContentPane().add(panel);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
}
 
Example 35
Project: incubator-netbeans   File: TreeList.java   View source code 5 votes vote down vote up
public TreeList(TreeListModel model) {
    super(model);
    setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    setFixedCellHeight(ROW_HEIGHT + INSETS_TOP + INSETS_BOTTOM + 2);
    setCellRenderer(renderer);
    setBackground(ColorManager.getDefault().getDefaultBackground());
    ToolTipManager.sharedInstance().registerComponent(this);
    addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() != 2 || e.isPopupTrigger() || e.isConsumed()) {
                return;
            }
            int index = locationToIndex(e.getPoint());
            if (index < 0 || index >= getModel().getSize()) {
                return;
            }
            Object value = getModel().getElementAt(index);
            if (value instanceof TreeListNode) {
                TreeListNode node = (TreeListNode) value;

                if (null != node && !node.isExpandable()) {
                    ActionListener al = node.getDefaultAction();
                    if (null != al) {
                        al.actionPerformed(new ActionEvent(e.getSource(), e.getID(), e.paramString()));
                    }
                } else if (null != node && node.isExpandable()) {
                    if (!node.isLoaded()) {
                        return;
                    }
                    node.setExpanded(!node.isExpanded());
                }
            }
        }
    });
}
 
Example 36
Project: cuttlefish   File: StatusBar.java   View source code 5 votes vote down vote up
public StatusBar() {
	super();
	this.setBackground(Color.WHITE);
	terminateTask = new JButton("Stop");
	label = new JLabel();
	label1 = new JLabel("Status ");
	progressBar = new JProgressBar();
	progressBar.setMinimum(50);
	progressBar.setMaximum(100);
	add(label1);
	add(progressBar);
	add(label);		
	add(terminateTask);
	setMessage("Ready");
	
	terminateTask.addActionListener(new ActionListener() {			
		@Override
		public void actionPerformed(ActionEvent e) {
			if(currentTask == null)
				return;
			currentTask.cancel(true);
			setMessage("Task canceled");
			terminateTask.setEnabled(false);
		}
	});
	
}
 
Example 37
Project: ZooKeeper   File: NodeViewerData.java   View source code 5 votes vote down vote up
/**
* 
*/
  public NodeViewerData() {
      this.setLayout(new BorderLayout());
      this.dataArea = new JTextPane();
      this.toolbar = new JToolBar();
      this.toolbar.setFloatable(false);
      JScrollPane scroller = new JScrollPane(this.dataArea);
      scroller
              .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
      this.add(scroller, BorderLayout.CENTER);
      this.add(this.toolbar, BorderLayout.NORTH);
      JButton saveButton = new JButton(ZooInspectorIconResources
              .getSaveIcon());
      saveButton.addActionListener(new ActionListener() {

          public void actionPerformed(ActionEvent e) {
              if (selectedNode != null) {
                  if (JOptionPane.showConfirmDialog(NodeViewerData.this,
                          "Are you sure you want to save this node?"
                                  + " (this action cannot be reverted)",
                          "Confirm Save", JOptionPane.YES_NO_OPTION,
                          JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) {
                      zooInspectorManager.setData(selectedNode, dataArea
                              .getText());
                  }
              }
          }
      });
      this.toolbar.add(saveButton);

  }
 
Example 38
Project: openjdk-jdk10   File: Test6179222.java   View source code 5 votes vote down vote up
public static void main(String[] args) {
    Test6179222 test = new Test6179222();
    // test 6179222
    test(EventHandler.create(ActionListener.class, test, "foo", "source.icon"));
    // test 6265540
    test(EventHandler.create(ActionListener.class, test, "bar.doit"));
    if (!test.bar.invoked) {
        throw new Error("Bar was not set");
    }
}
 
Example 39
Project: incubator-netbeans   File: QueryParameter.java   View source code 5 votes vote down vote up
public CheckBoxParameter(JCheckBox chk, String parameter, String encoding) {
    super(parameter, encoding);
    this.chk = chk;
    chk.addActionListener(new ActionListener(){
        @Override
        public void actionPerformed(ActionEvent e) {
            fireStateChanged();
        }
    });
    original = chk.isSelected();
}
 
Example 40
Project: Tarski   File: VisualizationActionListenerFactory.java   View source code 5 votes vote down vote up
public static ActionListener interpretAtomMenuItemActionListener() {
  return new ActionListener() {

    IMarker selectedMarker;

    @Override
    public void actionPerformed(final ActionEvent e) {
      final AlloyAtom alloyAtom = (AlloyAtom) Visualization.rightClickedAnnotation;

      showWizard();
      if (selectedMarker == null) {
        return;
      }

      final String sigTypeName = alloyAtom.getType().getName();
      final String stringIndex = alloyAtom.toString().substring(sigTypeName.length());
      int index = 0;
      if (!stringIndex.isEmpty()) {
        index = Integer.parseInt(stringIndex);
      }

      AlloyUtilities.bindAtomToMarker(sigTypeName, index, selectedMarker);
      Visualization.showViz();
    }

    private void showWizard() {
      Display.getDefault().syncExec(new Runnable() {
        @Override
        public void run() {
          final InterpretationWizard wizard = new InterpretationWizard();
          final WizardDialog dialog = new WizardDialog(
              Activator.getDefault().getWorkbench().getWorkbenchWindows()[0].getShell(), wizard);
          dialog.open();
          selectedMarker = wizard.getSelectedMarker();
        }
      });
    }
  };
}