public SpinnerModelEditorDemo() { // Group labels JPanel panel1 = new JPanel(); panel1.setLayout(new GridLayout(4, 1)); panel1.add(new JLabel("Date")); panel1.add(new JLabel("Day")); panel1.add(new JLabel("Month")); panel1.add(new JLabel("Year")); // Group spinners JPanel panel2 = new JPanel(); panel2.setLayout(new GridLayout(4, 1)); panel2.add(jspDate); panel2.add(jspDay); panel2.add(jspMonth); panel2.add(spinnerYear); // Add spinner and label to the UI add(panel1, BorderLayout.WEST); add(panel2, BorderLayout.CENTER); // Set editor for date JSpinner.DateEditor dateEditor = new JSpinner.DateEditor(jspDate, "MMM dd, yyyy"); jspDate.setEditor(dateEditor); // Set editor for year JSpinner.NumberEditor yearEditor = new JSpinner.NumberEditor(spinnerYear, "####"); spinnerYear.setEditor(yearEditor); // Update date to synchronize with the day, month, and year updateDate(); // Register and create a listener for jspDay jspDay.addChangeListener( new ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent e) { updateDate(); } }); // Register and create a listener for jspMonth jspMonth.addChangeListener( new ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent e) { updateDate(); } }); // Register and create a listener for spinnerYear spinnerYear.addChangeListener( new ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent e) { updateDate(); } }); }
protected JPanel createForm() { JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS)); // Time JPanel pT = new JPanel(new FlowLayout()); pT.setBorder(BorderFactory.createTitledBorder("Start Time")); hh = new JSpinner(new SpinnerNumberModel(Util.getHours(myrow.getTime()), 0, 99, 1)); hh.setEditor(new JSpinner.NumberEditor(hh, "00")); pT.add(hh); pT.add(new JLabel("h ")); mm = new JSpinner(new SpinnerNumberModel(Util.getMinutes(myrow.getTime()), 0, 59, 1)); mm.setEditor(new JSpinner.NumberEditor(mm, "00")); pT.add(mm); pT.add(new JLabel("m ")); ss = new JSpinner(new SpinnerNumberModel(Util.getSeconds(myrow.getTime()), 0, 59, 1)); ss.setEditor(new JSpinner.NumberEditor(ss, "00")); pT.add(ss); pT.add(new JLabel("s")); panel.add(pT); // Green JPanel pG = new JPanel(new BorderLayout()); pG.setBorder(BorderFactory.createTitledBorder("Green (sec.)")); green = new JSpinner(new SpinnerNumberModel(myrow.getGreen() * conversion, 0.0, 99999.99, 1)); green.setEditor(new JSpinner.NumberEditor(green, "####0.##")); pG.add(green); panel.add(pG); // Red JPanel pR = new JPanel(new BorderLayout()); pR.setBorder(BorderFactory.createTitledBorder("Red (sec.)")); red = new JSpinner(new SpinnerNumberModel(myrow.getRed() * conversion, 0.0, 99999.99, 1)); red.setEditor(new JSpinner.NumberEditor(red, "####0.##")); pR.add(red); panel.add(pR); JPanel bp = new JPanel(new FlowLayout()); JButton bOK = new JButton(" OK "); bOK.setActionCommand(cmdOK); bOK.addActionListener(new ButtonEventsListener()); JButton bCancel = new JButton("Cancel"); bCancel.setActionCommand(cmdCancel); bCancel.addActionListener(new ButtonEventsListener()); bp.add(bOK); bp.add(bCancel); panel.add(bp); return panel; }
static String[] input(int d, int m, int y) { // input frame for schedule String[] out = new String[4]; // appointment info storage final String[] doctors = {"Dr. Whitehead", "Dr. Namie", "Dr. Liddell"}; final JFrame input = new JFrame("Make Appointment"); Container pane1; JPanel pan = new JPanel(null); JLabel doctor = new JLabel("Choose your Doctor:"); JLabel da = new JLabel("Date:"); /*JLabel day=new JLabel(Integer.toString(d)); JLabel mo=new JLabel("Month:"); JLabel month=new JLabel(Integer.toString(m)); JLabel ye=new JLabel("Year:"); JLabel year=new JLabel(Integer.toString(y));*/ JLabel time = new JLabel("Appointment Time:"); JButton submit = new JButton("Submit"); docName = new JComboBox(doctors); JSpinner timeSpinner = new JSpinner(new SpinnerDateModel()); JSpinner.DateEditor timeEditor = new JSpinner.DateEditor(timeSpinner, "hh:mm a"); timeSpinner.setEditor(timeEditor); timeSpinner.setValue(new Date()); JSpinner dateSpinner = new JSpinner(new SpinnerDateModel()); JSpinner.DateEditor dateEditor = new JSpinner.DateEditor(dateSpinner, "MMM/dd/yyyy"); dateSpinner.setEditor(dateEditor); dateSpinner.setValue(new Date()); input.setSize(330, 375); // Set size to 400x400 pixels pane1 = input.getContentPane(); pane1.setLayout(null); // Apply null layout pan.setLayout(new GridLayout(4, 2, 20, 50)); pane1.setSize((int) (input.getHeight() / 2), (int) (input.getWidth() / 2)); pane1.setLocation( input.getHeight() - ((int) (input.getHeight() / 2)), input.getWidth() - ((int) (input.getWidth() / 2))); // trying to center failed input.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); // Close when X is clicked pane1.add(pan); // pan.add(ye); // pan.add(year); pan.add(da); pan.add(dateSpinner); pan.add(time); pan.add(timeSpinner); pan.add(doctor); pan.add(docName); pan.add(submit); submit.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { fmain.setVisible(true); input.setVisible(false); } }); pan.setBounds(0, 0, 320, 335); input.setResizable(false); input.setVisible(true); return out; }
public void init() { symbolData = new Icon[] { new ImageIcon(getClass().getResource("images/sym_square.gif")), new ImageIcon(getClass().getResource("images/sym_squarefilled.gif")), new ImageIcon(getClass().getResource("images/sym_circle.gif")), new ImageIcon(getClass().getResource("images/sym_circlefilled.gif")), new ImageIcon(getClass().getResource("images/sym_diamond.gif")), new ImageIcon(getClass().getResource("images/sym_diamondfilled.gif")), new ImageIcon(getClass().getResource("images/sym_triangle.gif")), new ImageIcon(getClass().getResource("images/sym_trianglefilled.gif")), new ImageIcon(getClass().getResource("images/sym_cross1.gif")), new ImageIcon(getClass().getResource("images/sym_cross2.gif")) }; mSymbolPopup = new JOAJComboBox(); for (int i = 0; i < symbolData.length; i++) { mSymbolPopup.addItem(symbolData[i]); } mSymbolPopup.setSelectedIndex(mCurrSymbol - 1); JPanel everyThingPanel = new JPanel(new BorderLayout(5, 5)); // create the two parameter chooser lists Container contents = this.getContentPane(); this.getContentPane().setLayout(new BorderLayout(5, 5)); JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout(5, 5)); JPanel paramPanel = new JPanel(new GridLayout(1, 2, 5, 5)); JPanel upperPanel = new JPanel(new BorderLayout(5, 5)); mYParamList = new StnParameterChooser(mFileViewer, new String("Stations Parameters:"), this, 5, "SALT"); OffsetPanel ofp = new OffsetPanel(this); mYParamList.init(); paramPanel.add(mYParamList); paramPanel.add(ofp); upperPanel.add("Center", paramPanel); everyThingPanel.add(BorderLayout.NORTH, upperPanel); // Options JPanel middlePanel = new JPanel(); middlePanel.setLayout(new ColumnLayout(Orientation.CENTER, Orientation.TOP, 3)); TitledBorder tb = BorderFactory.createTitledBorder(b.getString("kOptions")); if (JOAConstants.ISMAC) { // tb.setTitleFont(new Font("Helvetica", Font.PLAIN, 11)); } middlePanel.setBorder(tb); // containers for the non-advanced options JPanel nonAdvOptions = new JPanel(); nonAdvOptions.setLayout(new BorderLayout(5, 0)); JPanel ctrNonAdvOptions = new JPanel(); ctrNonAdvOptions.setLayout(new GridLayout(1, 2, 2, 2)); // plot axes goes in ctrNonAdvOptions JPanel axesOptions = new JPanel(); axesOptions.setLayout(new ColumnLayout(Orientation.LEFT, Orientation.CENTER, 0)); tb = BorderFactory.createTitledBorder(b.getString("kAxes")); if (JOAConstants.ISMAC) { // tb.setTitleFont(new Font("Helvetica", Font.PLAIN, 11)); } axesOptions.setBorder(tb); JPanel line0 = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); JPanel line1 = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); JPanel line3 = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); JPanel line33 = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); mConnectObs = new JOAJCheckBox(b.getString("kConnectObservations"), true); mReverseY = new JOAJCheckBox(b.getString("kReverseYAxis"), false); mReverseY.addItemListener(this); mPlotYGrid = new JOAJCheckBox(b.getString("kYGrid")); mPlotXGrid = new JOAJCheckBox(b.getString("kXGrid")); line0.add(mConnectObs); line1.add(mReverseY); line3.add(mPlotYGrid); line33.add(mPlotXGrid); axesOptions.add(line1); axesOptions.add(line3); axesOptions.add(line33); // other options JPanel otherOptions = new JPanel(); otherOptions.setLayout(new ColumnLayout(Orientation.LEFT, Orientation.CENTER, 0)); tb = BorderFactory.createTitledBorder(b.getString("kOther")); if (JOAConstants.ISMAC) { // tb.setTitleFont(new Font("Helvetica", Font.PLAIN, 11)); } otherOptions.setBorder(tb); // plot symbols JPanel line4 = new JPanel(); line4.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 0)); mEnableSymbols = new JOAJLabel(b.getString("kSymbol")); line4.add(mEnableSymbols); line4.add(mSymbolPopup); mSymbolPopup.addItemListener(this); mSizeLabel = new JOAJLabel(b.getString("kSize")); line4.add(mSizeLabel); SpinnerNumberModel model = new SpinnerNumberModel(4, 1, 100, 1); mSizeField = new JSpinner(model); line4.add(mSizeField); otherOptions.add(line0); otherOptions.add(line4); // add the axes and other panels to the gridlayout ctrNonAdvOptions.add(axesOptions); ctrNonAdvOptions.add(otherOptions); // add this panel to the north of the borderlayout nonAdvOptions.add("Center", ctrNonAdvOptions); JPanel colorNameContPanel = new JPanel(); colorNameContPanel.setLayout(new BorderLayout(0, 0)); JPanel colorNamePanel = new JPanel(); colorNamePanel.setLayout(new ColumnLayout(Orientation.LEFT, Orientation.CENTER, 0)); // swatches JPanel lineLCS = new JPanel(new FlowLayout(FlowLayout.RIGHT, 3, 0)); lineLCS.add(new JOAJLabel(b.getString("kLineColor"))); mLineColorSwatch = new Swatch(Color.black, 12, 12); lineLCS.add(new JOAJLabel(" ")); lineLCS.add(mLineColorSwatch); JPanel lineSCS = new JPanel(new FlowLayout(FlowLayout.RIGHT, 3, 0)); lineSCS.add(new JOAJLabel(b.getString("kSymbolColor"))); mSymbolColorSwatch = new Swatch(Color.black, 12, 12); lineSCS.add(new JOAJLabel(" ")); lineSCS.add(mSymbolColorSwatch); JPanel line7 = new JPanel(); line7.setLayout(new FlowLayout(FlowLayout.RIGHT, 3, 0)); line7.add(new JOAJLabel(b.getString("kBackgroundColor"))); plotBg = new Swatch(JOAConstants.DEFAULT_CONTENTS_COLOR, 12, 12); line7.add(new JOAJLabel(" ")); line7.add(plotBg); JPanel line8 = new JPanel(); line8.setLayout(new FlowLayout(FlowLayout.RIGHT, 3, 0)); line8.add(new JOAJLabel(b.getString("kGridColor"))); axesColor = new Swatch(Color.black, 12, 12); line8.add(new JOAJLabel(" ")); line8.add(axesColor); JPanel line9 = new JPanel(); line9.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 0)); line9.add(new JOAJLabel(b.getString("kColorSchemes"))); Vector<String> presetSchemes = new Vector<String>(); presetSchemes.addElement(b.getString("kDefault")); presetSchemes.addElement(b.getString("kWhiteBackground")); presetSchemes.addElement(b.getString("kBlackBackground")); presetColorSchemes = new JOAJComboBox(presetSchemes); presetColorSchemes.setSelectedItem(b.getString("kDefault")); presetColorSchemes.addItemListener(this); line9.add(presetColorSchemes); JPanel swatchCont = new JPanel(); swatchCont.setLayout(new GridLayout(4, 1, 0, 5)); swatchCont.add(lineLCS); swatchCont.add(lineSCS); swatchCont.add(line7); swatchCont.add(line8); JPanel swatchContCont = new JPanel(); swatchContCont.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 0)); swatchContCont.add(swatchCont); swatchContCont.add(line9); tb = BorderFactory.createTitledBorder(b.getString("kColors")); if (JOAConstants.ISMAC) { // tb.setTitleFont(new Font("Helvetica", Font.PLAIN, 11)); } swatchContCont.setBorder(tb); // window name JPanel namePanel = new JPanel(); namePanel.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 5)); namePanel.add(new JOAJLabel(b.getString("kWindowName"))); mNameField = new JOAJTextField(30); mNameField.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); namePanel.add(mNameField); // add the color panel colorNameContPanel.add("North", swatchContCont); colorNamePanel.add(colorNameContPanel); // add the name panel colorNamePanel.add(namePanel); // add these to the south of the borderlayout nonAdvOptions.add("South", colorNamePanel); // add all of this to the middle panel middlePanel.add(nonAdvOptions); // advanced options panel // axis container // y axis detail // container for the axes stuff plotScaleCont = new JPanel(new GridLayout(1, 2, 5, 5)); // y axis container JPanel yAxis = new JPanel(new ColumnLayout(Orientation.RIGHT, Orientation.CENTER, 2)); tb = BorderFactory.createTitledBorder(b.getString("kYAxis")); yAxis.setBorder(tb); StnPlotSpecification mPlotSpec = new StnPlotSpecification(); JPanel line5y = new JPanel(); line5y.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1)); line5y.add(new JOAJLabel(b.getString("kMinimum"))); yMin = new JOAJTextField(6); yMin.setText(JOAFormulas.formatDouble(String.valueOf(mPlotSpec.getWinYPlotMin()), 3, false)); yMin.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); line5y.add(yMin); JPanel line6y = new JPanel(); line6y.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1)); line6y.add(new JOAJLabel(b.getString("kMaximum"))); yMax = new JOAJTextField(6); yMax.setText(JOAFormulas.formatDouble(String.valueOf(mPlotSpec.getWinYPlotMax()), 3, false)); yMax.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); line6y.add(yMax); JPanel line7y = new JPanel(); line7y.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1)); line7y.add(new JOAJLabel(b.getString("kIncrement"))); yInc = new JOAJTextField(6); yInc.setText(JOAFormulas.formatDouble(String.valueOf(mPlotSpec.getYInc()), 3, false)); yInc.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); line7y.add(yInc); JPanel line8y = new JPanel(); line8y.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1)); line8y.add(new JOAJLabel(b.getString("kNoMinorTicks"))); SpinnerNumberModel model3 = new SpinnerNumberModel(mPlotSpec.getYTics(), 0, 100, 1); yTics = new JSpinner(model3); line8y.add(yTics); yAxis.add(line5y); yAxis.add(line6y); yAxis.add(line7y); yAxis.add(line8y); yAxis.add(new JLabel(" ")); yAxis.add(new JLabel(" ")); yAxis.add(new JLabel(" ")); plotScaleCont.add(yAxis); // x axis container JPanel xAxis = new JPanel(new ColumnLayout(Orientation.RIGHT, Orientation.CENTER, 2)); tb = BorderFactory.createTitledBorder(b.getString("kXAxis")); if (JOAConstants.ISMAC) { // tb.setTitleFont(new Font("Helvetica", Font.PLAIN, 11)); } xAxis.setBorder(tb); JPanel line5x = new JPanel(); line5x.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1)); line5x.add(mMinXLabel); xMin = new JOAJTextField(6); xMin.setText(JOAFormulas.formatDouble(String.valueOf(mPlotSpec.getWinXPlotMin()), 3, false)); xMin.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); line5x.add(xMin); JPanel minTime = new JPanel(new FlowLayout(FlowLayout.LEFT, 3, 1)); minTime.add(mMinXTLabel); JPanel maxTime = new JPanel(new FlowLayout(FlowLayout.LEFT, 3, 1)); maxTime.add(mMaxXTLabel); GeoDate minDate = new GeoDate(mFileViewer.getMinDate()); minDate.decrement(1.0, GeoDate.YEARS); GeoDate maxDate = new GeoDate(mFileViewer.getMaxDate()); maxDate.increment(1.0, GeoDate.YEARS); // value, start,end SpinnerDateModel mStartDateModel = new SpinnerDateModel( new GeoDate(mFileViewer.getMinDate()), minDate, maxDate, Calendar.HOUR); mStartSpinner = new JSpinner(mStartDateModel); JSpinner.DateEditor dateEditor = new JSpinner.DateEditor(mStartSpinner, "yyyy-MM-dd HH:mm"); mStartSpinner.setEditor(dateEditor); SpinnerDateModel mEndDateModel = new SpinnerDateModel( new GeoDate(mFileViewer.getMaxDate()), minDate, maxDate, Calendar.HOUR); mEndSpinner = new JSpinner(mEndDateModel); JSpinner.DateEditor dateEditor2 = new JSpinner.DateEditor(mEndSpinner, "yyyy-MM-dd HH:mm"); minTime.add(mStartSpinner); maxTime.add(mEndSpinner); mEndSpinner.setEditor(dateEditor2); JPanel line6x = new JPanel(); line6x.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1)); line6x.add(mMaxXLabel); xMax = new JOAJTextField(6); xMax.setText(JOAFormulas.formatDouble(String.valueOf(mPlotSpec.getWinXPlotMax()), 3, false)); xMax.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); line6x.add(xMax); JPanel line7x = new JPanel(); line7x.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1)); line7x.add(mIncLabel); xInc = new JOAJTextField(6); xInc.setText(JOAFormulas.formatDouble(String.valueOf(mPlotSpec.getXInc()), 3, false)); xInc.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); line7x.add(xInc); JPanel line8x = new JPanel(); line8x.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1)); line8x.add(mXIncLabel); SpinnerNumberModel model2 = new SpinnerNumberModel(mPlotSpec.getXTics(), 0, 100, 1); xTics = new JSpinner(model2); line8x.add(xTics); xAxis.add(minTime); xAxis.add(maxTime); xAxis.add(line5x); xAxis.add(line6x); xAxis.add(line7x); xAxis.add(line8x); plotScaleCont.add(xAxis); everyThingPanel.add(BorderLayout.CENTER, plotScaleCont); everyThingPanel.add(BorderLayout.SOUTH, middlePanel); mainPanel.add(BorderLayout.CENTER, new TenPixelBorder(everyThingPanel, 10, 10, 10, 10)); // lower panel mOKBtn = new JOAJButton(b.getString("kPlot")); mOKBtn.setActionCommand("ok"); this.getRootPane().setDefaultButton(mOKBtn); mCancelButton = new JOAJButton(b.getString("kCancel")); mCancelButton.setActionCommand("cancel"); JPanel dlgBtnsInset = new JPanel(); JPanel dlgBtnsPanel = new JPanel(); dlgBtnsInset.setLayout(new FlowLayout(FlowLayout.CENTER, 20, 1)); dlgBtnsPanel.setLayout(new GridLayout(1, 4, 15, 1)); if (JOAConstants.ISMAC) { dlgBtnsPanel.add(mCancelButton); dlgBtnsPanel.add(mOKBtn); } else { dlgBtnsPanel.add(mOKBtn); dlgBtnsPanel.add(mCancelButton); } dlgBtnsInset.add(dlgBtnsPanel); mOKBtn.addActionListener(this); mCancelButton.addActionListener(this); mainPanel.add(new TenPixelBorder(dlgBtnsInset, 5, 5, 5, 5), "South"); contents.add("Center", mainPanel); this.pack(); runTimer(); setXRangeToDistance(); // show dialog at center of screen Rectangle dBounds = this.getBounds(); Dimension sd = Toolkit.getDefaultToolkit().getScreenSize(); int x = sd.width / 2 - dBounds.width / 2; int y = sd.height / 2 - dBounds.height / 2; this.setLocation(x, y); }
@Override protected void createComponents() { super.createComponents(); Date initDate = DateUtils.currentDate(); Date latestDate = initDate; Date earliestDate = DateUtils.earliestDate(); entryDateLabel = new JLabel("Entry Date:"); entryDateSpinnerModel = new SpinnerDateModel(initDate, earliestDate, latestDate, Calendar.YEAR); entryDateSpinner = new JSpinner(entryDateSpinnerModel); entryDateSpinnerEditor = new JSpinner.DateEditor(entryDateSpinner, DateUtils.DATE_FORMAT); entryDateSpinner.setEditor(entryDateSpinnerEditor); entryDateSpinnerEditor .getTextField() .getDocument() .addDocumentListener( new DocumentListener() { @Override public void changedUpdate(DocumentEvent e) { return; } @Override public void insertUpdate(DocumentEvent e) { processChange(e); } @Override public void removeUpdate(DocumentEvent e) { processChange(e); } private void processChange(DocumentEvent e) { if (eventsAreDisabled()) { return; } if (entryDateSpinnerEditor.getTextField().hasFocus()) { entryDateChanged(); } } }); // entryDateSpinner.addChangeListener(new ChangeListener() { // @Override // public void stateChanged(ChangeEvent e) { // if (eventsAreDisabled()) { // return; // } // entryDateChanged(); // } // }); countLabel = new JLabel("Count:"); countField = new JTextField(5); countField.addKeyListener( new KeyListener() { @Override public void keyPressed(KeyEvent e) { return; } @Override public void keyReleased(KeyEvent e) { if (eventsAreDisabled()) { return; } countChanged(); } @Override public void keyTyped(KeyEvent arg0) { return; } }); }
/** Fills the panel with simple signal specific fields. */ protected void fillPanel() { if (controller != null) { Vector<CycleDataRow> cd = ((ControllerSimpleSignal) controller).getCycleTable(); for (int i = 0; i < cd.size(); i++) { CycleDataRow cdr = ((ControllerSimpleSignal) controller) .new CycleDataRow(cd.get(i).getTime(), cd.get(i).getGreen(), cd.get(i).getRed()); cycledata.add(cdr); } } // offset JPanel pO = new JPanel(new BorderLayout()); pO.setBorder(BorderFactory.createTitledBorder("Offset (sec.)")); offset = new JSpinner( new SpinnerNumberModel( ((ControllerSimpleSignal) controller).getOffset() * conversion, 0.0, 99999.99, 10)); offset.setEditor(new JSpinner.NumberEditor(offset, "####0.##")); pO.add(offset); add(pO); // table JPanel tabpanel = new JPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); tabpanel.setBorder(BorderFactory.createTitledBorder("Cycle Schedule")); cycletable = new JTable(cycletablemodel); cycletable.setPreferredScrollableViewportSize(new Dimension(200, 50)); cycletable.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { int row = cycletable.rowAtPoint(new Point(e.getX(), e.getY())); if ((row > cycledata.size() - 1) || (row < 0)) return; try { WindowEdit winEdit = new WindowEdit(null, cycledata.get(row)); winEdit.setVisible(true); cycletablemodel.deleterow(row); cycletablemodel.addrow(winEdit.getMyRow()); } catch (Exception excp) { } } } }); c.fill = GridBagConstraints.HORIZONTAL; c.ipady = 100; c.weightx = 0.5; c.gridwidth = 3; c.gridx = 0; c.gridy = 0; tabpanel.add(new JScrollPane(cycletable), c); c.ipady = 0; c.gridy = 1; c.gridwidth = 1; c.gridx = 0; tabpanel.add(buttonAdd, c); c.gridx = 1; tabpanel.add(buttonDelete, c); add(tabpanel); // configure buttons buttonAdd.setEnabled(true); buttonAdd.addActionListener(new ButtonAddListener()); buttonDelete.setEnabled(true); buttonDelete.addActionListener(new ButtonDeleteListener()); return; }