List of usage examples for javax.swing JButton setActionCommand
public void setActionCommand(String actionCommand)
From source file:edu.harvard.mcz.imagecapture.VerbatimToTranscribeDialog.java
/** * Create the dialog./*from w w w. j a va 2s . co m*/ */ public VerbatimToTranscribeDialog() { setDefaultCloseOperation(DISPOSE_ON_CLOSE); setBounds(100, 100, 726, 557); getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, BorderLayout.CENTER); contentPanel.setLayout(new BorderLayout(0, 0)); { table = new JTable(); SpecimenLifeCycle sls = new SpecimenLifeCycle(); GenusSpeciesCountTableModel model = new GenusSpeciesCountTableModel(sls.countSpecimensForVerbatim()); table.setModel(model); table.setDefaultRenderer(GenusSpeciesCount.class, new ButtonRenderer("Transcribe")); table.setDefaultEditor(GenusSpeciesCount.class, new ButtonEditor(ButtonEditor.OPEN_SPECIMEN_VERBATIM, this)); contentPanel.add(table, BorderLayout.CENTER); } { JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); getContentPane().add(buttonPane, BorderLayout.SOUTH); { JButton cancelButton = new JButton("Close"); cancelButton.setActionCommand("Close"); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setVisible(false); } }); buttonPane.add(cancelButton); } } }
From source file:SwingToolBarDemo.java
protected JButton makeNavigationButton(String imageName, String actionCommand, String toolTipText, String altText) {// w w w. j a v a2 s . c o m //Look for the image. String imgLocation = "toolbarButtonGraphics/navigation/" + imageName + ".gif"; URL imageURL = SwingToolBarDemo.class.getResource(imgLocation); //Create and initialize the button. JButton button = new JButton(); button.setActionCommand(actionCommand); button.setToolTipText(toolTipText); button.addActionListener(this); if (imageURL != null) { //image found button.setIcon(new ImageIcon(imageURL, altText)); } else { //no image found button.setText(altText); System.err.println("Resource not found: " + imgLocation); } return button; }
From source file:Main.java
public Main() { super(new BorderLayout()); populateTree(treePanel);/*from www .j ava2 s .co m*/ JButton addButton = new JButton("Add"); addButton.setActionCommand(ADD_COMMAND); addButton.addActionListener(this); JButton removeButton = new JButton("Remove"); removeButton.setActionCommand(REMOVE_COMMAND); removeButton.addActionListener(this); JButton clearButton = new JButton("Clear"); clearButton.setActionCommand(CLEAR_COMMAND); clearButton.addActionListener(this); treePanel.setPreferredSize(new Dimension(300, 150)); add(treePanel, BorderLayout.CENTER); JPanel panel = new JPanel(new GridLayout(0, 3)); panel.add(addButton); panel.add(removeButton); panel.add(clearButton); add(panel, BorderLayout.SOUTH); }
From source file:jfreeechart.DynamicDataDemo.java
/** * Constructs a new demonstration application. * * @param title the frame title.//from w ww .j ava2 s . c o m */ public DynamicDataDemo(final String title) { super(title); this.series = new TimeSeries("Random Data", Millisecond.class); final TimeSeriesCollection dataset = new TimeSeriesCollection(this.series); final JFreeChart chart = createChart(dataset); final ChartPanel chartPanel = new ChartPanel(chart); final JButton button = new JButton("Add New Data Item"); button.setActionCommand("ADD_DATA"); button.addActionListener(this); final JPanel content = new JPanel(new BorderLayout()); content.add(chartPanel); content.add(button, BorderLayout.SOUTH); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(content); }
From source file:edu.harvard.mcz.imagecapture.VerbatimListDialog.java
protected void init() { setTitle("Verbatim Transcriptions to parse into fields"); setDefaultCloseOperation(DISPOSE_ON_CLOSE); setBounds(100, 100, 1000, 600);//from w w w . ja va 2s . com getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, BorderLayout.CENTER); contentPanel.setLayout(new BorderLayout(0, 0)); SpecimenLifeCycle sls = new SpecimenLifeCycle(); table = new JTable(new VerbatimCountTableModel(sls.countDistinctVerbatimValues())); table.setDefaultRenderer(VerbatimCount.class, new ButtonRenderer("Edit")); table.setDefaultEditor(VerbatimCount.class, new ButtonEditor(ButtonEditor.OPEN_VERBATIM_CLASSIFY, this)); JScrollPane scrollPane = new JScrollPane(); scrollPane.setViewportView(table); contentPanel.add(scrollPane, BorderLayout.CENTER); { JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); getContentPane().add(buttonPane, BorderLayout.SOUTH); { JButton cancelButton = new JButton("Close"); cancelButton.setActionCommand("Close"); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setVisible(false); } }); buttonPane.add(cancelButton); } } }
From source file:net.chaosserver.timelord.swingui.AddTimeDialog.java
/** * Builds the Add Time Panel.//w ww.jav a 2 s . com * * @return the newly created add time panel */ public JPanel buildAddTimePanel() { JPanel addTimePanel = new JPanel(); Collection<TimelordTask> taskCollection = timelordData.getTaskCollection(); Vector<TimelordTask> taskVector = new Vector<TimelordTask>(taskCollection); comboBox = new JComboBox(taskVector); comboBox.setEditable(true); addTimePanel.add(comboBox); JButton button = new JButton("+0.25"); button.setActionCommand(ACTION_OK); button.addActionListener(this); addTimePanel.add(button); return addTimePanel; }
From source file:components.ToolBarDemo2.java
protected JButton makeNavigationButton(String imageName, String actionCommand, String toolTipText, String altText) {// w w w .j a va2s. c om //Look for the image. String imgLocation = "images/" + imageName + ".gif"; URL imageURL = ToolBarDemo2.class.getResource(imgLocation); //Create and initialize the button. JButton button = new JButton(); button.setActionCommand(actionCommand); button.setToolTipText(toolTipText); button.addActionListener(this); if (imageURL != null) { //image found button.setIcon(new ImageIcon(imageURL, altText)); } else { //no image found button.setText(altText); System.err.println("Resource not found: " + imgLocation); } return button; }
From source file:org.jfree.chart.demo.DrawStringDemo.java
private JPanel createTab1Content() { JPanel jpanel = new JPanel(new BorderLayout()); combo1 = new JComboBox(); combo1.setActionCommand("combo1.changed"); populateTextAnchorCombo(combo1);/*w w w . ja v a2 s . c o m*/ combo1.addActionListener(this); JPanel jpanel1 = new JPanel(); jpanel1.add(combo1); JButton jbutton = new JButton("Select Font..."); jbutton.setActionCommand("fontButton.clicked"); jbutton.addActionListener(this); jpanel1.add(jbutton); jpanel.add(jpanel1, "North"); drawStringPanel1 = new DrawStringPanel("0123456789", false); jpanel.add(drawStringPanel1); return jpanel; }
From source file:ToolBarDemo2.java
protected JButton makeNavigationButton(String imageName, String actionCommand, String toolTipText, String altText) {//from www .j a va 2s .c o m //Look for the image. String imgLocation = "toolbarButtonGraphics/navigation/" + imageName + ".gif"; URL imageURL = ToolBarDemo2.class.getResource(imgLocation); //Create and initialize the button. JButton button = new JButton(); button.setActionCommand(actionCommand); button.setToolTipText(toolTipText); button.addActionListener(this); if (imageURL != null) { //image found button.setIcon(new ImageIcon(imageURL, altText)); } else { //no image found button.setText(altText); System.err.println("Resource not found: " + imgLocation); } return button; }
From source file:appletComponentArch.DynamicTreePanel.java
public DynamicTreePanel() { super(new BorderLayout()); //Create the components. treePanel = new DynamicTree(); populateTree(treePanel);//from w w w . j a v a2 s . c o m JButton addButton = new JButton("Add"); addButton.setActionCommand(ADD_COMMAND); addButton.addActionListener(this); JButton removeButton = new JButton("Remove"); removeButton.setActionCommand(REMOVE_COMMAND); removeButton.addActionListener(this); JButton clearButton = new JButton("Clear"); clearButton.setActionCommand(CLEAR_COMMAND); clearButton.addActionListener(this); //Lay everything out. treePanel.setPreferredSize(new Dimension(300, 150)); add(treePanel, BorderLayout.CENTER); JPanel panel = new JPanel(new GridLayout(0, 3)); panel.add(addButton); panel.add(removeButton); panel.add(clearButton); add(panel, BorderLayout.SOUTH); }