java类java.awt.event.ActionListener的实例源码

BasicReplaceResultsPanel.java 文件源码 项目:incubator-netbeans 阅读 21 收藏 0 点赞 0 评论 0
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
}
PropertiesDataNode.java 文件源码 项目:incubator-netbeans 阅读 24 收藏 0 点赞 0 评论 0
/** 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);
}
MainFrame.java 文件源码 项目:KernelHive 阅读 34 收藏 0 点赞 0 评论 0
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);
}
bug8025082.java 文件源码 项目:openjdk-jdk10 阅读 18 收藏 0 点赞 0 评论 0
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);
}
TreeList.java 文件源码 项目:incubator-netbeans 阅读 25 收藏 0 点赞 0 评论 0
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());
                }
            }
        }
    });
}
StatusBar.java 文件源码 项目:cuttlefish 阅读 25 收藏 0 点赞 0 评论 0
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);
        }
    });

}
NodeViewerData.java 文件源码 项目:ZooKeeper 阅读 23 收藏 0 点赞 0 评论 0
/**
* 
*/
  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);

  }
Test6179222.java 文件源码 项目:openjdk-jdk10 阅读 20 收藏 0 点赞 0 评论 0
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");
    }
}
QueryParameter.java 文件源码 项目:incubator-netbeans 阅读 21 收藏 0 点赞 0 评论 0
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();
}
VisualizationActionListenerFactory.java 文件源码 项目:Tarski 阅读 27 收藏 0 点赞 0 评论 0
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();
        }
      });
    }
  };
}


问题


面经


文章

微信
公众号

扫码关注公众号