List of usage examples for javax.swing JButton setActionCommand
public void setActionCommand(String actionCommand)
From source file:ch.zhaw.simulation.diagram.charteditor.DefaultAxisEditor.java
/** * Standard constructor: builds a panel for displaying/editing the * properties of the specified axis./*from ww w . ja v a 2 s .co m*/ * * @param axis * the axis whose properties are to be displayed/edited in the * panel. */ public DefaultAxisEditor(Axis axis) { this.labelFont = axis.getLabelFont(); this.labelPaintSample = new PaintSample(axis.getLabelPaint()); this.tickLabelFont = axis.getTickLabelFont(); this.tickLabelPaintSample = new PaintSample(axis.getTickLabelPaint()); // Insets values this.tickLabelInsets = axis.getTickLabelInsets(); this.labelInsets = axis.getLabelInsets(); setLayout(new BorderLayout()); JPanel general = new JPanel(new BorderLayout()); general.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), localizationResources.getString("General"))); JPanel interior = new JPanel(new LCBLayout(5)); interior.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); interior.add(new JLabel(localizationResources.getString("Label"))); this.label = new JTextField(axis.getLabel()); interior.add(this.label); interior.add(new JPanel()); interior.add(new JLabel(localizationResources.getString("Font"))); this.labelFontField = new FontDisplayField(this.labelFont); interior.add(this.labelFontField); JButton b = new JButton(localizationResources.getString("Select...")); b.setActionCommand("SelectLabelFont"); b.addActionListener(this); interior.add(b); interior.add(new JLabel(localizationResources.getString("Paint"))); interior.add(this.labelPaintSample); b = new JButton(localizationResources.getString("Select...")); b.setActionCommand("SelectLabelPaint"); b.addActionListener(this); interior.add(b); general.add(interior); add(general, BorderLayout.NORTH); this.slot1 = new JPanel(new BorderLayout()); JPanel other = new JPanel(new BorderLayout()); other.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), localizationResources.getString("Other"))); this.otherTabs = new JTabbedPane(); this.otherTabs.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); JPanel ticks = new JPanel(new LCBLayout(3)); ticks.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); this.showTickLabelsCheckBox = new JCheckBox(localizationResources.getString("Show_tick_labels"), axis.isTickLabelsVisible()); ticks.add(this.showTickLabelsCheckBox); ticks.add(new JPanel()); ticks.add(new JPanel()); ticks.add(new JLabel(localizationResources.getString("Tick_label_font"))); this.tickLabelFontField = new FontDisplayField(this.tickLabelFont); ticks.add(this.tickLabelFontField); b = new JButton(localizationResources.getString("Select...")); b.setActionCommand("SelectTickLabelFont"); b.addActionListener(this); ticks.add(b); this.showTickMarksCheckBox = new JCheckBox(localizationResources.getString("Show_tick_marks"), axis.isTickMarksVisible()); ticks.add(this.showTickMarksCheckBox); ticks.add(new JPanel()); ticks.add(new JPanel()); this.otherTabs.add(localizationResources.getString("Ticks"), ticks); other.add(this.otherTabs); this.slot1.add(other); this.slot2 = new JPanel(new BorderLayout()); this.slot2.add(this.slot1, BorderLayout.NORTH); add(this.slot2); }
From source file:net.sf.xmm.moviemanager.gui.DialogIMDbMultiAdd.java
JButton createPlayButton() { JButton playMediaFiles = new JButton("Play"); playMediaFiles.setActionCommand("DialogIMDbMultiAdd - Play"); //$NON-NLS-1$ playMediaFiles.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { log.debug("ActionPerformed: " + event.getActionCommand()); //$NON-NLS-1$ if (multiAddFile != null) { String[] files = multiAddFile.toStringArray(); try { MovieManagerCommandPlay.executePlay(files); } catch (IOException e) { log.warn("Exception:" + e.getMessage(), e); } catch (InterruptedException e) { log.warn("Exception:" + e.getMessage(), e); }/*from w w w. j a v a 2s .c o m*/ } } }); return playMediaFiles; }
From source file:TextSamplerDemo.java
protected void addStylesToDocument(StyledDocument doc) { //Initialize some styles. Style def = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE); Style regular = doc.addStyle("regular", def); StyleConstants.setFontFamily(def, "SansSerif"); Style s = doc.addStyle("italic", regular); StyleConstants.setItalic(s, true); s = doc.addStyle("bold", regular); StyleConstants.setBold(s, true); s = doc.addStyle("small", regular); StyleConstants.setFontSize(s, 10); s = doc.addStyle("large", regular); StyleConstants.setFontSize(s, 16); s = doc.addStyle("icon", regular); StyleConstants.setAlignment(s, StyleConstants.ALIGN_CENTER); ImageIcon pigIcon = createImageIcon("images/Pig.gif", "a cute pig"); if (pigIcon != null) { StyleConstants.setIcon(s, pigIcon); }/*from w w w . ja va2 s . com*/ s = doc.addStyle("button", regular); StyleConstants.setAlignment(s, StyleConstants.ALIGN_CENTER); ImageIcon soundIcon = createImageIcon("images/sound.gif", "sound icon"); JButton button = new JButton(); if (soundIcon != null) { button.setIcon(soundIcon); } else { button.setText("BEEP"); } button.setCursor(Cursor.getDefaultCursor()); button.setMargin(new Insets(0, 0, 0, 0)); button.setActionCommand(buttonString); button.addActionListener(this); StyleConstants.setComponent(s, button); }
From source file:com.game.ui.views.ItemPanel.java
public void doCommonStuffForContent() { JPanel panel1 = new JPanel(); panel1.setAlignmentX(0);//from w w w .j a va2s .c o m panel1.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); panel1.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.NORTHWEST; c.insets = new Insets(5, 5, 5, 5); c.weightx = 1; c.weighty = 0.2; c.gridwidth = 2; JLabel dtlLbl = new JLabel(type + "Details : "); dtlLbl.setFont(new Font("Times New Roman", Font.BOLD, 15)); panel1.add(dtlLbl, c); c.gridwidth = 1; c.gridy = 1; JLabel nameLbl = new JLabel("Name : "); panel1.add(nameLbl, c); c.gridx = 1; JTextField name = new JTextField(""); name.setColumns(20); panel1.add(name, c); if (ringPanel) { createComponentsForRing(panel1, c); } else if (armourPanel) { createComponentsForArmour(panel1, c); } else if (potionPanel) { createComponentsForPotion(panel1, c); } else if (treasurePanel) { createComponentsForTreasure(panel1, c); } c.gridx = 0; c.gridy = c.gridy + 1; c.gridwidth = 2; JButton submit = new JButton("Save"); submit.addActionListener(this); submit.setActionCommand("button"); panel1.add(submit, c); c.gridx = 0; c.gridy = c.gridy + 1; c.gridwidth = 2; c.weighty = 0; c.weightx = 1; validationMess = new JLabel("Pls enter all the fields or pls choose a " + type + " from the drop down"); validationMess.setForeground(Color.red); validationMess.setVisible(false); panel1.add(validationMess, c); c.gridy++; c.weighty = 1; c.weightx = 1; panel1.add(new JPanel(), c); panel1.setBorder(LineBorder.createGrayLineBorder()); add(panel1); add(Box.createVerticalGlue()); }
From source file:TextInputDemo.java
protected JComponent createButtons() { JPanel panel = new JPanel(new FlowLayout(FlowLayout.TRAILING)); JButton button = new JButton("Set address"); button.addActionListener(this); panel.add(button);/*from w w w . j a va 2s . c om*/ button = new JButton("Clear address"); button.addActionListener(this); button.setActionCommand("clear"); panel.add(button); //Match the SpringLayout's gap, subtracting 5 to make //up for the default gap FlowLayout provides. panel.setBorder(BorderFactory.createEmptyBorder(0, 0, GAP - 5, GAP - 5)); return panel; }
From source file:net.mumie.coursecreator.gui.ClassChooser.java
private void buildLayout() { // Dimensions of the Dialog int width = 10; int height = 160; int buttonWidth = 100; int buttonHeight = 30; // sets the Layout this.getContentPane().setLayout(new GridBagLayout()); // the Button and Label Text String okButtonText = "Zuweisen"; String cancelButtonText = "Cancel"; headlineLabelText = ""; // the Fonts/*from w w w .j a v a 2s .co m*/ Font font = new Font("SansSerif", Font.PLAIN, 14); Font headlineLabelFont = new Font("SansSerif", Font.PLAIN, 12); Font textFieldFont = new Font("Monospaced", Font.PLAIN, 10); // GridBagContraints for rootPanel (s.b.): GridBagConstraints rootPanelStyle = createGridBagContrains(GridBagConstraints.CENTER, 4, 4, 4, 4, 0, 0); // GridBagContraints for headlineLabel: GridBagConstraints headlineLabelStyle = createGridBagContrains(GridBagConstraints.CENTER, 6, 6, 6, 6, 0, 0); // GridBagConstraints for textFieldPanel (s.b.): GridBagConstraints textFieldPanelStyle = createGridBagContrains(GridBagConstraints.CENTER, 4, 4, 4, 4, 0, 1); // GridBagConstraints for buttonPanel (s.b.): GridBagConstraints buttonPanelStyle = createGridBagContrains(GridBagConstraints.CENTER, 4, 4, 4, 4, 0, 2); // GridBagConstraints for serverTextField: GridBagConstraints serverTextFieldStyle = createGridBagContrains(GridBagConstraints.WEST, 6, 6, 6, 6, 1, 0); // GridBagContraints for okButton (s.b.): GridBagConstraints okButtonStyle = createGridBagContrains(GridBagConstraints.CENTER, 6, 6, 6, 6, 0, 0); // GridBagContraints for cancelButton (s.b.): GridBagConstraints cancelButtonStyle = createGridBagContrains(GridBagConstraints.CENTER, 6, 6, 6, 6, 1, 0); // Creating rootPanel (contains all components) JPanel rootPanel = new JPanel(new GridBagLayout()); rootPanel.setFont(font); // Creating headlineLabel: JLabel headlineLabel = new JLabel(headlineLabelText); headlineLabel.setFont(headlineLabelFont); // Creating textFieldPanel: JPanel textFieldPanel = new JPanel(new GridBagLayout()); textFieldPanel.setFont(font); // Creating classTextField: classBox = new JComboBox(this.classList); classBox.setFont(textFieldFont); String classPath = this.controller.getMetaInfoField().getMetaInfos().getClassPath(); String className = this.controller.getMetaInfoField().getMetaInfos().getClassName(); if (setSelectedClass(classPath, className) == -1) headlineLabel.setForeground(Color.RED); else headlineLabel.setForeground(Color.BLACK); headlineLabel.setText(this.headlineLabelText); // Creating buttonPanel: JPanel buttonPanel = new JPanel(new GridBagLayout()); buttonPanel.setFont(font); // okButton: JButton okButton = new JButton(okButtonText); okButton.setPreferredSize(new Dimension(buttonWidth, buttonHeight)); okButton.setActionCommand(CommandConstants.META_INFO_FIELD_OK); okButton.addActionListener(this.controller); // cancelButton: JButton cancelButton = new JButton(cancelButtonText); cancelButton.setPreferredSize(new Dimension(buttonWidth, buttonHeight)); cancelButton.setActionCommand(CommandConstants.META_INFO_FIELD_CANCEL); cancelButton.addActionListener(this.controller); // Composing the GUI: this.getContentPane().setLayout(new GridBagLayout()); this.getContentPane().add(rootPanel, rootPanelStyle); rootPanel.add(headlineLabel, headlineLabelStyle); rootPanel.add(textFieldPanel, textFieldPanelStyle); textFieldPanel.add(classBox, serverTextFieldStyle); rootPanel.add(buttonPanel, buttonPanelStyle); buttonPanel.add(okButton, okButtonStyle); buttonPanel.add(cancelButton, cancelButtonStyle); this.addWindowListener(this.windowListener); int maxString = this.headlineLabelText.length(); for (int i = 0; i < this.classList.size(); i++) { maxString = Math.max(((String) this.classList.get(i).toString()).length(), maxString); } width = Math.max(width, maxString * 8); this.setSize(width, height); }
From source file:Human1.java
JPanel guiPanel() { JPanel panel = new JPanel(); panel.setLayout(new GridLayout(0, 1)); // Human_r_shoulder rotation panel.add(new JLabel("Right Shoulder rotation")); rShoulderSlider = new JSlider(JSlider.HORIZONTAL, 0, 180, rShoulderRot); rShoulderSlider.addChangeListener(this); rShoulderSliderLabel = new JLabel(Integer.toString(rShoulderRot)); panel.add(rShoulderSlider);/*from w ww. j av a 2s . com*/ panel.add(rShoulderSliderLabel); // Human_r_elbow rotation panel.add(new JLabel("Right Elbow rotation")); rElbowSlider = new JSlider(JSlider.HORIZONTAL, 0, 180, rElbowRot); rElbowSlider.addChangeListener(this); rElbowSliderLabel = new JLabel(Integer.toString(rElbowRot)); panel.add(rElbowSlider); panel.add(rElbowSliderLabel); // Human_l_shoulder rotation panel.add(new JLabel("Left Shoulder rotation")); lShoulderSlider = new JSlider(JSlider.HORIZONTAL, 0, 180, lShoulderRot); lShoulderSlider.addChangeListener(this); lShoulderSliderLabel = new JLabel(Integer.toString(lShoulderRot)); panel.add(lShoulderSlider); panel.add(lShoulderSliderLabel); // Human_l_elbow rotation panel.add(new JLabel("Left Elbow rotation")); lElbowSlider = new JSlider(JSlider.HORIZONTAL, 0, 180, lElbowRot); lElbowSlider.addChangeListener(this); lElbowSliderLabel = new JLabel(Integer.toString(lElbowRot)); panel.add(lElbowSlider); panel.add(rElbowSliderLabel); if (isApplication) { JButton snapButton = new JButton(snapImageString); snapButton.setActionCommand(snapImageString); snapButton.addActionListener(this); panel.add(snapButton); } return panel; }
From source file:net.sf.mzmine.chartbasics.graphicsexport.GraphicsExportDialog.java
/** * Create the dialog.//w ww .ja va 2s. c o m */ public GraphicsExportDialog() { final JFrame thisframe = this; // parameters = new GraphicsExportParameters(); chartParam = new ChartThemeParameters(); parametersAndComponents = new HashMap<String, JComponent>(); String[] formats = parameters.getParameter(GraphicsExportParameters.exportFormat).getChoices(); chooser.addChoosableFileFilter(new FileTypeFilter(formats, "Export images")); chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); // setBounds(100, 100, 808, 795); getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, BorderLayout.CENTER); contentPanel.setLayout(new MigLayout("", "[][][grow]", "[][][][grow]")); { StringParameter p = parameters.getParameter(GraphicsExportParameters.path); StringComponent txtPath = p.createEditingComponent(); contentPanel.add(txtPath, "flowx,cell 0 0,growx"); parametersAndComponents.put(p.getName(), txtPath); } { btnPath = new JButton("Path"); btnPath.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { choosePath(); } }); contentPanel.add(btnPath, "cell 1 0"); } { StringParameter p = parameters.getParameter(GraphicsExportParameters.filename); StringComponent txtFileName = p.createEditingComponent(); contentPanel.add(txtFileName, "cell 0 1,growx"); parametersAndComponents.put(p.getName(), txtFileName); } { JLabel lblFilename = new JLabel("filename"); contentPanel.add(lblFilename, "cell 1 1"); } { JPanel pnSettingsLeft = new JPanel(); pnSettingsLeft.setMinimumSize(new Dimension(260, 260)); contentPanel.add(pnSettingsLeft, "cell 0 3,grow"); pnSettingsLeft.setLayout(new BorderLayout(0, 0)); { GridBagPanel pn = new GridBagPanel(); { // add unit UserParameter p; JComponent comp; // add unit p = (UserParameter) parameters.getParameter(GraphicsExportParameters.unit); comp = p.createEditingComponent(); comp.setToolTipText(p.getDescription()); comp.setEnabled(true); pn.add(comp, 2, 2); parametersAndComponents.put(p.getName(), comp); int i = 0; // add export settings Parameter[] param = parameters.getParameters(); for (int pi = 3; pi < param.length; pi++) { p = (UserParameter) param[pi]; comp = p.createEditingComponent(); comp.setToolTipText(p.getDescription()); comp.setEnabled(true); pn.add(new JLabel(p.getName()), 0, i); pn.add(comp, 1, i, 1, 1, 1, 1); // add to map parametersAndComponents.put(p.getName(), comp); i++; } // add separator pn.add(new JSeparator(), 0, i, 5, 1, 1, 1, GridBagConstraints.BOTH); i++; // add Apply theme button JButton btnApply2 = new JButton("Apply theme"); btnApply2.addActionListener(e -> applyTheme()); pn.add(btnApply2, 0, i, 5, 1, 1, 1, GridBagConstraints.BOTH); i++; // add chart settings param = chartParam.getParameters(); for (int pi = 0; pi < param.length; pi++) { p = (UserParameter) param[pi]; comp = p.createEditingComponent(); comp.setToolTipText(p.getDescription()); comp.setEnabled(true); pn.add(new JLabel(p.getName()), 0, i); pn.add(comp, 1, i, 4, 1); // add to map parametersAndComponents.put(p.getName(), comp); i++; } // add listener to master font JFontSpecs master = (JFontSpecs) parametersAndComponents .get(chartParam.getParameter(ChartThemeParameters.masterFont).getName()); master.addListener(fspec -> { if (listenersEnabled) handleMasterFontChanged(fspec); }); } JScrollPane scrollPane = new JScrollPane(pn); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); pnSettingsLeft.add(scrollPane, BorderLayout.CENTER); scrollPane.getVerticalScrollBar().setUnitIncrement(18); scrollPane.revalidate(); scrollPane.repaint(); } } { { pnChartPreview = new JPanel(); pnChartPreview.setLayout(null); contentPanel.add(pnChartPreview, "cell 1 3 2 1,grow"); } } { JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); getContentPane().add(buttonPane, BorderLayout.SOUTH); { JButton okButton = new JButton("Save"); okButton.addActionListener(e -> saveGraphicsAs()); okButton.setActionCommand("OK"); buttonPane.add(okButton); getRootPane().setDefaultButton(okButton); } { btnRenewPreview = new JButton("Renew Preview"); btnRenewPreview.addActionListener(e -> renewPreview()); buttonPane.add(btnRenewPreview); } { btnApply = new JButton("Apply theme"); btnApply.addActionListener(e -> applyTheme()); buttonPane.add(btnApply); } { JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(e -> setVisible(false)); cancelButton.setActionCommand("Cancel"); buttonPane.add(cancelButton); } } // set all to components updateComponentsFromParameters(); }
From source file:at.tuwien.ifs.feature.evaluation.SimilarityRetrievalGUI.java
public JButton initButtonLoad() { JButton buttonLoad = new JButton("Load"); buttonLoad.addActionListener(new ActionListener() { @Override//from w w w. j a va 2s.com public void actionPerformed(ActionEvent e) { fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); fileChooser.setFileFilter( new ExtensionFileFilterSwing(new String[] { "arff", "vec", "rp", "rh", "ssd", "tfxidf" })); if (fileChooser.getSelectedFile() != null) { // reusing the dialog fileChooser.setSelectedFile(null); } // TODO: remove fileChooser.setSelectedFile( new File("/data/music/ISMIRgenre/vec/mp3_vec_conv_from_wav/ISMIRgenre.rp")); int returnVal = fileChooser.showDialog(SimilarityRetrievalGUI.this, "Open input data"); if (returnVal == JFileChooser.APPROVE_OPTION) { // FIXME: remove dependency on AbstractSOMLibSparseInputData AbstractSOMLibSparseInputData data = (AbstractSOMLibSparseInputData) InputDataFactory .open(fileChooser.getSelectedFile().getAbsolutePath()); String[] newLabels = data.getLabels(); Arrays.sort(newLabels); if (inputData.size() > 0) { // check if the input data files match; if not, don't add this new one String[] existingLabels = inputData.get(0).getLabels(); Arrays.sort(existingLabels); if (!ArrayUtils.isEquals(existingLabels, newLabels)) { JOptionPane.showMessageDialog(SimilarityRetrievalGUI.this, "New data loaded doesn't have the same labels as the existing ones. Aborting", "Error", JOptionPane.ERROR_MESSAGE); System.out.println(Arrays.toString(existingLabels)); System.out.println(Arrays.toString(newLabels)); return; } } inputData.add(data); final InputDataRadioButton rb = new InputDataRadioButton(data); bgInputData.add(rb); rb.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String actionCommand = rb.getActionCommand(); System.out.println(actionCommand); } }); if (inputData.size() == 1) { // first time loaded rb.setSelected(true); // enable the retrieval panel panelRetrieval.setEnabled(true); panelLoadedFeatureFiles.remove(labelNoInputData); // populate the combo box for the retrieval comboQueryVector.setModel(new DefaultComboBoxModel(data.getLabels())); modelNumberNeighbours.setMaximum(data.numVectors() - 1); modelNumberNeighbours.setValue(Math.min(5, data.numVectors())); spinnerNumberNeighbours.setToolTipText("Maximum value:" + (data.numVectors() - 1)); btnStart.setEnabled(true); // fill the library tab Object[][] libraryData = new Object[data.numVectors()][]; ImageIcon icon = UiUtils.getIcon(PlayerControl.ICON_PREFIX, "play" + PlayerControl.ICON_SUFFIX); for (int i = 0; i < libraryData.length; i++) { final JButton button = new JButton(icon); final int index = i; button.setActionCommand(String.valueOf(i)); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String label = inputData.get(0).getLabel(index); try { player.stop(); player.play(new MP3VectorMetaData( new File(txtFieldMusicPath.getText() + File.separator + label), label)); } catch (FileNotFoundException e1) { JOptionPane.showMessageDialog(SimilarityRetrievalGUI.this, "Error playing audio file: " + e1.getMessage(), "Playback Error", JOptionPane.ERROR_MESSAGE); e1.printStackTrace(); } } }); libraryData[i] = new Object[] { button, data.getLabel(i), "unknown" }; } databaseDetailsTable .setModel(new DefaultTableModel(libraryData, databaseDetailsColumnNames)); databaseDetailsTable.getColumn(databaseDetailsColumnNames[0]) .setCellEditor(new ButtonCellEditor()); databaseDetailsTable.getColumn("").setCellRenderer(new ButtonCellRenderer()); resizeDatabaseDetailsTableColumns(); buttonLoadClassInfo.setEnabled(true); } panelLoadedFeatureFiles.add(rb); pack(); } } }); return buttonLoad; }
From source file:DateChooserPanel.java
/** * Returns a panel of buttons, each button representing a day in the month. * This is a sub-component of the DatePanel. * * @return the panel./*from w ww . ja va 2 s. c o m*/ */ private JPanel getCalendarPanel() { final JPanel p = new JPanel(new GridLayout(7, 7)); final DateFormatSymbols dateFormatSymbols = new DateFormatSymbols(); final String[] weekDays = dateFormatSymbols.getShortWeekdays(); for (int i = 0; i < this.WEEK_DAYS.length; i++) { p.add(new JLabel(weekDays[this.WEEK_DAYS[i]], SwingConstants.CENTER)); } this.buttons = new JButton[42]; for (int i = 0; i < 42; i++) { final JButton b = new JButton(""); b.setMargin(new Insets(1, 1, 1, 1)); b.setName(Integer.toString(i)); b.setFont(this.dateFont); b.setFocusPainted(false); b.setActionCommand("dateButtonClicked"); b.addActionListener(this); this.buttons[i] = b; p.add(b); } return p; }