private void addListener(final JComponent component) { if (component instanceof JComboBox) { ItemListener itemListener = new ItemListener() { public void itemStateChanged(ItemEvent e) { JComboBox comboBox = (JComboBox) component; final Object selectedItem = comboBox.getSelectedItem(); _dotDefinitionDialogFrame .getScratchDisplayObjectType() .setValueOfStaticProperty(_primitiveForm.getName(), _property, selectedItem); } }; JComboBox comboBox = (JComboBox) component; comboBox.addItemListener(itemListener); } else if (component instanceof JSpinner) { javax.swing.event.ChangeListener changeListener = new javax.swing.event.ChangeListener() { public void stateChanged(ChangeEvent e) { JSpinner spinner = (JSpinner) component; final Object value = spinner.getValue(); _dotDefinitionDialogFrame .getScratchDisplayObjectType() .setValueOfStaticProperty(_primitiveForm.getName(), _property, value); } }; JSpinner spinner = (JSpinner) component; spinner.addChangeListener(changeListener); } }
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(); } }); }
private MainPanel() { super(new BorderLayout()); StringBuffer buf = new StringBuffer(); for (int i = 0; i < 100; i++) { String s = i + LF; buf.append(s); } final JScrollPane scrollPane = new JScrollPane(new JTextArea(buf.toString())); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); JSpinner spinner = new JSpinner( new SpinnerNumberModel( scrollPane.getVerticalScrollBar().getUnitIncrement(1), 1, 100000, 1)); spinner.setEditor(new JSpinner.NumberEditor(spinner, "#####0")); spinner.addChangeListener( new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { JSpinner s = (JSpinner) e.getSource(); scrollPane.getVerticalScrollBar().setUnitIncrement((Integer) s.getValue()); } }); Box box = Box.createHorizontalBox(); box.add(new JLabel("Unit Increment:")); box.add(Box.createHorizontalStrut(2)); box.add(spinner); box.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); add(box, BorderLayout.NORTH); add(scrollPane); setPreferredSize(new Dimension(320, 240)); }
protected void attachTo(Component jc) { if (extListener != null && extListener.accept(jc)) { extListener.startListeningTo(jc, extNotifier); listenedTo.add(jc); if (wizardPage.getMapKeyFor(jc) != null) { wizardPage.maybeUpdateMap(jc); } return; } if (isProbablyAContainer(jc)) { attachToHierarchyOf((Container) jc); } else if (jc instanceof JList) { listenedTo.add(jc); ((JList) jc).addListSelectionListener(this); } else if (jc instanceof JComboBox) { ((JComboBox) jc).addActionListener(this); } else if (jc instanceof JTree) { listenedTo.add(jc); ((JTree) jc).getSelectionModel().addTreeSelectionListener(this); } else if (jc instanceof JToggleButton) { ((AbstractButton) jc).addItemListener(this); } else if (jc instanceof JFormattedTextField) { // JFormattedTextField must be tested before JTextCompoent jc.addPropertyChangeListener("value", this); } else if (jc instanceof JTextComponent) { listenedTo.add(jc); ((JTextComponent) jc).getDocument().addDocumentListener(this); } else if (jc instanceof JColorChooser) { listenedTo.add(jc); ((JColorChooser) jc).getSelectionModel().addChangeListener(this); } else if (jc instanceof JSpinner) { ((JSpinner) jc).addChangeListener(this); } else if (jc instanceof JSlider) { ((JSlider) jc).addChangeListener(this); } else if (jc instanceof JTable) { listenedTo.add(jc); ((JTable) jc).getSelectionModel().addListSelectionListener(this); } else { if (logger.isLoggable(Level.FINE)) { logger.fine( "Don't know how to listen to a " + // NOI18N jc.getClass().getName()); } } if (accept(jc) && !(jc instanceof JPanel)) { jc.addPropertyChangeListener("name", this); if (wizardPage.getMapKeyFor(jc) != null) { wizardPage.maybeUpdateMap(jc); } } if (logger.isLoggable(Level.FINE) && accept(jc)) { logger.fine("Begin listening to " + jc); // NOI18N } }
private void createYearAndMonthPanal() { Calendar c = getNowCalendar(); int currentYear = c.get(Calendar.YEAR); int currentMonth = c.get(Calendar.MONTH) + 1; int currentHour = c.get(Calendar.HOUR_OF_DAY); yearSpin = new JSpinner(new javax.swing.SpinnerNumberModel(currentYear, startYear, lastYear, 1)); monthSpin = new JSpinner(new javax.swing.SpinnerNumberModel(currentMonth, 1, 12, 1)); hourSpin = new JSpinner(new javax.swing.SpinnerNumberModel(currentHour, 0, 23, 1)); yearPanel.setLayout(new java.awt.FlowLayout()); yearPanel.setBackground(controlLineColor); yearSpin.setPreferredSize(new Dimension(48, 20)); yearSpin.setName("Year"); yearSpin.setEditor(new JSpinner.NumberEditor(yearSpin, "####")); yearSpin.addChangeListener(this); yearPanel.add(yearSpin); JLabel yearLabel = new JLabel("年"); yearLabel.setForeground(controlTextColor); yearPanel.add(yearLabel); monthSpin.setPreferredSize(new Dimension(35, 20)); monthSpin.setName("Month"); monthSpin.addChangeListener(this); yearPanel.add(monthSpin); JLabel monthLabel = new JLabel("月"); monthLabel.setForeground(controlTextColor); yearPanel.add(monthLabel); hourSpin.setPreferredSize(new Dimension(35, 20)); hourSpin.setName("Hour"); hourSpin.addChangeListener(this); yearPanel.add(hourSpin); JLabel hourLabel = new JLabel("日"); hourLabel.setForeground(controlTextColor); yearPanel.add(hourLabel); }
private void configureSpinnerFloat(JSpinner spinner) { JSpinner.NumberEditor editor = (JSpinner.NumberEditor) spinner.getEditor(); DecimalFormat format = editor.getFormat(); format.setMinimumFractionDigits(3); format.setMinimumIntegerDigits(1); editor.getTextField().setHorizontalAlignment(SwingConstants.CENTER); Dimension d = spinner.getPreferredSize(); d.width = 60; spinner.setPreferredSize(d); spinner.addChangeListener(this); spinner.setMaximumSize(d); }
private void updateRefineSettings() { spinnerLineSamples.removeChangeListener(this); spinnerCornerOffset.removeChangeListener(this); spinnerSampleRadius.removeChangeListener(this); spinnerRefineMaxIterations.removeChangeListener(this); spinnerConvergeTol.removeChangeListener(this); spinnerMaxCornerChange.removeChangeListener(this); if (refineType == PolygonRefineType.LINE) { spinnerLineSamples.setValue(configLine.lineSamples); spinnerCornerOffset.setValue(configLine.cornerOffset); spinnerSampleRadius.setValue(configLine.sampleRadius); spinnerRefineMaxIterations.setValue(configLine.maxIterations); spinnerConvergeTol.setValue(configLine.convergeTolPixels); spinnerMaxCornerChange.setValue(configLine.maxCornerChangePixel); } else if (refineType == PolygonRefineType.CORNER) { spinnerLineSamples.setValue(configCorner.lineSamples); spinnerCornerOffset.setValue(configCorner.cornerOffset); spinnerSampleRadius.setValue(configCorner.sampleRadius); spinnerRefineMaxIterations.setValue(configCorner.maxIterations); spinnerConvergeTol.setValue(configCorner.convergeTolPixels); spinnerMaxCornerChange.setValue(configCorner.maxCornerChangePixel); } spinnerLineSamples.addChangeListener(this); spinnerCornerOffset.addChangeListener(this); spinnerSampleRadius.addChangeListener(this); spinnerRefineMaxIterations.addChangeListener(this); spinnerConvergeTol.addChangeListener(this); spinnerMaxCornerChange.addChangeListener(this); }
private void addChangeListeners() { ChangeListener translationChangeListener = new ChangeListener() { public void stateChanged(ChangeEvent e) { _dotDefinitionDialogFrame.setSomethingChanged(true); } }; _translationFactorSpinner.addChangeListener(translationChangeListener); ChangeListener joinByLineChangeListener = new ChangeListener() { public void stateChanged(ChangeEvent e) { _dotDefinitionDialogFrame.setSomethingChanged(true); } }; _joinByLineCheckBox.addChangeListener(joinByLineChangeListener); }
private void setUpA1(List<DataSet> dataSets, Box a1) { int[] shifts = params.getShifts(); if (shifts.length != dataSets.get(0).getNumColumns()) { shifts = new int[dataSets.get(0).getNumColumns()]; params.setShifts(shifts); } final int[] _shifts = shifts; for (int i = 0; i < dataSets.get(0).getNumColumns(); i++) { Node node = dataSets.get(0).getVariable(i); Box a5 = Box.createHorizontalBox(); SpinnerModel shiftModel = new SpinnerNumberModel(_shifts[i], -50, 50, 1); JSpinner shiftSpinner = new JSpinner(shiftModel); shiftSpinner.setMaximumSize(shiftSpinner.getPreferredSize()); final int nodeIndex = i; shiftSpinner.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { JSpinner spinner = (JSpinner) e.getSource(); SpinnerNumberModel model = (SpinnerNumberModel) spinner.getModel(); int value = (Integer) model.getValue(); _shifts[nodeIndex] = value; params.setShifts(_shifts); } }); a5.add(new JLabel(" Shift for ")); a5.add(new JLabel(node.getName())); a5.add(new JLabel(" is ")); a5.add(shiftSpinner); a5.add(Box.createHorizontalGlue()); a1.add(a5); } }
private void addEventListener() { btn.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { int year = cal.get(Calendar.YEAR); int month = cal.get(Calendar.MONTH); String date = lastLabel.getText(); String str2 = month + 1 + ""; String str3 = date; if (month + 1 < 10) { str2 = "0" + (month + 1); } if (Integer.valueOf(date) < 10) { str3 = "0" + date; } text.setText(year + "-" + str2 + "-" + str3); MySimpleCal.this.dispose(); } }); monthBox.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { resetPanel(); } }); yearSpi.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { resetPanel(); } }); }
public void setSpinnerSemester(JSpinner spinnerSemester) { this.spinnerSemester = spinnerSemester; java.util.List<Semester> semesterList = svmContext.getSvmModel().getSemestersAll(); if (semesterList.isEmpty()) { // keine Semester erfasst SpinnerModel spinnerModel = new SpinnerListModel(new String[] {""}); spinnerSemester.setModel(spinnerModel); spinnerSemester.setEnabled(false); return; } Semester[] semesters = semesterList.toArray(new Semester[semesterList.size()]); SpinnerModel spinnerModelSemester = new SpinnerListModel(semesters); spinnerSemester.setModel(spinnerModelSemester); spinnerSemester.addChangeListener( new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { onSemesterSelected(); } }); // Model initialisieren kurseSemesterwahlModel.setSemester( kurseSemesterwahlModel.getInitSemester(svmContext.getSvmModel())); }
public ParameterConfigurationPanel(String name, SensorType type) { this.type = type; this.name = name; setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); add(new Label(name)); typeList = new JComboBox(controlTypes); typeList.addActionListener( new AbstractAction() { public void actionPerformed(ActionEvent e) { setType((String) typeList.getSelectedItem()); configure(); } }); add(typeList); add(new Label("channel")); channel = new JSpinner(new SpinnerNumberModel(1, 1, 16, 1)); channel.setValue(1); channel.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { configure(); } }); add(channel); add(new Label("cc")); cc = new JSpinner(new SpinnerNumberModel(21, 1, 127, 1)); cc.setValue(21); cc.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { configure(); } }); add(cc); add(new Label("min")); min = new JSpinner(); min.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { configure(); } }); add(min); add(new Label("max")); max = new JSpinner(); max.setValue(127); max.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { configure(); } }); add(max); JButton button = new JButton("invert"); button.addActionListener( new AbstractAction() { public void actionPerformed(ActionEvent e) { int saved = (Integer) min.getValue(); min.setValue(max.getValue()); max.setValue(saved); } }); add(button); modeList = new JComboBox(eventhandler.getModeNames()); modeList.addActionListener( new AbstractAction() { public void actionPerformed(ActionEvent e) { configure(); } }); add(modeList); }
public NumberField(NumberOption option) { super(option); panel = new JPanel(new GridBagLayout()); this.step = option.getStep(); Double min = option.getMin(); Double max = option.getMax(); Double defl = new Double(option.getDefault()); // Normalize parameters if (min != null && defl.compareTo(min) < 0) { defl = min; } else if (max != null && defl.compareTo(max) > 0) { defl = max; } if (min != null) { sliderMin = (int) (min.doubleValue() / step); } else { sliderMin = SLIDER_DEFAULT_MIN; } if (max != null) { sliderMax = (int) (max.doubleValue() / step); } else { sliderMax = SLIDER_DEFAULT_MAX; } // Create spinner SpinnerNumberModel spinnerModel = new SpinnerNumberModel(defl, min, max, new Double(step)); spinner = new JSpinner(spinnerModel); ((JSpinner.DefaultEditor) spinner.getEditor()).getTextField().setColumns(FIELD_WIDTH); // Create slider slider = new JSlider(sliderMin, sliderMax, sliderIndex(defl)); slider.setPaintLabels(false); slider.setPaintTicks(false); slider.setSnapToTicks(false); // Add listeners. The spinner is the master and the slider is // the slave. spinner.addChangeListener( new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { int newIndex = sliderIndex((Double) spinner.getValue()); if (slider.getValue() != newIndex) { slider.setValue(newIndex); } fireChangeEvent(); } }); slider.addChangeListener( new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { int newIndex = slider.getValue(); if (newIndex != sliderIndex((Double) spinner.getValue())) { spinner.setValue(new Double(newIndex * step)); } } }); // Create enable checkbox configureEnableToggle( option.isInitiallyEnabled(), string(option.getDisabledValue()), Arrays.asList((JComponent) spinner, slider)); // Add to the panel panel.add(spinner); GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(0, 8, 0, 0); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; panel.add(slider, c); }
/** Fills the panel with event specific fields. */ protected void fillPanel() { JLabel l; Box fdp = Box.createVerticalBox(); fdp.setBorder(BorderFactory.createTitledBorder("Fundamental Diagram")); fdChart = makeFDChart(); ChartPanel cp = new ChartPanel(fdChart); cp.setMinimumDrawWidth(100); cp.setMinimumDrawHeight(60); cp.setPreferredSize(new Dimension(250, 80)); fdp.add(new JScrollPane(cp)); JPanel prmp = new JPanel(new SpringLayout()); l = new JLabel("Capacity:", JLabel.TRAILING); prmp.add(l); spinMaxFlow = new JSpinner(new SpinnerNumberModel(mf, 0, 99999, 1.0)); spinMaxFlow.setEditor(new JSpinner.NumberEditor(spinMaxFlow, "####0.00")); spinMaxFlow.addChangeListener(this); spinMaxFlow.setName(nmSpinMaxFlow); l.setLabelFor(spinMaxFlow); prmp.add(spinMaxFlow); l = new JLabel("Cap.Drop:", JLabel.TRAILING); prmp.add(l); spinCapDrop = new JSpinner(new SpinnerNumberModel(drp, 0, 99999, 1.0)); spinCapDrop.setEditor(new JSpinner.NumberEditor(spinCapDrop, "####0.00")); spinCapDrop.addChangeListener(this); spinCapDrop.setName(nmSpinCapDrop); l.setLabelFor(spinCapDrop); prmp.add(spinCapDrop); l = new JLabel("C.Density:", JLabel.TRAILING); prmp.add(l); spinCritDen = new JSpinner(new SpinnerNumberModel(cd, 0, 99999, 1.0)); spinCritDen.setEditor(new JSpinner.NumberEditor(spinCritDen, "####0.00")); spinCritDen.addChangeListener(this); spinCritDen.setName(nmSpinCritDen); l.setLabelFor(spinCritDen); prmp.add(spinCritDen); l = new JLabel(" V:", JLabel.TRAILING); prmp.add(l); spinVff = new JSpinner(new SpinnerNumberModel(mf / cd, 0, 200, 1.0)); spinVff.setEditor(new JSpinner.NumberEditor(spinVff, "#0.00")); spinVff.addChangeListener(this); spinVff.setName(nmSpinVff); l.setLabelFor(spinVff); prmp.add(spinVff); l = new JLabel("J.Density:", JLabel.TRAILING); prmp.add(l); spinJamDen = new JSpinner(new SpinnerNumberModel(jd, 0, 99999, 1.0)); spinJamDen.setEditor(new JSpinner.NumberEditor(spinJamDen, "####0.00")); spinJamDen.addChangeListener(this); spinJamDen.setName(nmSpinJamDen); l.setLabelFor(spinJamDen); prmp.add(spinJamDen); l = new JLabel(" W:", JLabel.TRAILING); prmp.add(l); if (jd == cd) jd = cd + 1; int ulim = (int) Math.max(Math.ceil(mf / (jd - cd)), 999); spinWc = new JSpinner(new SpinnerNumberModel(mf / (jd - cd), 0, ulim, 1.0)); spinWc.setEditor(new JSpinner.NumberEditor(spinWc, "#0.00")); spinWc.addChangeListener(this); spinWc.setName(nmSpinWc); l.setLabelFor(spinWc); prmp.add(spinWc); SpringUtilities.makeCompactGrid(prmp, 3, 4, 2, 2, 2, 2); fdp.add(prmp); // add(new JScrollPane(fdp)); add(fdp); return; }
@SuppressWarnings("deprecation") NPCPane(SpritesNPCManager mgr, int NPCIndex) { myIndex = NPCIndex; setBorder(new TitledBorder(null, "NPC", TitledBorder.LEADING, TitledBorder.TOP, null, null)); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); lblSpriteSet = new JLabel("Spriteset:"); add(lblSpriteSet); lblSpriteSet.setBounds(10, 38, lblSpriteSet.getText().length() * 8, 16); Rectangle r = lblSpriteSet.getBounds(); txtSpriteSet = new JSpinner(new SpinnerNumberModel(0, 0, 255, 1)); txtSpriteSet.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { Save(MapIO.loadedMap.mapNPCManager); } }); add(txtSpriteSet); txtSpriteSet.setBounds(90, 38, 87, 16); // txtSpriteSet.disable(); lblBehavior1 = new JLabel("Behavior1:"); add(lblBehavior1); lblBehavior1.setBounds(10, 54, lblBehavior1.getText().length() * 8, 16); r = lblBehavior1.getBounds(); txtBehavior1 = new JTextField(); txtBehavior1.setColumns(2); add(txtBehavior1); txtBehavior1.setBounds(90, 54, 32, 16); lblBehavior2 = new JLabel("Behavior2:"); add(lblBehavior2); lblBehavior2.setBounds(10, 70, lblBehavior2.getText().length() * 8, 16); r = lblBehavior2.getBounds(); txtBehavior2 = new JTextField(); txtBehavior2.setColumns(2); add(txtBehavior2); txtBehavior2.setBounds(90, 70, 64, 16); lblIsTrainer = new JLabel("Is a Trainer:"); add(lblIsTrainer); lblIsTrainer.setBounds(10, 86, lblIsTrainer.getText().length() * 8, 16); r = lblIsTrainer.getBounds(); chkIsTrainer = new JCheckBox(); add(chkIsTrainer); chkIsTrainer.setBounds(114, 86, 32, 16); lblTrainerLOS = new JLabel("TrainerLOS:"); add(lblTrainerLOS); lblTrainerLOS.setBounds(10, 102, lblTrainerLOS.getText().length() * 8, 16); r = lblTrainerLOS.getBounds(); txtTrainerLOS = new JTextField(); txtTrainerLOS.setColumns(3); add(txtTrainerLOS); txtTrainerLOS.setBounds(90, 102, 32, 16); lbliFlag = new JLabel("NPC Flag:"); add(lbliFlag); lbliFlag.setBounds(10, 128, 88, 16); txtiFlag = new JTextField(); txtiFlag.setColumns(4); add(txtiFlag); txtiFlag.setText("0"); txtiFlag.setBounds(90, 128, 32, 16); lblScript = new JLabel("NPC Script Pointer:"); add(lblScript); lblScript.setBounds(10, 150, 88, 16); txtScript = new JTextField(); txtScript.setColumns(9); add(txtScript); txtScript.setText("0"); txtScript.setBounds(90, 150, 32, 16); JButton btnSave = new JButton("Save"); btnSave.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { Save(MapIO.loadedMap.mapNPCManager); } }); add(btnSave); btnSave.setBounds(55, 163, 89, 23); Load(mgr, NPCIndex); }
/** * Creates the video advanced settings. * * @return video advanced settings panel. */ private static Component createVideoAdvancedSettings() { ResourceManagementService resources = NeomediaActivator.getResources(); final DeviceConfiguration deviceConfig = mediaService.getDeviceConfiguration(); TransparentPanel centerPanel = new TransparentPanel(new GridBagLayout()); centerPanel.setMaximumSize(new Dimension(WIDTH, 150)); JButton resetDefaultsButton = new JButton(resources.getI18NString("impl.media.configform.VIDEO_RESET")); JPanel resetButtonPanel = new TransparentPanel(new FlowLayout(FlowLayout.RIGHT)); resetButtonPanel.add(resetDefaultsButton); final JPanel centerAdvancedPanel = new TransparentPanel(new BorderLayout()); centerAdvancedPanel.add(centerPanel, BorderLayout.NORTH); centerAdvancedPanel.add(resetButtonPanel, BorderLayout.SOUTH); GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.anchor = GridBagConstraints.NORTHWEST; constraints.insets = new Insets(5, 5, 0, 0); constraints.gridx = 0; constraints.weightx = 0; constraints.weighty = 0; constraints.gridy = 0; centerPanel.add( new JLabel(resources.getI18NString("impl.media.configform.VIDEO_RESOLUTION")), constraints); constraints.gridy = 1; constraints.insets = new Insets(0, 0, 0, 0); final JCheckBox frameRateCheck = new SIPCommCheckBox(resources.getI18NString("impl.media.configform.VIDEO_FRAME_RATE")); centerPanel.add(frameRateCheck, constraints); constraints.gridy = 2; constraints.insets = new Insets(5, 5, 0, 0); centerPanel.add( new JLabel(resources.getI18NString("impl.media.configform.VIDEO_PACKETS_POLICY")), constraints); constraints.weightx = 1; constraints.gridx = 1; constraints.gridy = 0; constraints.insets = new Insets(5, 0, 0, 5); Object[] resolutionValues = new Object[DeviceConfiguration.SUPPORTED_RESOLUTIONS.length + 1]; System.arraycopy( DeviceConfiguration.SUPPORTED_RESOLUTIONS, 0, resolutionValues, 1, DeviceConfiguration.SUPPORTED_RESOLUTIONS.length); final JComboBox sizeCombo = new JComboBox(resolutionValues); sizeCombo.setRenderer(new ResolutionCellRenderer()); sizeCombo.setEditable(false); centerPanel.add(sizeCombo, constraints); // default value is 20 final JSpinner frameRate = new JSpinner(new SpinnerNumberModel(20, 5, 30, 1)); frameRate.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { deviceConfig.setFrameRate( ((SpinnerNumberModel) frameRate.getModel()).getNumber().intValue()); } }); constraints.gridy = 1; constraints.insets = new Insets(0, 0, 0, 5); centerPanel.add(frameRate, constraints); frameRateCheck.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (frameRateCheck.isSelected()) { deviceConfig.setFrameRate( ((SpinnerNumberModel) frameRate.getModel()).getNumber().intValue()); } else // unlimited framerate deviceConfig.setFrameRate(-1); frameRate.setEnabled(frameRateCheck.isSelected()); } }); final JSpinner videoMaxBandwidth = new JSpinner( new SpinnerNumberModel(deviceConfig.getVideoMaxBandwidth(), 1, Integer.MAX_VALUE, 1)); videoMaxBandwidth.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { deviceConfig.setVideoMaxBandwidth( ((SpinnerNumberModel) videoMaxBandwidth.getModel()).getNumber().intValue()); } }); constraints.gridx = 1; constraints.gridy = 2; constraints.insets = new Insets(0, 0, 5, 5); centerPanel.add(videoMaxBandwidth, constraints); resetDefaultsButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { // reset to defaults sizeCombo.setSelectedIndex(0); frameRateCheck.setSelected(false); frameRate.setEnabled(false); frameRate.setValue(20); // unlimited framerate deviceConfig.setFrameRate(-1); videoMaxBandwidth.setValue(DeviceConfiguration.DEFAULT_VIDEO_MAX_BANDWIDTH); } }); // load selected value or auto Dimension videoSize = deviceConfig.getVideoSize(); if ((videoSize.getHeight() != DeviceConfiguration.DEFAULT_VIDEO_HEIGHT) && (videoSize.getWidth() != DeviceConfiguration.DEFAULT_VIDEO_WIDTH)) sizeCombo.setSelectedItem(deviceConfig.getVideoSize()); else sizeCombo.setSelectedIndex(0); sizeCombo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { Dimension selectedVideoSize = (Dimension) sizeCombo.getSelectedItem(); if (selectedVideoSize == null) { // the auto value, default one selectedVideoSize = new Dimension( DeviceConfiguration.DEFAULT_VIDEO_WIDTH, DeviceConfiguration.DEFAULT_VIDEO_HEIGHT); } deviceConfig.setVideoSize(selectedVideoSize); } }); frameRateCheck.setSelected( deviceConfig.getFrameRate() != DeviceConfiguration.DEFAULT_VIDEO_FRAMERATE); frameRate.setEnabled(frameRateCheck.isSelected()); if (frameRate.isEnabled()) frameRate.setValue(deviceConfig.getFrameRate()); return centerAdvancedPanel; }
public DetectPolygonControlPanel(DetectBlackPolygonApp owner) { this.owner = owner; imageView = new JComboBox(); imageView.addItem("Input"); imageView.addItem("Binary"); imageView.addItem("Black"); imageView.addActionListener(this); imageView.setMaximumSize(imageView.getPreferredSize()); selectZoom = new JSpinner(new SpinnerNumberModel(1, 0.1, 50, 1)); selectZoom.addChangeListener(this); selectZoom.setMaximumSize(selectZoom.getPreferredSize()); showCorners = new JCheckBox("Corners"); showCorners.addActionListener(this); showCorners.setSelected(bShowCorners); showLines = new JCheckBox("Lines"); showLines.setSelected(bShowLines); showLines.addActionListener(this); showContour = new JCheckBox("Contour"); showContour.addActionListener(this); showContour.setSelected(bShowContour); threshold = new ThresholdControlPanel(owner); refineChoice = new JComboBox(); for (PolygonRefineType n : PolygonRefineType.values()) { refineChoice.addItem(n.name()); } refineChoice.setSelectedIndex(refineType.ordinal()); refineChoice.addActionListener(this); refineChoice.setMaximumSize(refineChoice.getPreferredSize()); spinnerMinContourSize = new JSpinner(new SpinnerNumberModel(config.minContourImageWidthFraction, 0.0, 0.2, 0.01)); configureSpinnerFloat(spinnerMinContourSize); spinnerMinSides = new JSpinner(new SpinnerNumberModel(minSides, 3, 20, 1)); spinnerMinSides.setMaximumSize(spinnerMinSides.getPreferredSize()); spinnerMinSides.addChangeListener(this); spinnerMaxSides = new JSpinner(new SpinnerNumberModel(maxSides, 3, 20, 1)); spinnerMaxSides.setMaximumSize(spinnerMaxSides.getPreferredSize()); spinnerMaxSides.addChangeListener(this); spinnerMinEdge = new JSpinner(new SpinnerNumberModel(config.minimumEdgeIntensity, 0.0, 255.0, 1.0)); spinnerMinEdge.setMaximumSize(spinnerMinEdge.getPreferredSize()); spinnerMinEdge.addChangeListener(this); spinnerContourSplit = new JSpinner(new SpinnerNumberModel(config.contour2Poly_splitFraction, 0.0, 1.0, 0.01)); configureSpinnerFloat(spinnerContourSplit); spinnerContourMinSplit = new JSpinner( new SpinnerNumberModel(config.contour2Poly_minimumSideFraction, 0.0, 1.0, 0.001)); configureSpinnerFloat(spinnerContourMinSplit); spinnerContourSplit.addChangeListener(this); spinnerContourIterations = new JSpinner(new SpinnerNumberModel(config.contour2Poly_iterations, 1, 200, 1)); spinnerContourIterations.setMaximumSize(spinnerContourIterations.getPreferredSize()); spinnerContourIterations.addChangeListener(this); spinnerSplitPenalty = new JSpinner(new SpinnerNumberModel(config.splitPenalty, 0.0, 100.0, 1.0)); configureSpinnerFloat(spinnerSplitPenalty); setConvex = new JCheckBox("Convex"); setConvex.addActionListener(this); setConvex.setSelected(config.convex); setBorder = new JCheckBox("Image Border"); setBorder.addActionListener(this); setBorder.setSelected(config.canTouchBorder); spinnerLineSamples = new JSpinner(new SpinnerNumberModel(configLine.lineSamples, 5, 100, 1)); spinnerLineSamples.setMaximumSize(spinnerLineSamples.getPreferredSize()); spinnerLineSamples.addChangeListener(this); spinnerCornerOffset = new JSpinner(new SpinnerNumberModel(configLine.cornerOffset, 0, 10, 1)); spinnerCornerOffset.setMaximumSize(spinnerCornerOffset.getPreferredSize()); spinnerCornerOffset.addChangeListener(this); spinnerSampleRadius = new JSpinner(new SpinnerNumberModel(configLine.sampleRadius, 0, 10, 1)); spinnerSampleRadius.setMaximumSize(spinnerCornerOffset.getPreferredSize()); spinnerSampleRadius.addChangeListener(this); spinnerRefineMaxIterations = new JSpinner(new SpinnerNumberModel(configLine.maxIterations, 0, 200, 1)); spinnerRefineMaxIterations.setMaximumSize(spinnerRefineMaxIterations.getPreferredSize()); spinnerRefineMaxIterations.addChangeListener(this); spinnerConvergeTol = new JSpinner(new SpinnerNumberModel(configLine.convergeTolPixels, 0.0, 2.0, 0.005)); configureSpinnerFloat(spinnerConvergeTol); spinnerMaxCornerChange = new JSpinner(new SpinnerNumberModel(configLine.maxCornerChangePixel, 0.0, 50.0, 1.0)); configureSpinnerFloat(spinnerMaxCornerChange); addLabeled(imageView, "View: ", this); addLabeled(selectZoom, "Zoom", this); addAlignLeft(showCorners, this); addAlignLeft(showLines, this); addAlignLeft(showContour, this); add(threshold); addLabeled(spinnerMinContourSize, "Min Contour Size: ", this); addLabeled(spinnerMinSides, "Minimum Sides: ", this); addLabeled(spinnerMaxSides, "Maximum Sides: ", this); addLabeled(spinnerMinEdge, "Edge Intensity: ", this); addAlignLeft(setConvex, this); addAlignLeft(setBorder, this); addCenterLabel("Contour", this); addLabeled(spinnerContourSplit, "Split Fraction: ", this); addLabeled(spinnerContourMinSplit, "Min Split: ", this); addLabeled(spinnerContourIterations, "Max Iterations: ", this); addLabeled(spinnerSplitPenalty, "Split Penalty: ", this); addCenterLabel("Refinement", this); addLabeled(refineChoice, "Refine: ", this); addLabeled(spinnerLineSamples, "Line Samples: ", this); addLabeled(spinnerCornerOffset, "Corner Offset: ", this); addLabeled(spinnerSampleRadius, "Sample Radius: ", this); addLabeled(spinnerRefineMaxIterations, "Iterations: ", this); addLabeled(spinnerConvergeTol, "Converge Tol Pixels: ", this); addLabeled(spinnerMaxCornerChange, "Max Corner Change: ", this); addVerticalGlue(this); }
protected JSpinner buildSpinner() { JSpinner s = new JSpinner(); s.addChangeListener(this.buildChangeListener()); return s; }
/** Builds the panel. */ public void setup() { DataModelList dataModelList = null; for (Object parentModel : parentModels) { if (parentModel instanceof DataWrapper) { DataWrapper dataWrapper = (DataWrapper) parentModel; dataModelList = dataWrapper.getDataModelList(); } } if (dataModelList == null) { throw new NullPointerException("Null data model list."); } for (DataModel model : dataModelList) { if (!(model instanceof DataSet)) { JOptionPane.showMessageDialog( JOptionUtils.centeringComp(), "For the shift search, all of the data in the data box must be in the form of data sets."); return; } } final List<DataSet> dataSets = new ArrayList<DataSet>(); for (Object aDataModelList : dataModelList) { dataSets.add((DataSet) aDataModelList); } SpinnerModel maxVarsModel = new SpinnerNumberModel( Preferences.userRoot().getInt("shiftSearchMaxNumShifts", 3), 1, 50, 1); JSpinner maxVarsSpinner = new JSpinner(maxVarsModel); maxVarsSpinner.setMaximumSize(maxVarsSpinner.getPreferredSize()); maxVarsSpinner.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { JSpinner spinner = (JSpinner) e.getSource(); SpinnerNumberModel model = (SpinnerNumberModel) spinner.getModel(); int value = (Integer) model.getValue(); Preferences.userRoot().putInt("shiftSearchMaxNumShifts", value); } }); SpinnerModel maxShiftModel = new SpinnerNumberModel(Preferences.userRoot().getInt("shiftSearchMaxShift", 2), 1, 50, 1); JSpinner maxShiftSpinner = new JSpinner(maxShiftModel); maxShiftSpinner.setMaximumSize(maxShiftSpinner.getPreferredSize()); maxShiftSpinner.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { JSpinner spinner = (JSpinner) e.getSource(); SpinnerNumberModel model = (SpinnerNumberModel) spinner.getModel(); int value = (Integer) model.getValue(); Preferences.userRoot().putInt("shiftSearchMaxShift", value); } }); JButton searchButton = new JButton("Search"); final JButton stopButton = new JButton("Stop"); final JTextArea textArea = new JTextArea(); JScrollPane textScroll = new JScrollPane(textArea); textScroll.setPreferredSize(new Dimension(500, 200)); searchButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { final Thread thread = new Thread() { public void run() { textArea.setText(""); doShiftSearch(dataSets, textArea); } }; thread.start(); } }); stopButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { if (search != null) { search.stop(); } } }); JComboBox directionBox = new JComboBox(new String[] {"forward", "backward"}); directionBox.setSelectedItem(params.isForwardSearch() ? "forward" : "backward"); directionBox.setMaximumSize(directionBox.getPreferredSize()); directionBox.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { JComboBox source = (JComboBox) actionEvent.getSource(); String selected = (String) source.getSelectedItem(); params.setForwardSearch("forward".equals(selected)); } }); Box b1 = Box.createVerticalBox(); Box b2 = Box.createHorizontalBox(); b2.add(new JLabel("Maximum number of variables in shift set is: ")); b2.add(maxVarsSpinner); b2.add(Box.createHorizontalGlue()); b1.add(b2); Box b3 = Box.createHorizontalBox(); b3.add(new JLabel("Maximum ")); b3.add(directionBox); b3.add(new JLabel(" shift: ")); b3.add(maxShiftSpinner); b3.add(Box.createHorizontalGlue()); b1.add(b3); Box b4 = Box.createHorizontalBox(); b4.add(new JLabel("Output:")); b4.add(Box.createHorizontalGlue()); b1.add(b4); Box b5 = Box.createHorizontalBox(); b5.add(textScroll); b1.add(b5); Box b6 = Box.createHorizontalBox(); b6.add(searchButton); b6.add(stopButton); b1.add(b6); final Box a1 = Box.createVerticalBox(); Box a2 = Box.createHorizontalBox(); a2.add(new JLabel("Specify the shift (positive or negative) for each variable:")); a2.add(Box.createHorizontalGlue()); a1.add(a2); a1.add(Box.createVerticalStrut(20)); setUpA1(dataSets, a1); JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addTab("Shift", new JScrollPane(a1)); tabbedPane.addTab("Search", new JScrollPane(b1)); add(tabbedPane, BorderLayout.CENTER); tabbedPane.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent changeEvent) { System.out.println("a1 shown"); a1.removeAll(); setUpA1(dataSets, a1); } }); }
public Component getCustomOptionComponent() { /* DEPTH */ final JSpinner jspnMaxDepth = new JSpinner(new SpinnerNumberModel(s_maxDepth + 1, 1, 100, 1)); jspnMaxDepth.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { Integer value = (Integer) ((JSpinner) e.getSource()).getValue(); s_maxDepth = value - 1; logger.debug("maxDepth " + (s_maxDepth + 1)); } }); final JRadioButton jrbMaxDepth = new JRadioButton("Depth"); final JLabel lblMaxDepth = new JLabel("Depth: "); final JPanel jpMaxDepthSub = new JPanel() { @Override public void setEnabled(boolean b) { super.setEnabled(b); jspnMaxDepth.setEnabled(b); lblMaxDepth.setEnabled(b); } }; jpMaxDepthSub.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 0)); jpMaxDepthSub.add(lblMaxDepth); jpMaxDepthSub.add(jspnMaxDepth); /// final JPanel jpMaxDepth = new JPanel() { @Override public void setEnabled(boolean b) { super.setEnabled(b); jrbMaxDepth.setEnabled(b); jpMaxDepthSub.setEnabled(b); } }; jpMaxDepth.setLayout(new BoxLayout(jpMaxDepth, BoxLayout.Y_AXIS)); jpMaxDepth.add(GuiUtil.addComponentAsFlow(jrbMaxDepth, FlowLayout.LEFT)); jpMaxDepth.add(GuiUtil.addComponentAsFlow(jpMaxDepthSub, FlowLayout.RIGHT)); /* REPETITION */ final JSpinner jspnMaxRept = new JSpinner(new SpinnerNumberModel(s_maxRept, 1, 100, 1)); jspnMaxRept.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { s_maxRept = (Integer) ((JSpinner) e.getSource()).getValue(); logger.debug("maxRept " + s_maxRept); } }); final JRadioButton jrbMaxRept = new JRadioButton("Repetition"); final JLabel lblMaxRept = new JLabel("Count: "); final JPanel jpMaxReptSub = new JPanel() { @Override public void setEnabled(boolean b) { super.setEnabled(b); jspnMaxRept.setEnabled(b); lblMaxRept.setEnabled(b); } }; jpMaxReptSub.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 0)); jpMaxReptSub.add(lblMaxRept); jpMaxReptSub.add(jspnMaxRept); final JPanel jpMaxRept = new JPanel() { @Override public void setEnabled(boolean b) { super.setEnabled(b); jrbMaxRept.setEnabled(b); jpMaxReptSub.setEnabled(b); } }; jpMaxRept.setLayout(new BoxLayout(jpMaxRept, BoxLayout.Y_AXIS)); jpMaxRept.add(GuiUtil.addComponentAsFlow(jrbMaxRept, FlowLayout.LEFT)); jpMaxRept.add(GuiUtil.addComponentAsFlow(jpMaxReptSub, FlowLayout.RIGHT)); /////////////////////////////////////// final JLabel lbl = new JLabel("Limit search by:", SwingConstants.LEFT); final JPanel panel = new JPanel() { @Override public void setEnabled(boolean b) { super.setEnabled(b); lbl.setEnabled(b); jpMaxDepth.setEnabled(b); jpMaxRept.setEnabled(b); } @Override public void setVisible(boolean b) { super.setVisible(b); final JPanel p = this; // SwingUtilities.invokeLater( new Runnable() { // public void run() { Window win = SwingUtilities.getWindowAncestor(p); System.err.println(win); if (win != null) { System.err.println("packing"); win.pack(); } // } // } ); } }; panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 0)); panel.add(GuiUtil.addComponentAsFlow(lbl, FlowLayout.LEFT)); panel.add(jpMaxDepth); panel.add(jpMaxRept); ButtonGroup bg = new ButtonGroup(); bg.add(jrbMaxDepth); bg.add(jrbMaxRept); /* CHECKBOX */ final JCheckBox chboxRepeat = new JCheckBox("Allow subtask recursive repetition", s_isSubtaskRepetitionAllowed); chboxRepeat.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { if (s_isSubtaskRepetitionAllowed == chboxRepeat.isSelected()) return; s_isSubtaskRepetitionAllowed = chboxRepeat.isSelected(); panel.setVisible(s_isSubtaskRepetitionAllowed); logger.debug("m_isSubtaskRepetitionAllowed " + s_isSubtaskRepetitionAllowed); } }); panel.setVisible(s_isSubtaskRepetitionAllowed); final JCheckBox chboxIncremental = new JCheckBox("Incremental", s_isIncremental); chboxIncremental.setToolTipText("Incremental depth-first search"); chboxIncremental.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { if (s_isIncremental == chboxIncremental.isSelected()) return; s_isIncremental = chboxIncremental.isSelected(); logger.debug("isIncremental " + s_isIncremental); } }); final JCheckBox chboxOptimize = new JCheckBox("Disable optimization in subtasks", s_disableOptimizationInSubtasks); chboxOptimize.setToolTipText("Use for debugging purposes"); chboxOptimize.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { if (s_disableOptimizationInSubtasks == chboxOptimize.isSelected()) return; s_disableOptimizationInSubtasks = chboxOptimize.isSelected(); logger.debug("disableOptimizationInSubtasks " + s_disableOptimizationInSubtasks); } }); JPanel container1 = new JPanel(); container1.setLayout(new BoxLayout(container1, BoxLayout.Y_AXIS)); container1.setBorder(BorderFactory.createTitledBorder("Planning settings")); container1.add(GuiUtil.addComponentAsFlow(chboxOptimize, FlowLayout.LEFT)); container1.add(GuiUtil.addComponentAsFlow(chboxIncremental, FlowLayout.LEFT)); container1.add(GuiUtil.addComponentAsFlow(chboxRepeat, FlowLayout.LEFT)); container1.add(GuiUtil.addComponentAsFlow(panel, FlowLayout.LEFT)); JPanel container2 = new JPanel(new GridLayout(2, 0)); container2.setBorder(BorderFactory.createTitledBorder("Logging options")); final JCheckBox linear = new JCheckBox("Detailed linear planning", isLinearLoggingOn()); linear.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { setLinearLoggingOn(linear.isSelected()); } }); container2.add(linear); final JCheckBox subtask = new JCheckBox("Detailed subtask planning", isSubtaskLoggingOn()); subtask.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { setSubtaskLoggingOn(subtask.isSelected()); } }); container2.add(subtask); JPanel main = new JPanel(); main.setLayout(new BoxLayout(main, BoxLayout.Y_AXIS)); main.add(container1); main.add(container2); return main; }
public NotePlayerConfigurationPanel() { setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); JPanel panel = new JPanel(new MigLayout()); add(panel); play = new JCheckBox("Play notes", true); play.addActionListener( new AbstractAction() { public void actionPerformed(ActionEvent e) { doPlay = !doPlay; if (doPlay) { pb.setEnabled(true); at.setEnabled(true); } else { pb.setEnabled(false); at.setEnabled(false); } configure(); } }); panel.add(play, "wrap"); pb = new JCheckBox("Pitch Bend", false); pb.addActionListener( new AbstractAction() { public void actionPerformed(ActionEvent e) { doPb = !doPb; configure(); } }); panel.add(pb, "wrap"); at = new JCheckBox("Aftertouch", false); at.addActionListener( new AbstractAction() { public void actionPerformed(ActionEvent e) { doAt = !doAt; configure(); } }); panel.add(at, "wrap"); panel = new JPanel(new MigLayout()); add(panel); panel.add(new Label("Follow Mode"), "label"); JComboBox box = new JComboBox(sender.getFollowModes()); box.setSelectedItem(eventhandler.getConfigurationMode(getOperationMode()).getFollowMode()); box.addActionListener( new AbstractAction() { public void actionPerformed(ActionEvent e) { JComboBox box = (JComboBox) e.getSource(); String name = (String) box.getSelectedItem(); eventhandler.getConfigurationMode(getOperationMode()).setFollowMode(name); sender.setFollowMode(name); } }); panel.add(box, "wrap"); panel.add(new Label("Scale"), "label"); scale = new JComboBox(eventhandler.getScaleMapper().getScaleNames()); scale.setSelectedItem(eventhandler.getCurrentScale()); scale.addActionListener( new AbstractAction() { public void actionPerformed(ActionEvent e) { String scalename = (String) scale.getSelectedItem(); eventhandler.getScaleMapper(getOperationMode()).setScale(scalename); } }); panel.add(scale, "wrap"); panel.add(new Label("Basenote"), "label"); basenote = new JSpinner(new SpinnerNumberModel(1, 1, 127, 1)); basenote.setValue(eventhandler.getBaseNote()); basenote.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { Integer value = (Integer) basenote.getValue(); eventhandler.setBaseNote(getOperationMode(), value); } }); panel.add(basenote, "wrap"); }
public FloorEditorWindow() { previewModeBox.addActionListener( new ActionListener() { /** Invoked when an action occurs. */ public void actionPerformed(ActionEvent e) { previewBox.setMode( FloorPreviewPanel.FloorPreviewMode.values()[previewModeBox.getSelectedIndex()]); loadFloor(); } }); final ChangeListener cl = new ChangeListener() { public void stateChanged(ChangeEvent e) { if (currentFloor == null || isLoading) return; isDirty = true; currentFloor.occlude = blendingCheckbox.isSelected(); switch (previewBox.getMode()) { case RT3_GAME: currentFloor.colour2 = gameColour.getColour(); currentFloor.rgb2hls(currentFloor.colour2, true); currentFloor.texture = (Integer) gameTexture.getValue(); currentFloor.name = gameName.getText(); break; case RT3_MAP: currentFloor.minimapColour = gameColour.getColour(); currentFloor.rgb2hls(currentFloor.minimapColour, false); break; case RT4P_OVERLAY: currentFloor.hdColour = gameColour.getColour(); int hslColour = currentFloor.hslColour; currentFloor.rgb2hls(currentFloor.hdColour, false); currentFloor.hdOlHslColour = hslColour; currentFloor.hslColour = hslColour; currentFloor.hdTexture = (Integer) gameTexture.getValue(); // currentFloor.name = gameName.getText(); break; case RT4P_UNDERLAY: currentFloor.hdUlColour = gameColour.getColour(); hslColour = currentFloor.hslColour; currentFloor.rgb2hls(currentFloor.hdUlColour, false); currentFloor.hdHslColour = hslColour; currentFloor.hslColour = hslColour; currentFloor.hdUlTexture = (Integer) gameTexture.getValue(); // currentFloor.name = gameName.getText(); break; } previewBox.repaint(); } }; gameColour.addChangeListener(cl); gameTexture.addChangeListener(cl); blendingCheckbox.addChangeListener(cl); gameName.addFocusListener( new FocusListener() { String text = ""; public void focusGained(FocusEvent e) { text = gameName.getText(); } public void focusLost(FocusEvent e) { if (!gameName.getText().equals(text)) cl.stateChanged(null); } }); resetButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if ((!isDirty) || JOptionPane.showConfirmDialog( mainPane, "Are you sure you want to revert all changes to this floor?", "RuneScape Map Editor", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) currentFloor = loadedFloor.cloneFLO(); } }); saveButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { isDirty = false; loadedFloor.replace(currentFloor); Floor.cache[loadedFloor.id] = loadedFloor; for (ChangeListener l : listenerList) l.stateChanged(null); } }); saveAsNewButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { isDirty = false; int i = Floor.addNew(currentFloor); currentFloor.id = i; loadedFloor = Floor.cache[i]; for (ChangeListener l : listenerList) l.stateChanged(null); } }); }
protected void buildChooser() { String redString = UIManager.getString("ColorChooser.rgbRedText"); String greenString = UIManager.getString("ColorChooser.rgbGreenText"); String blueString = UIManager.getString("ColorChooser.rgbBlueText"); setLayout(new BorderLayout()); Color color = getColorFromModel(); JPanel enclosure = new JPanel(); enclosure.setLayout(new SmartGridLayout(3, 3)); enclosure.setInheritsPopupMenu(true); // The panel that holds the sliders add(enclosure, BorderLayout.CENTER); // sliderPanel.setBorder(new LineBorder(Color.black)); // The row for the red value JLabel l = new JLabel(redString); l.setDisplayedMnemonic(AbstractColorChooserPanel.getInt("ColorChooser.rgbRedMnemonic", -1)); enclosure.add(l); redSlider = new JSlider(JSlider.HORIZONTAL, 0, 255, color.getRed()); redSlider.setMajorTickSpacing(85); redSlider.setMinorTickSpacing(17); redSlider.setPaintTicks(true); redSlider.setPaintLabels(true); redSlider.setInheritsPopupMenu(true); enclosure.add(redSlider); redField = new JSpinner(new SpinnerNumberModel(color.getRed(), minValue, maxValue, 1)); l.setLabelFor(redSlider); redField.setInheritsPopupMenu(true); JPanel redFieldHolder = new JPanel(new CenterLayout()); redFieldHolder.setInheritsPopupMenu(true); redField.addChangeListener(this); redFieldHolder.add(redField); enclosure.add(redFieldHolder); // The row for the green value l = new JLabel(greenString); l.setDisplayedMnemonic(AbstractColorChooserPanel.getInt("ColorChooser.rgbGreenMnemonic", -1)); enclosure.add(l); greenSlider = new JSlider(JSlider.HORIZONTAL, 0, 255, color.getGreen()); greenSlider.setMajorTickSpacing(85); greenSlider.setMinorTickSpacing(17); greenSlider.setPaintTicks(true); greenSlider.setPaintLabels(true); greenSlider.setInheritsPopupMenu(true); enclosure.add(greenSlider); greenField = new JSpinner(new SpinnerNumberModel(color.getGreen(), minValue, maxValue, 1)); l.setLabelFor(greenSlider); greenField.setInheritsPopupMenu(true); JPanel greenFieldHolder = new JPanel(new CenterLayout()); greenFieldHolder.add(greenField); greenFieldHolder.setInheritsPopupMenu(true); greenField.addChangeListener(this); enclosure.add(greenFieldHolder); // The slider for the blue value l = new JLabel(blueString); l.setDisplayedMnemonic(AbstractColorChooserPanel.getInt("ColorChooser.rgbBlueMnemonic", -1)); enclosure.add(l); blueSlider = new JSlider(JSlider.HORIZONTAL, 0, 255, color.getBlue()); blueSlider.setMajorTickSpacing(85); blueSlider.setMinorTickSpacing(17); blueSlider.setPaintTicks(true); blueSlider.setPaintLabels(true); blueSlider.setInheritsPopupMenu(true); enclosure.add(blueSlider); blueField = new JSpinner(new SpinnerNumberModel(color.getBlue(), minValue, maxValue, 1)); l.setLabelFor(blueSlider); blueField.setInheritsPopupMenu(true); JPanel blueFieldHolder = new JPanel(new CenterLayout()); blueFieldHolder.add(blueField); blueField.addChangeListener(this); blueFieldHolder.setInheritsPopupMenu(true); enclosure.add(blueFieldHolder); redSlider.addChangeListener(this); greenSlider.addChangeListener(this); blueSlider.addChangeListener(this); redSlider.putClientProperty("JSlider.isFilled", Boolean.TRUE); greenSlider.putClientProperty("JSlider.isFilled", Boolean.TRUE); blueSlider.putClientProperty("JSlider.isFilled", Boolean.TRUE); }
private JPanel makePathAttributesPanel() { JPanel outerPanel = new JPanel(new BorderLayout(6, 6)); outerPanel.setBorder(this.createTitleBorder("Path Attributes")); GridLayout nameLayout = new GridLayout(0, 1, 6, 6); JPanel namePanel = new JPanel(nameLayout); GridLayout valueLayout = new GridLayout(0, 1, 6, 6); JPanel valuePanel = new JPanel(valueLayout); namePanel.add(new JLabel("Follow Terrain")); JCheckBox ckb = new JCheckBox(); ckb.setSelected(currentFollowTerrain); ckb.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { currentFollowTerrain = ((JCheckBox) actionEvent.getSource()).isSelected(); update(); } }); valuePanel.add(ckb); JLabel label; namePanel.add(label = new JLabel("Conformance")); int[] values = new int[] {1, 2, 4, 8, 10, 15, 20, 30, 40, 50}; String[] strings = new String[values.length]; for (int i = 0; i < values.length; i++) { strings[i] = Integer.toString(values[i]) + " pixels"; } JSpinner sp = new JSpinner(new SpinnerListModel(strings)); onTerrainOnlyItems.add(label); onTerrainOnlyItems.add(sp); sp.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent changeEvent) { String v = (String) ((JSpinner) changeEvent.getSource()).getValue(); currentTerrainConformance = Integer.parseInt(v.substring(0, v.indexOf(" "))); update(); } }); sp.setValue(Integer.toString(currentTerrainConformance) + " pixels"); valuePanel.add(sp); namePanel.add(label = new JLabel("Subsegments")); sp = new JSpinner(new SpinnerListModel(new String[] {"1", "2", "5", "10", "20", "40", "50"})); offTerrainOnlyItems.add(label); offTerrainOnlyItems.add(sp); sp.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent changeEvent) { String v = (String) ((JSpinner) changeEvent.getSource()).getValue(); currentNumSubsegments = Integer.parseInt(v); update(); } }); sp.setValue(Integer.toString(currentNumSubsegments)); valuePanel.add(sp); namePanel.add(new JLabel("Type")); final JComboBox cb = new JComboBox(new String[] {"Great Circle", "Linear", "Rhumb Line"}); cb.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { currentPathType = (String) cb.getSelectedItem(); update(); } }); cb.setSelectedItem("Great Circle"); valuePanel.add(cb); namePanel.add(new JLabel("Style")); final JComboBox cb1 = new JComboBox(new String[] {"None", "Solid", "Dash"}); cb1.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { currentPathStyle = (String) cb1.getSelectedItem(); update(); } }); cb1.setSelectedItem("Solid"); valuePanel.add(cb1); namePanel.add(new JLabel("Width")); sp = new JSpinner(new SpinnerNumberModel(this.currentPathWidth, 1d, 10d, 1d)); sp.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent changeEvent) { currentPathWidth = (Double) ((JSpinner) changeEvent.getSource()).getValue(); update(); } }); sp.setValue(currentPathWidth); valuePanel.add(sp); namePanel.add(new JLabel("Color")); JComboBox cb2 = new JComboBox(new String[] {"Red", "Green", "Blue", "Yellow"}); cb2.setSelectedItem(currentPathColor); cb2.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { currentPathColor = (String) ((JComboBox) actionEvent.getSource()).getSelectedItem(); update(); } }); valuePanel.add(cb2); namePanel.add(new JLabel("Opacity")); sp = new JSpinner(new SpinnerNumberModel(this.currentPathOpacity, 0, 10, 1)); sp.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent changeEvent) { currentPathOpacity = (Integer) ((JSpinner) changeEvent.getSource()).getValue(); update(); } }); valuePanel.add(sp); namePanel.add(new JLabel("Offset")); sp = new JSpinner( new SpinnerListModel( new String[] {"0", "10", "100", "1000", "10000", "100000", "1000000"})); sp.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent changeEvent) { currentOffset = Float.parseFloat((String) ((JSpinner) changeEvent.getSource()).getValue()); update(); } }); sp.setValue("0"); valuePanel.add(sp); outerPanel.add(namePanel, BorderLayout.WEST); outerPanel.add(valuePanel, BorderLayout.CENTER); return outerPanel; }
InputFrame() { JPanel pane = new JPanel(); pane.setLayout(null); pane.setBackground(Color.LIGHT_GRAY); add(pane); // JTextField文字欄位元件 lblName = new JLabel("姓名:"); lblName.setBounds(10, 10, 40, 20); pane.add(lblName); text0.setBounds(50, 10, 80, 20); text0.addActionListener(textfield); pane.add(text0); // JSpinner數位序列元件 lblAge = new JLabel("年齡:"); lblAge.setBounds(170, 10, 40, 20); pane.add(lblAge); JSpinner spin = new JSpinner(new SpinnerNumberModel(20, 1, 100, 1)); spin.setBounds(210, 10, 80, 20); spin.addChangeListener(spinner); pane.add(spin); // JRadioButton選項圓鈕元件 lblSex = new JLabel("性別:"); lblSex.setBounds(10, 40, 40, 20); pane.add(lblSex); ButtonGroup group = new ButtonGroup(); JRadioButton rb1 = new JRadioButton("帥哥", false); rb1.setBounds(50, 40, 60, 20); JRadioButton rb2 = new JRadioButton("美女", false); rb2.setBounds(110, 40, 60, 20); rb1.setOpaque(false); rb2.setOpaque(false); // 秀出底色 rb1.addActionListener(radio); rb2.addActionListener(radio); group.add(rb1); group.add(rb2); pane.add(rb1); pane.add(rb2); // JCheckBox核對方塊元件 lblInter = new JLabel("興趣:"); lblInter.setBounds(10, 70, 50, 20); pane.add(lblInter); for (int i = 0; i < check.length; i++) { check[i] = new JCheckBox(checkItem[i]); check[i].setBounds(50 + 60 * i, 70, 60, 20); check[i].setOpaque(false); check[i].addActionListener(checkbox); pane.add(check[i]); } // JComboBox下拉式清單元件 lblAcad = new JLabel("學歷:"); lblAcad.setBounds(10, 100, 50, 20); pane.add(lblAcad); String[] items_c = {"博士", "碩士", "大學", "高中", "國中", "國小"}; JComboBox c_box = new JComboBox(items_c); c_box.setBounds(50, 100, 100, 20); c_box.addItemListener(cbo); pane.add(c_box); // JList清單元件 lblPlace = new JLabel("居住地區:"); lblPlace.setBounds(170, 100, 70, 20); pane.add(lblPlace); String[] items_p = { "台北", "桃園", "新竹", "苗栗", "台中", "彰化", "雲林", "嘉義", "台南", "高雄", "屏東", "花蓮", "台東", "澎湖" }; JList list = new JList(items_p); list.setVisibleRowCount(4); list.addListSelectionListener(list_p); JScrollPane scroll = new JScrollPane(list); scroll.setBounds(240, 100, 80, 80); pane.add(scroll); // JTextArea文字區域元件 texta.setBounds(10, 190, 330, 40); texta.setEditable(false); pane.add(texta); setTitle("輸入元件綜合應用"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(50, 50, 360, 280); setVisible(true); }
private JPanel makeInteriorAttributesPanel() { JPanel outerPanel = new JPanel(new BorderLayout(6, 6)); outerPanel.setBorder(this.createTitleBorder("Surface Attributes")); GridLayout nameLayout = new GridLayout(0, 1, 6, 6); JPanel namePanel = new JPanel(nameLayout); GridLayout valueLayout = new GridLayout(0, 1, 6, 6); JPanel valuePanel = new JPanel(valueLayout); namePanel.add(new JLabel("Style")); final JComboBox cb1 = new JComboBox(new String[] {"None", "Solid"}); cb1.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { currentInteriorStyle = (String) cb1.getSelectedItem(); update(); } }); cb1.setSelectedItem("Solid"); valuePanel.add(cb1); namePanel.add(new JLabel("Opacity")); JSpinner sp = new JSpinner(new SpinnerNumberModel(this.currentBorderOpacity, 0, 10, 1)); sp.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent changeEvent) { currentInteriorOpacity = (Integer) ((JSpinner) changeEvent.getSource()).getValue(); update(); } }); valuePanel.add(sp); namePanel.add(new JLabel("Color")); final JComboBox cb2 = new JComboBox(new String[] {"Red", "Green", "Blue", "Yellow"}); cb2.setSelectedItem(currentInteriorColor); cb2.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { currentInteriorColor = (String) ((JComboBox) actionEvent.getSource()).getSelectedItem(); update(); } }); valuePanel.add(cb2); namePanel.add(new JLabel("Border")); final JComboBox cb5 = new JComboBox(new String[] {"None", "Solid"}); cb5.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { currentBorderStyle = (String) cb5.getSelectedItem(); update(); } }); cb5.setSelectedItem("Solid"); valuePanel.add(cb5); namePanel.add(new JLabel("Border Width")); sp = new JSpinner(new SpinnerNumberModel(this.currentBorderWidth, 1d, 10d, 1d)); sp.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent changeEvent) { currentBorderWidth = (Double) ((JSpinner) changeEvent.getSource()).getValue(); update(); } }); sp.setValue(currentBorderWidth); valuePanel.add(sp); namePanel.add(new JLabel("Border Color")); JComboBox cb4 = new JComboBox(new String[] {"Red", "Green", "Blue", "Yellow"}); cb4.setSelectedItem(currentBorderColor); cb4.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { currentBorderColor = (String) ((JComboBox) actionEvent.getSource()).getSelectedItem(); update(); } }); valuePanel.add(cb4); namePanel.add(new JLabel("Border Opacity")); sp = new JSpinner(new SpinnerNumberModel(this.currentBorderOpacity, 0, 10, 1)); sp.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent changeEvent) { currentBorderOpacity = (Integer) ((JSpinner) changeEvent.getSource()).getValue(); update(); } }); valuePanel.add(sp); outerPanel.add(namePanel, BorderLayout.WEST); outerPanel.add(valuePanel, BorderLayout.CENTER); return outerPanel; }
FieldEditorHelper(FieldEditor fieldEditor) { this.fieldEditor = fieldEditor; fieldNameField = fieldEditor.getFieldNameField(); fieldNameField.getDocument().addDocumentListener(new FieldNameChangeListener()); dataTypeCombo = fieldEditor.getDataTypeCombo(); dataTypeCombo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { dataTypeComboAction(e); } }); calcTypeCombo = fieldEditor.getCalcTypeCombo(); calcTypeCombo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { calcTypeComboAction(e); } }); lookupViewCombo = fieldEditor.getLookupViewCombo(); lookupViewCombo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { lookupViewComboAction(e); } }); lookupFieldCombo = fieldEditor.getLookupFieldCombo(); lookupFieldCombo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { lookupFieldComboAction(e); } }); objRelationshipCombo = fieldEditor.getObjRelationshipCombo(); objRelationshipCombo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { objRelationshipComboAction(e); } }); objAttributeCombo = fieldEditor.getObjAttributeCombo(); objAttributeCombo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { objAttributeComboAction(e); } }); defaultValueField = fieldEditor.getDefaultValueField(); defaultValueField.getDocument().addDocumentListener(new DefaultValueChangeListener()); captionField = fieldEditor.getCaptionField(); captionField.getDocument().addDocumentListener(new CaptionChangeListener()); editableCheckBox = fieldEditor.getEditableCheckBox(); editableCheckBox.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { editableCheckBoxAction(e); } }); visibleCheckBox = fieldEditor.getVisibleCheckBox(); visibleCheckBox.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { visibleCheckBoxAction(e); } }); displayClassField = fieldEditor.getDisplayClassField(); displayClassField.getDocument().addDocumentListener(new DisplayClassChangeListener()); displayPatternField = fieldEditor.getDisplayPatternField(); displayPatternField.getDocument().addDocumentListener(new DisplayPatternChangeListener()); editClassField = fieldEditor.getEditClassField(); editClassField.getDocument().addDocumentListener(new EditClassChangeListener()); editPatternField = fieldEditor.getEditPatternField(); editPatternField.getDocument().addDocumentListener(new EditPatternChangeListener()); preferredIndexField = fieldEditor.getPreferredIndexField(); preferredIndexField.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { preferredIndexFieldChanged(e); } }); }