当前位置: 首页>>代码示例>>Java>>正文


Java ActionListener类代码示例

本文整理汇总了Java中java.awt.event.ActionListener的典型用法代码示例。如果您正苦于以下问题:Java ActionListener类的具体用法?Java ActionListener怎么用?Java ActionListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ActionListener类属于java.awt.event包,在下文中一共展示了ActionListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addRoomActionListener

import java.awt.event.ActionListener; //导入依赖的package包/类
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;
}
 
开发者ID:Coder-ACJHP,项目名称:Hotel-Properties-Management-System,代码行数:19,代码来源:UpdateReservationWindow.java

示例2: deleteAtomActionListener

import java.awt.event.ActionListener; //导入依赖的package包/类
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);
      }
    }
  };
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:18,代码来源:VisualizationActionListenerFactory.java

示例3: initialize

import java.awt.event.ActionListener; //导入依赖的package包/类
/**
 * Initialize the contents of the frame.
 */
public void initialize(){
	JPanel panel_7 = new JPanel();
	panel_7.setBounds(0, 0, 665, 415);
	frmPiattaformaGaming.getContentPane().add(panel_7);
	panel_7.setLayout(new MigLayout());
	panel_7.setVisible(true);
	
	JTextArea ta = new JTextArea();
	ta.setEditable(false);
	panel_7.add(ta);
	
	ArrayList<Recensione> al = new GiocoController(gioco).allReviews();
	for( Recensione r : al ){
		ta.setText(ta.getText() + "  - " +  r.getTesto() + "\n\n");
	}
	
	JButton btnBack = new JButton("Indietro");
	panel_7.add(btnBack, "pos 267px 345px, width 110, height 15");
	
	JScrollPane scroll = new JScrollPane(ta);
	scroll.setVerticalScrollBarPolicy ( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS );
	scroll.getVerticalScrollBar().setUnitIncrement(20);
	scroll.setSize(460,240);
	panel_7.add(scroll, "pos 0px 0px, width 660, height 340");
	
	btnBack.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
			panel_7.setVisible(false);
			new GiocoView(frmPiattaformaGaming, utente, gioco);
	}});
}
 
开发者ID:StefanoMartella,项目名称:GamingPlatform,代码行数:35,代码来源:GiocoRecensioniView.java

示例4: createGUI

import java.awt.event.ActionListener; //导入依赖的package包/类
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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:HiddenDefaultButtonTest.java

示例5: createContextMenu

import java.awt.event.ActionListener; //导入依赖的package包/类
/**
 * @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;
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:29,代码来源:MultiAlgoScenarioWizard.java

示例6: addActions

import java.awt.event.ActionListener; //导入依赖的package包/类
/**
 * 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);
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:22,代码来源:CompositeMenuToggleButton.java

示例7: getJComboBoxDestinationLang

import java.awt.event.ActionListener; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:22,代码来源:Translation.java

示例8: configureMenuItem

import java.awt.event.ActionListener; //导入依赖的package包/类
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
    }
}
 
开发者ID:CBSkarmory,项目名称:AWGW,代码行数:19,代码来源:WorldFrame.java

示例9: initComponents

import java.awt.event.ActionListener; //导入依赖的package包/类
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);
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:22,代码来源:ServerStatusView.java

示例10: EnumeratedEditor

import java.awt.event.ActionListener; //导入依赖的package包/类
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);
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:23,代码来源:EncodedEnumeratedType.java

示例11: notifyWritePermissionProblem

import java.awt.event.ActionListener; //导入依赖的package包/类
@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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:InstallStep.java

示例12: initButtons

import java.awt.event.ActionListener; //导入依赖的package包/类
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);
}
 
开发者ID:evernat,项目名称:dead-code-detector,代码行数:21,代码来源:PatternPanel.java

示例13: getNetworkProblemDescriptor

import java.awt.event.ActionListener; //导入依赖的package包/类
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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:ProblemPanel.java

示例14: createPauseButton

import java.awt.event.ActionListener; //导入依赖的package包/类
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);
}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:17,代码来源:RunCentralisedMAS.java

示例15: CreateCourseArchivePanel

import java.awt.event.ActionListener; //导入依赖的package包/类
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);
    }
  });
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:25,代码来源:CreateCourseArchivePanel.java


注:本文中的java.awt.event.ActionListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。