Java Code Examples for javax.swing.JButton#setActionCommand()
The following examples show how to use
javax.swing.JButton#setActionCommand() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SerialDateChooserPanel.java From ccu-historian with GNU General Public License v3.0 | 5 votes |
/** * Returns a panel of buttons, each button representing a day in the month. This is a * sub-component of the DatePanel. * * @return the panel. */ private JPanel getCalendarPanel() { final JPanel panel = new JPanel(new GridLayout(7, 7)); panel.add(new JLabel("Sun", SwingConstants.CENTER)); panel.add(new JLabel("Mon", SwingConstants.CENTER)); panel.add(new JLabel("Tue", SwingConstants.CENTER)); panel.add(new JLabel("Wed", SwingConstants.CENTER)); panel.add(new JLabel("Thu", SwingConstants.CENTER)); panel.add(new JLabel("Fri", SwingConstants.CENTER)); panel.add(new JLabel("Sat", SwingConstants.CENTER)); this.buttons = new JButton[42]; for (int i = 0; i < 42; i++) { final JButton button = new JButton(""); button.setMargin(new Insets(1, 1, 1, 1)); button.setName(Integer.toString(i)); button.setFont(this.dateFont); button.setFocusPainted(false); button.setActionCommand("dateButtonClicked"); button.addActionListener(this); this.buttons[i] = button; panel.add(button); } return panel; }
Example 2
Source File: LoadSaveDialog.java From WorldGrower with GNU General Public License v3.0 | 5 votes |
public LoadSaveDialog(SaveGameHandler saveGameHandler, LoadSaveMode loadSaveMode, ImageInfoReader imageInfoReader, SoundIdReader soundIdReader) { super(500, 475, imageInfoReader); ((JComponent)getRootPane()).setBorder(BorderFactory.createLineBorder(Color.WHITE, 5)); JScrollPane scrollPane = JScrollPaneFactory.createScrollPane(); scrollPane.setBounds(16, 16, 462, 375); addComponent(scrollPane); JList<SaveGame> list = JListFactory.createJList(loadSaveMode.getSaveFiles()); list.setOpaque(false); list.setSelectedIndex(0); list.setCellRenderer(new SaveGameRenderer(imageInfoReader)); scrollPane.setViewportView(list); JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BorderLayout()); buttonPane.setOpaque(false); buttonPane.setBounds(16, 410, 465, 50); addComponent(buttonPane); JButton cancelButton = JButtonFactory.createButton("Cancel", imageInfoReader, soundIdReader); cancelButton.setActionCommand("Cancel"); buttonPane.add(cancelButton, BorderLayout.WEST); getRootPane().setDefaultButton(cancelButton); JButton okButton = JButtonFactory.createButton(loadSaveMode.getDescription(), imageInfoReader, soundIdReader); okButton.setActionCommand("OK"); okButton.setEnabled(false); buttonPane.add(okButton, BorderLayout.EAST); getRootPane().setDefaultButton(okButton); addActions(list, okButton, cancelButton, loadSaveMode, saveGameHandler); }
Example 3
Source File: StockpileSelectionDialog.java From jeveassets with GNU General Public License v2.0 | 5 votes |
public StockpileSelectionDialog(final Program program, String title) { super(program, title); ListenerClass listener = new ListenerClass(); jList = new JMultiSelectionList<T>(); jList.addListSelectionListener(listener); JScrollPane jListScroll = new JScrollPane(jList); jOK = new JButton(TabsStockpile.get().ok()); jOK.setActionCommand(StockpileSelection.OK.name()); jOK.addActionListener(listener); jOK.setEnabled(false); JButton jCancel = new JButton(TabsStockpile.get().cancel()); jCancel.setActionCommand(StockpileSelection.CANCEL.name()); jCancel.addActionListener(listener); layout.setHorizontalGroup( layout.createParallelGroup(GroupLayout.Alignment.TRAILING) .addComponent(jListScroll, 300, 300, 300) .addGroup(layout.createSequentialGroup() .addComponent(jOK, Program.getButtonsWidth(), Program.getButtonsWidth(), Program.getButtonsWidth()) .addComponent(jCancel, Program.getButtonsWidth(), Program.getButtonsWidth(), Program.getButtonsWidth()) ) ); layout.setVerticalGroup( layout.createSequentialGroup() .addComponent(jListScroll, 200, 200, 200) .addGroup(layout.createParallelGroup() .addComponent(jOK, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent(jCancel, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) ) ); }
Example 4
Source File: OnePageWindow.java From wpcleaner with Apache License 2.0 | 5 votes |
/** * Create a Send button. * * @param listener Action listener. * @param icon Flag indicating if an icon should be used. * @return Send button. */ public JButton createButtonSend(ActionListener listener, boolean icon) { JButton button = Utilities.createJButton( icon ? "gnome-document-send.png" : null, EnumImageSize.NORMAL, GT._T("Send"), !icon, ConfigurationValueShortcut.SEND); button.setActionCommand(ACTION_SEND); button.addActionListener(listener); return button; }
Example 5
Source File: LanguageTableModel.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
public Editor() { cellPanel.setLayout(cardLayout); cellPanel.setOpaque(true); JButton addButton = Utilities.createSignButton(Sign.Plus); JButton removeButton = Utilities.createSignButton(Sign.Minus); addButton.setActionCommand(ADD_ID); removeButton.setActionCommand(REMOVE_ID); addButton.setFocusable(false); removeButton.setFocusable(false); addButton.addActionListener(this); removeButton.addActionListener(this); Box box = Box.createHorizontalBox(); box.add(Box.createHorizontalGlue()); box.add(addLabel); box.add(Box.createHorizontalStrut(3)); box.add(addButton); box.add(Box.createHorizontalStrut(2)); cellPanel.add(box, ADD_ID); box = Box.createHorizontalBox(); box.add(Box.createHorizontalStrut(3)); box.add(cellLabel); box.add(Box.createHorizontalGlue()); box.add(removeButton); box.add(Box.createHorizontalStrut(2)); cellPanel.add(box, REMOVE_ID); }
Example 6
Source File: ControlsDialog.java From WorldGrower with GNU General Public License v3.0 | 5 votes |
private void addButtonPane() { JPanel buttonPane = new JPanel(); buttonPane.setOpaque(false); buttonPane.setBounds(0, 740, 383, 75); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); addComponent(buttonPane); JButton okButton = JButtonFactory.createButton("OK", imageInfoReader, soundIdReader); okButton.setActionCommand("OK"); buttonPane.add(okButton); addActionHandlers(okButton, this); getRootPane().setDefaultButton(okButton); }
Example 7
Source File: Help.java From FancyBing with GNU General Public License v3.0 | 5 votes |
private JButton createToolBarButton(String icon, String command, String toolTip) { JButton button = new JButton(); button.setActionCommand(command); button.setToolTipText(i18n(toolTip)); button.addActionListener(this); button.setIcon(GuiUtil.getIcon(icon, command)); button.setFocusable(false); return button; }
Example 8
Source File: RanksIterator.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 5 votes |
public RanksIterator(JFrame parent,String inputFile,String outputFile, int numIterations){ super(parent,AIRanksTool.getUIText("Progress_Message")); this.outputFile=outputFile; ; this.numIterations=numIterations; setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); progressLabel=new JLabel(String.format(AIRanksTool.getUIText("Progress_Note"), 1,0,numIterations,0)); String message=String.format(AIRanksTool.getUIText("Progress_Note"), 100,100,100,100); progressLabel.setText(message); progressBar=new JProgressBar(0,100); cancelButton= new JButton(AIRanksTool.getUIText("Progress_Cancel_Button")); cancelButton.setActionCommand("cancel"); cancelButton.addActionListener(this); JPanel mainPane=new JPanel(new BorderLayout() ); JPanel pane = new JPanel(new GridLayout(0,1)); mainPane.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); pane.add(progressLabel); pane.add(progressBar); pane.add(cancelButton); mainPane.add(pane,BorderLayout.CENTER); add(mainPane); pack(); setVisible(true); //size=ranks.getSize(); int numProcessors=Runtime.getRuntime().availableProcessors(); //System.out.println(numProcessors); allIterations =this.new AllIterations(numProcessors,this,inputFile); //allIterations.addPropertyChangeListener(this); allIterations.execute(); }
Example 9
Source File: InflateReader.java From aion-germany with GNU General Public License v3.0 | 5 votes |
@Override public JComponent readToComponent(ValuePart part) { JButton view = new JButton("View"); view.addActionListener(new ButtonActionListener(this.read(part))); view.setActionCommand("clicked"); return view; }
Example 10
Source File: DefaultColorBarEditor.java From ccu-historian with GNU General Public License v3.0 | 4 votes |
/** * Creates a new edit panel for a color bar. * * @param colorBar the color bar. */ public DefaultColorBarEditor(ColorBar colorBar) { super((NumberAxis) colorBar.getAxis()); this.invertPalette = colorBar.getColorPalette().isInverse(); this.stepPalette = colorBar.getColorPalette().isStepped(); this.currentPalette = new PaletteSample(colorBar.getColorPalette()); this.availablePaletteSamples = new PaletteSample[2]; this.availablePaletteSamples[0] = new PaletteSample(new RainbowPalette()); this.availablePaletteSamples[1] = new PaletteSample(new GreyPalette()); JTabbedPane other = getOtherTabs(); JPanel palettePanel = new JPanel(new LCBLayout(4)); palettePanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); palettePanel.add(new JPanel()); this.invertPaletteCheckBox = new JCheckBox( localizationResources.getString("Invert_Palette"), this.invertPalette ); this.invertPaletteCheckBox.setActionCommand("invertPalette"); this.invertPaletteCheckBox.addActionListener(this); palettePanel.add(this.invertPaletteCheckBox); palettePanel.add(new JPanel()); palettePanel.add(new JPanel()); this.stepPaletteCheckBox = new JCheckBox( localizationResources.getString("Step_Palette"), this.stepPalette ); this.stepPaletteCheckBox.setActionCommand("stepPalette"); this.stepPaletteCheckBox.addActionListener(this); palettePanel.add(this.stepPaletteCheckBox); palettePanel.add(new JPanel()); palettePanel.add( new JLabel(localizationResources.getString("Palette")) ); JButton button = new JButton(localizationResources.getString("Set_palette...")); button.setActionCommand("PaletteChoice"); button.addActionListener(this); palettePanel.add(this.currentPalette); palettePanel.add(button); other.add(localizationResources.getString("Palette"), palettePanel); }
Example 11
Source File: NewUnitPanel.java From freecol with GNU General Public License v2.0 | 4 votes |
/** * Updates this panel's labels so that the information it displays * is up to date. */ public void update() { removeAll(); final Player player = getMyPlayer(); final Europe europe = player.getEurope(); add(question, "span, wrap 20"); // The prices may have changed, recreate the buttons buttons.clear(); for (UnitType ut : sort(units, priceComparator)) { int price = europe.getUnitPrice(ut); boolean enable = player.checkGold(price); JButton newButton = new JButton(); newButton.setLayout(new MigLayout("wrap 2", "[60]", "[30][30]")); ImageIcon icon = new ImageIcon(getImageLibrary() .getSmallUnitTypeImage(ut, !enable)); JLabel name = Utility.localizedLabel(ut); name.setEnabled(enable); JLabel gold = Utility.localizedLabel(StringTemplate .template("goldAmount") .addAmount("%amount%", price)); gold.setEnabled(enable); newButton.setEnabled(enable); newButton.add(new JLabel(icon), "span 1 2"); newButton.add(name); newButton.add(gold); newButton.setActionCommand(ut.getId()); newButton.addActionListener(this); buttons.add(newButton); add(newButton, "grow"); } add(okButton, "newline 20, span, tag ok"); setSize(getPreferredSize()); revalidate(); shouldEnable = player.checkGold(europe.getUnitPrice(first(units))); }
Example 12
Source File: GroovyConsoleSlide.java From COMP6237 with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public Component getComponent(int width, int height) throws IOException { final JPanel base = new JPanel(); base.setOpaque(false); base.setPreferredSize(new Dimension(width, height)); base.setLayout(new BorderLayout()); final JPanel controls = new JPanel(); final JButton runBtn = new JButton("Run"); runBtn.setActionCommand("run"); runBtn.addActionListener(this); controls.add(runBtn); base.add(controls, BorderLayout.NORTH); textArea = new RSyntaxTextArea(20, 60); Font font = textArea.getFont(); font = font.deriveFont(font.getStyle(), 18); textArea.setFont(font); textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_GROOVY); textArea.setCodeFoldingEnabled(true); textArea.setText(initialScript); final RTextScrollPane inputScrollPane = new RTextScrollPane(textArea); outputPane = new JTextPane(); outputPane.setEditable(false); outputPane.setFont(new Font("Monospaced", Font.PLAIN, 18)); outputPane.setBorder(new EmptyBorder(4, 4, 4, 4)); final JScrollPane outputScrollPane = new JScrollPane(outputPane); splitPane = new JSplitPane(orientation, inputScrollPane, outputScrollPane); splitPane.setOneTouchExpandable(true); splitPane.setDividerLocation(width / 2); final Dimension minimumSize = new Dimension(100, 50); inputScrollPane.setMinimumSize(minimumSize); outputScrollPane.setMinimumSize(minimumSize); final JPanel body = new JPanel(); body.setBackground(Color.RED); body.setLayout(new BoxLayout(body, BoxLayout.Y_AXIS)); body.add(splitPane); base.add(body, BorderLayout.CENTER); installInterceptors(); return base; }
Example 13
Source File: DomGameFrame.java From DominionSim with MIT License | 4 votes |
private JPanel getInfoPanel() { JPanel thePanel = new JPanel(); thePanel.setLayout(new GridBagLayout()); GridBagConstraints theCons = DomGui.getGridBagConstraints(2); theCons.fill=GridBagConstraints.NONE; myDrawDeckLabel = new JLabel(); theCons.gridx++; thePanel.add(myDrawDeckLabel, theCons); myDiscardLabel = new JLabel(); theCons.gridx++; thePanel.add(myDiscardLabel, theCons); //Actions indicator JLabel theActionsLabel = new JLabel("Actions:"); theCons.gridx++; thePanel.add(theActionsLabel, theCons); myActionsValue=new JLabel(); theCons.gridx++; thePanel.add(myActionsValue, theCons); //Buys indicator JLabel theBuysLabel = new JLabel("Buys:"); theCons.gridx++; thePanel.add(theBuysLabel, theCons); myBuysValue = new JLabel(); theCons.gridx++; thePanel.add(myBuysValue, theCons); myVPLabel = new JLabel(); theCons.gridx++; thePanel.add(myVPLabel, theCons); myOppsVPLabel = new JLabel(); theCons.gridx++; thePanel.add(myOppsVPLabel, theCons); theCons.gridx++; JButton theInfoButton = new JButton("Game Info"); theInfoButton.setActionCommand("Game Info"); theInfoButton.addActionListener(this); thePanel.add(theInfoButton, theCons); // theCons.gridx++; // myOppTextLabel = new JLabel(); // thePanel.add(myOppTextLabel, theCons); theCons.weightx=100; theCons.gridx++; thePanel.add(new JLabel(), theCons); theCons.weightx=1; theCons.gridx++; myHintButton = new JButton("Hint!"); myHintButton.setActionCommand("Hint"); myHintButton.addActionListener(this); myHintButton.setVisible(false); thePanel.add(myHintButton, theCons); theCons.gridx++; myPlayAllTreasurersBTN = new JButton("Play all treasures"); myPlayAllTreasurersBTN.setActionCommand("Play all treasures"); myPlayAllTreasurersBTN.addActionListener(this); myPlayAllTreasurersBTN.setVisible(false); thePanel.add(myPlayAllTreasurersBTN, theCons); theCons.gridx++; mySpendCoffersBTN = new JButton("$0"); mySpendCoffersBTN.setActionCommand("Spend coffers"); mySpendCoffersBTN.setToolTipText("Spend coffers"); mySpendCoffersBTN.addActionListener(this); mySpendCoffersBTN.setVisible(false); thePanel.add(mySpendCoffersBTN, theCons); theCons.gridx++; myUseVillagersBTN = new JButton("V(0)"); myUseVillagersBTN.setActionCommand("Use Villagers"); myUseVillagersBTN.setToolTipText("Use Villagers"); myUseVillagersBTN.addActionListener(this); myUseVillagersBTN.setVisible(false); thePanel.add(myUseVillagersBTN, theCons); theCons.gridx++; myPayOffDebtBTN = new JButton("$0"); myPayOffDebtBTN.setForeground(Color.red); myPayOffDebtBTN.setActionCommand("Pay off debt"); myPayOffDebtBTN.setToolTipText("Pay off debt"); myPayOffDebtBTN.addActionListener(this); myPayOffDebtBTN.setVisible(false); thePanel.add(myPayOffDebtBTN, theCons); theCons.gridx++; myEndActions = new JButton("End Actions"); myEndActions.setActionCommand("End Actions"); myEndActions.addActionListener(this); thePanel.add(myEndActions, theCons); theCons.gridx++; myEndTurnBTN = new JButton("End turn"); myEndTurnBTN.setActionCommand("End turn"); myEndTurnBTN.addActionListener(this); thePanel.add(myEndTurnBTN, theCons); return thePanel; }
Example 14
Source File: MatchingDemo.java From COMP3204 with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public Component getComponent(int width, int height) throws IOException { engine.getOptions().setDoubleInitialImage(false); final JPanel outer = new JPanel(); outer.setOpaque(false); outer.setPreferredSize(new Dimension(width, height)); outer.setLayout(new GridBagLayout()); // the main panel final JPanel base = new JPanel(); base.setOpaque(false); base.setLayout(new BoxLayout(base, BoxLayout.Y_AXIS)); vc = new VideoCaptureComponent(320, 240); vc.getDisplay().getScreen().setPreferredSize(new Dimension(640, 240)); vc.getDisplay().addVideoListener(this); base.add(vc); final JPanel controls1 = new JPanel(); controls1.setOpaque(false); final JButton grab = new JButton("Grab"); grab.setActionCommand("grab"); grab.addActionListener(this); grab.setFont(FONT); controls1.add(grab); base.add(controls1); final JPanel controls = new JPanel(); controls.setOpaque(false); final JLabel label = new JLabel("Threshold:"); label.setFont(FONT); controls.add(label); final JSlider slider = new JSlider(0, 10, 8); matcher.setThreshold(slider.getValue()); slider.setPreferredSize(new Dimension(slider.getPreferredSize().width + 250, slider.getPreferredSize().height)); controls.add(slider); final JTextField tf = new JTextField(5); tf.setFont(FONT); tf.setEnabled(false); tf.setText(slider.getValue() + ""); controls.add(tf); slider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { tf.setText(slider.getValue() + ""); matcher.setThreshold(slider.getValue()); } }); base.add(controls); outer.add(base); return outer; }
Example 15
Source File: BoardNewDialog.java From megamek with GNU General Public License v2.0 | 4 votes |
BoardNewDialog(JFrame frame) { super(frame, Messages.getString("BoardEditor.SetDimensions"), true); //$NON-NLS-1$ xvalue = 0; yvalue = 0; labWidth = new JLabel( Messages.getString("BoardEditor.labWidth"), SwingConstants.RIGHT); //$NON-NLS-1$ labHeight = new JLabel( Messages.getString("BoardEditor.labHeight"), SwingConstants.RIGHT); //$NON-NLS-1$ texWidth = new JTextField("16", 2); //$NON-NLS-1$ texHeight = new JTextField("17", 2); //$NON-NLS-1$ butOkay = new JButton(Messages.getString("Okay")); //$NON-NLS-1$ butOkay.setActionCommand("done"); //$NON-NLS-1$ butOkay.addActionListener(this); butOkay.setSize(80, 24); butCancel = new JButton(Messages.getString("Cancel")); //$NON-NLS-1$ butCancel.setActionCommand("cancel"); //$NON-NLS-1$ butCancel.addActionListener(this); butCancel.setSize(80, 24); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); getContentPane().setLayout(gridbag); c.fill = GridBagConstraints.NONE; c.weightx = 0.0; c.weighty = 0.0; c.insets = new Insets(5, 5, 1, 1); gridbag.setConstraints(labWidth, c); getContentPane().add(labWidth); c.gridwidth = GridBagConstraints.REMAINDER; gridbag.setConstraints(texWidth, c); getContentPane().add(texWidth); c.gridwidth = GridBagConstraints.RELATIVE; gridbag.setConstraints(labHeight, c); getContentPane().add(labHeight); c.gridwidth = GridBagConstraints.REMAINDER; gridbag.setConstraints(texHeight, c); getContentPane().add(texHeight); c.ipadx = 20; c.ipady = 5; c.gridwidth = GridBagConstraints.RELATIVE; gridbag.setConstraints(butOkay, c); getContentPane().add(butOkay); c.gridwidth = GridBagConstraints.REMAINDER; gridbag.setConstraints(butCancel, c); getContentPane().add(butCancel); pack(); setResizable(false); setLocation(frame.getLocation().x + frame.getSize().width / 2 - getSize().width / 2, frame.getLocation().y + frame.getSize().height / 2 - getSize().height / 2); }
Example 16
Source File: MaterialsTab.java From jeveassets with GNU General Public License v2.0 | 4 votes |
public MaterialsTab(final Program program) { super(program, TabsMaterials.get().materials(), Images.TOOL_MATERIALS.getIcon(), true); //Category: Asteroid //Category: Material ListenerClass listener = new ListenerClass(); JFixedToolBar jToolBarLeft = new JFixedToolBar(); jOwners = new JComboBox<>(); jOwners.setActionCommand(MaterialsAction.SELECTED.name()); jOwners.addActionListener(listener); jToolBarLeft.addComboBox(jOwners, 200); jPiMaterial = new JCheckBox(TabsMaterials.get().includePI()); jPiMaterial.setActionCommand(MaterialsAction.SELECTED.name()); jPiMaterial.addActionListener(listener); jToolBarLeft.add(jPiMaterial); jToolBarLeft.addSpace(10); jToolBarLeft.addSeparator(); jExport = new JButton(GuiShared.get().export(), Images.DIALOG_CSV_EXPORT.getIcon()); jExport.setActionCommand(MaterialsAction.EXPORT.name()); jExport.addActionListener(listener); jToolBarLeft.addButton(jExport); JFixedToolBar jToolBarRight = new JFixedToolBar(); jCollapse = new JButton(TabsMaterials.get().collapse(), Images.MISC_COLLAPSED.getIcon()); jCollapse.setActionCommand(MaterialsAction.COLLAPSE.name()); jCollapse.addActionListener(listener); jToolBarRight.addButton(jCollapse); jExpand = new JButton(TabsMaterials.get().expand(), Images.MISC_EXPANDED.getIcon()); jExpand.setActionCommand(MaterialsAction.EXPAND.name()); jExpand.addActionListener(listener); jToolBarRight.addButton(jExpand); //Table Format tableFormat = new EnumTableFormatAdaptor<>(MaterialTableFormat.class); //Backend eventList = EventListManager.create(); //Separator eventList.getReadWriteLock().readLock().lock(); separatorList = new SeparatorList<>(eventList, new MaterialSeparatorComparator(), 1, Integer.MAX_VALUE); eventList.getReadWriteLock().readLock().unlock(); //Table Model tableModel = EventModels.createTableModel(separatorList, tableFormat); //Table jTable = new JSeparatorTable(program, tableModel, separatorList); jTable.setSeparatorRenderer(new MaterialsSeparatorTableCell(jTable, separatorList)); jTable.setSeparatorEditor(new MaterialsSeparatorTableCell(jTable, separatorList)); PaddingTableCellRenderer.install(jTable, 3); //Selection Model selectionModel = EventModels.createSelectionModel(separatorList); selectionModel.setSelectionMode(ListSelection.MULTIPLE_INTERVAL_SELECTION_DEFENSIVE); jTable.setSelectionModel(selectionModel); //Listeners installTable(jTable, NAME); //Scroll jTableScroll = new JScrollPane(jTable); //Menu installMenu(program, new MaterialTableMenu(), jTable, Material.class); List<EnumTableColumn<Material>> enumColumns = new ArrayList<>(); enumColumns.addAll(Arrays.asList(MaterialExtenedTableFormat.values())); enumColumns.addAll(Arrays.asList(MaterialTableFormat.values())); exportDialog = new ExportDialog<>(program.getMainWindow().getFrame(), NAME, null, new MaterialsFilterControl(), Collections.singletonList(eventList), enumColumns); layout.setHorizontalGroup( layout.createParallelGroup() .addGroup(layout.createSequentialGroup() .addComponent(jToolBarLeft, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, Integer.MAX_VALUE) .addGap(0) .addComponent(jToolBarRight) ) .addComponent(jTableScroll, 0, 0, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createSequentialGroup() .addGroup(layout.createParallelGroup() .addComponent(jToolBarLeft, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(jToolBarRight, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) ) .addComponent(jTableScroll, 0, 0, Short.MAX_VALUE) ); }
Example 17
Source File: DefaultColorBarEditor.java From buffer_bci with GNU General Public License v3.0 | 4 votes |
/** * Creates a new edit panel for a color bar. * * @param colorBar the color bar. */ public DefaultColorBarEditor(ColorBar colorBar) { super((NumberAxis) colorBar.getAxis()); this.invertPalette = colorBar.getColorPalette().isInverse(); this.stepPalette = colorBar.getColorPalette().isStepped(); this.currentPalette = new PaletteSample(colorBar.getColorPalette()); this.availablePaletteSamples = new PaletteSample[2]; this.availablePaletteSamples[0] = new PaletteSample(new RainbowPalette()); this.availablePaletteSamples[1] = new PaletteSample(new GreyPalette()); JTabbedPane other = getOtherTabs(); JPanel palettePanel = new JPanel(new LCBLayout(4)); palettePanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); palettePanel.add(new JPanel()); this.invertPaletteCheckBox = new JCheckBox( localizationResources.getString("Invert_Palette"), this.invertPalette ); this.invertPaletteCheckBox.setActionCommand("invertPalette"); this.invertPaletteCheckBox.addActionListener(this); palettePanel.add(this.invertPaletteCheckBox); palettePanel.add(new JPanel()); palettePanel.add(new JPanel()); this.stepPaletteCheckBox = new JCheckBox( localizationResources.getString("Step_Palette"), this.stepPalette ); this.stepPaletteCheckBox.setActionCommand("stepPalette"); this.stepPaletteCheckBox.addActionListener(this); palettePanel.add(this.stepPaletteCheckBox); palettePanel.add(new JPanel()); palettePanel.add( new JLabel(localizationResources.getString("Palette")) ); JButton button = new JButton(localizationResources.getString("Set_palette...")); button.setActionCommand("PaletteChoice"); button.addActionListener(this); palettePanel.add(this.currentPalette); palettePanel.add(button); other.add(localizationResources.getString("Palette"), palettePanel); }
Example 18
Source File: TomatoLinearClassifierDemo.java From COMP3204 with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public Component getComponent(int width, int height) throws IOException { points = new ArrayList<double[]>(); classes = new ArrayList<Integer>(); classifier = new SimplePerceptron(); circle = new Circle(VIDEO_WIDTH / 2, VIDEO_HEIGHT / 2, VIDEO_HEIGHT / 8); vc = new VideoCaptureComponent(VIDEO_WIDTH, VIDEO_HEIGHT); vc.getDisplay().addVideoListener(this); // the main panel final JPanel base = new JPanel(); base.setOpaque(false); base.setPreferredSize(new Dimension(width, height)); base.setLayout(new GridBagLayout()); // left hand side (video, features) final Box videoCtrls = Box.createVerticalBox(); videoCtrls.setOpaque(false); videoCtrls.add(vc); videoCtrls.add(Box.createVerticalStrut(10)); final JPanel colourspacesPanel = createColourSpaceButtons(); videoCtrls.add(colourspacesPanel); createFeatureField(); videoCtrls.add(Box.createVerticalStrut(10)); videoCtrls.add(featureField); base.add(videoCtrls); // right hand box final Box rightPanel = Box.createVerticalBox(); rightPanel.setOpaque(false); image = new MBFImage(GRAPH_WIDTH, GRAPH_HEIGHT, ColourSpace.RGB); image.fill(RGBColour.WHITE); imageComp = new DisplayUtilities.ImageComponent(true, false); imageComp.setShowPixelColours(false); imageComp.setShowXYPosition(false); imageComp.setAllowZoom(false); imageComp.setAllowPanning(false); rightPanel.add(imageComp); final JPanel classCtrlsCnt = new JPanel(new GridLayout(1, 2)); // learning controls final JPanel learnCtrls = new JPanel(new GridLayout(0, 1)); classType = new JComboBox<String>(); for (final String c : CLASSES) classType.addItem(c); learnCtrls.add(classType); final JButton learnButton = new JButton("Learn"); learnButton.setActionCommand("button.learn"); learnButton.addActionListener(this); learnCtrls.add(learnButton); classCtrlsCnt.add(learnCtrls); // classification controls final JPanel classCtrls = new JPanel(new GridLayout(0, 1)); classCtrls.setOpaque(false); guess = new JTextField(8); guess.setOpaque(false); guess.setFont(Font.decode("Monaco-24")); guess.setHorizontalAlignment(JTextField.CENTER); guess.setEditable(false); classCtrls.add(guess); classCtrlsCnt.add(classCtrls); rightPanel.add(classCtrlsCnt); base.add(rightPanel); redraw(); return base; }
Example 19
Source File: TomatoKNNClassifierDemo.java From COMP3204 with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public Component getComponent(final int width, final int height) throws IOException { points = new ArrayList<double[]>(); classes = new ArrayList<Integer>(); k = 1; circle = new Circle(VIDEO_WIDTH / 2, VIDEO_HEIGHT / 2, VIDEO_HEIGHT / 8); vc = new VideoCaptureComponent(VIDEO_WIDTH, VIDEO_HEIGHT); vc.getDisplay().addVideoListener(this); // the main panel final JPanel base = new JPanel() { private static final long serialVersionUID = 1L; @Override protected void paintComponent(Graphics g) { ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); super.paintComponent(g); if (bgImage != null) g.drawImage(bgImage, 0, 0, width, height, null); } }; base.setOpaque(false); base.setPreferredSize(new Dimension(width, height)); base.setLayout(new GridBagLayout()); // left hand side (video, features) final Box videoCtrls = Box.createVerticalBox(); videoCtrls.add(vc); videoCtrls.add(Box.createVerticalStrut(10)); final JPanel colourspacesPanel = createColourSpaceButtons(); videoCtrls.add(colourspacesPanel); createFeatureField(); videoCtrls.add(Box.createVerticalStrut(10)); videoCtrls.add(featureField); base.add(videoCtrls); // right hand box final Box rightPanel = Box.createVerticalBox(); rightPanel.setOpaque(false); guess = new JTextField(8); guess.setOpaque(false); guess.setFont(Font.decode("Monaco-48")); guess.setHorizontalAlignment(JTextField.CENTER); guess.setEditable(false); rightPanel.add(guess); image = new MBFImage(GRAPH_WIDTH, GRAPH_HEIGHT, ColourSpace.RGB); image.fill(RGBColour.WHITE); imageComp = new DisplayUtilities.ImageComponent(true, false); imageComp.setShowPixelColours(false); imageComp.setShowXYPosition(false); imageComp.setAllowZoom(false); imageComp.setAllowPanning(false); rightPanel.add(imageComp); final JPanel classCtrlsCnt = new JPanel(new GridLayout(1, 2)); classCtrlsCnt.setOpaque(false); // learning controls final JPanel learnCtrls = new JPanel(new GridLayout(0, 1)); learnCtrls.setOpaque(false); classType = new JComboBox<String>(); for (final String c : CLASSES) classType.addItem(c); learnCtrls.add(classType); final JButton learnButton = new JButton("Learn"); learnButton.setActionCommand("button.learn"); learnButton.addActionListener(this); learnCtrls.add(learnButton); classCtrlsCnt.add(learnCtrls); // classification controls final JPanel classCtrls = new JPanel(new GridLayout(0, 1)); classCtrls.setOpaque(false); final JPanel cnt = new JPanel(); cnt.setOpaque(false); cnt.add(new JLabel("K:")); final JSpinner kField = new JSpinner(new SpinnerNumberModel(k, 1, 10, 1)); kField.addChangeListener(this); cnt.add(kField); classCtrls.add(cnt); classCtrlsCnt.add(classCtrls); rightPanel.add(classCtrlsCnt); base.add(rightPanel); redraw(); return base; }
Example 20
Source File: Utils.java From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 | 4 votes |
public static JButton createButton(String action, ActionListener actionlistener) { JButton btn = new JButton(); btn.setActionCommand(action); btn.addActionListener(actionlistener); return btn; }