javax.swing.JSpinner.setEditor()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(120)

本文整理了Java中javax.swing.JSpinner.setEditor()方法的一些代码示例,展示了JSpinner.setEditor()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSpinner.setEditor()方法的具体详情如下:
包路径:javax.swing.JSpinner
类名称:JSpinner
方法名:setEditor

JSpinner.setEditor介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

JSpinner timeSpinner = new JSpinner( new SpinnerDateModel() );
JSpinner.DateEditor timeEditor = new JSpinner.DateEditor(timeSpinner, "HH:mm:ss");
timeSpinner.setEditor(timeEditor);
timeSpinner.setValue(new Date()); // will only show the current time

代码示例来源:origin: kiegroup/optaplanner

private JPanel createTableHeader() {
  JPanel headerPanel = new JPanel(new FlowLayout());
  headerPanel.add(new JLabel("Standard deviation maximum"));
  standardDeviationMaximumField = new JSpinner(new SpinnerNumberModel(1.0, 0.0, 10.0, 0.001));
  standardDeviationMaximumField.setEditor(new JSpinner.NumberEditor(standardDeviationMaximumField,
      InvestmentNumericUtil.MILLIS_PERCENT_PATTERN));
  headerPanel.add(standardDeviationMaximumField);
  standardDeviationMaximumField.addChangeListener(new ChangeListener() {
    @Override
    public void stateChanged(ChangeEvent e) {
      if (ignoreChangeEvents) {
        return;
      }
      long standardDeviationMillisMaximum = (long) (((Number) standardDeviationMaximumField.getValue()).doubleValue() * 1000.0);
      changeStandardDeviationMillisMaximum(standardDeviationMillisMaximum);
    }
  });
  return headerPanel;
}

代码示例来源:origin: chewiebug/GCViewer

public TimeOffsetPanel(JPopupMenu popup) {
  this.popup = popup;
  timeSpinner = new JSpinner(new SpinnerDateModel());
  timeSpinner.setEditor(new JSpinner.DateEditor(timeSpinner, getPattern()));
  setOffsetCheckBox = new JCheckBox(LocalisationHelper.getString("timeoffset_prompt"), true);
  setOffsetCheckBox.addItemListener(new ItemListener() {
    @Override
    public void itemStateChanged(ItemEvent e) {
      timeSpinner.setEnabled(setOffsetCheckBox.isSelected());
      fireTimeOffsetPanelStateChanged(setOffsetCheckBox.isSelected());
    }
  });
  add(setOffsetCheckBox);
  add(timeSpinner);
  getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), OK_ACTION_MAP_KEY);
  getActionMap().put(OK_ACTION_MAP_KEY, new AbstractAction() {
    public void actionPerformed(ActionEvent e) {
      TimeOffsetPanel.this.popup.setVisible(false);
      fireTimeOffsetPanelStateChanged(setOffsetCheckBox.isSelected());
    }
  });
  getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), CANCEL_ACTION_MAP_KEY);
  getActionMap().put(CANCEL_ACTION_MAP_KEY, new AbstractAction() {
    public void actionPerformed(ActionEvent e) {
      TimeOffsetPanel.this.popup.setVisible(false);
    }
  });
}

代码示例来源:origin: kiegroup/optaplanner

final JSpinner maximumField = new JSpinner(new SpinnerNumberModel(
    (double) region.getQuantityMillisMaximum() / 1000.0, 0.0, 1.0, 0.010));
maximumField.setEditor(new JSpinner.NumberEditor(maximumField,
    InvestmentNumericUtil.MILLIS_PERCENT_PATTERN));
regionPanel.addRowHeader(HEADER_COLUMN_EXTRA_PROPERTY_2, region, maximumField);
final JSpinner maximumField = new JSpinner(new SpinnerNumberModel(
    (double) sector.getQuantityMillisMaximum() / 1000.0, 0.0, 1.0, 0.010));
maximumField.setEditor(new JSpinner.NumberEditor(maximumField,
    InvestmentNumericUtil.MILLIS_PERCENT_PATTERN));
sectorPanel.addRowHeader(HEADER_COLUMN_EXTRA_PROPERTY_2, sector, maximumField);

代码示例来源:origin: stackoverflow.com

public static JPanel buildDatePanel(String label, Date value) {
JPanel datePanel = new JPanel();

JDateChooser dateChooser = new JDateChooser();
if (value != null) {
  dateChooser.setDate(value);
}
for (Component comp : dateChooser.getComponents()) {
  if (comp instanceof JTextField) {
  ((JTextField) comp).setColumns(50);
  ((JTextField) comp).setEditable(false);
  }
}

datePanel.add(dateChooser);

SpinnerModel model = new SpinnerDateModel();
JSpinner timeSpinner = new JSpinner(model);
JComponent editor = new JSpinner.DateEditor(timeSpinner, "HH:mm:ss");
timeSpinner.setEditor(editor);
if(value != null) {
  timeSpinner.setValue(value);
}

datePanel.add(timeSpinner);

return datePanel;
}

代码示例来源:origin: stackoverflow.com

JFrame frame = new JFrame("Your JFrame");
//Code inserted by netbeans...
Date date = new Date();
SpinnerDateModel sdm = new SpinnerDateModel(date, null, null, Calendar.HOUR_OF_DAY);
JSpinner spinner = new JSpinner(dsm);
JSpinner.DateEditor dateEditor = new JSpinner.DateEditor(spinner, "hh:mm");
spinner.setEditor(dateEditor);
frame.add(spinner,BorderLayout.NORTH); //Choose you position and where to add the component

代码示例来源:origin: stackoverflow.com

JSpinner notWorkingSpinner = new JSpinner(m2);
JSpinner.DateEditor dateEditor = new JSpinner.DateEditor(notWorkingSpinner);
DateFormatter formatter = new DateFormatter( format );
notWorkingSpinner.setEditor(dateEditor);
dateEditor.getTextField().setFormatterFactory( new DefaultFormatterFactory( formatter ) );
formatter.setValueClass( DateThatAddsYear.class ); // Tell it to use a different value class!

代码示例来源:origin: stackoverflow.com

JSpinner spinner = new JSpinner();
String pattern = "0.000"; // valid format
JSpinner.NumberEditor editor = new JSpinner.NumberEditor(spinner, pattern);
DecimalFormat format = editor.getFormat();
Locale locale = new Locale("ru", "RU"); // create your specific locale
DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols(locale);
format.setDecimalFormatSymbols(decimalFormatSymbols);
spinner.setEditor(editor);

代码示例来源:origin: Audiveris/audiveris

/**
 * Create an editable labeled hexa spinner with provided
 * characteristics.
 *
 * @param label the string to be used as label text
 * @param tip   the related tool tip text
 */
public LHexaSpinner (String label,
           String tip)
{
  super(label, tip);
  spinner.setEditor(new HexaEditor(spinner));
}

代码示例来源:origin: uk.org.mygrid.taverna/taverna-contrib

/**
 * 
 */
public JSpinnerEditor() {
  super();
  spinner.setEditor(renderer);
  spinner.addChangeListener(renderer);
}

代码示例来源:origin: uk.org.mygrid.taverna.processors/taverna-beanshell-processor

/**
 * 
 */
public JSpinnerEditor() {
  super();
  spinner.setEditor(renderer);
  spinner.addChangeListener(renderer);
}

代码示例来源:origin: stackoverflow.com

// Instance(?) field here...
Hini = new javax.swing.JSpinner();
Date date = new Date();
SpinnerDateModel sm = new SpinnerDateModel(date, null, null, Calendar.MINUTE);
// Local field here
JSpinner Hini = new JSpinner(sm);
JSpinner.DateEditor de = new JSpinner.DateEditor(Hini, "hh:mm a");
de.getTextField().setEditable( true );
Hini.setEditor(de);

代码示例来源:origin: stackoverflow.com

JSpinner currency = new JSpinner();
currency.setModel(new javax.swing.SpinnerNumberModel());
currency.setEditor(new javax.swing.JSpinner.NumberEditor(currency, "00.00"));
JLabel label = new JLabel("Enter the numeral representing your hourly wage");
JPanel panel = new JPanel();
panel.add(label);
panel.add(filteredField);

JOptionPane.showMessageDialog(null, panel, "Hourly Rate", JOptionPane.QUESTION_MESSAGE);

System.out.println("You entered " + currency.getValue());

代码示例来源:origin: stackoverflow.com

Date date = new Date();
SpinnerDateModel sm = new SpinnerDateModel(date, null, null, Calendar.MINUTE);

JSpinner spinner = new JSpinner(sm);
JSpinner.DateEditor de = new JSpinner.DateEditor(spinner, "hh:mm a");
de.getTextField().setEditable( false );
spinner.setEditor(de);

System.out.println("Spinner:      "+de.getFormat().format(spinner.getValue()));

代码示例来源:origin: stackoverflow.com

SpinnerDateModel model = new SpinnerDateModel();
JSpinner spinner = new JSpinner(model);

JSpinner.DateEditor editor = new JSpinner.DateEditor(spinner, "MM/dd/yyyy");
DateFormatter formatter = (DateFormatter)editor.getTextField().getFormatter();
formatter.setAllowsInvalid(false);
formatter.setOverwriteMode(true);

spinner.setEditor(editor);

代码示例来源:origin: stackoverflow.com

JSpinner startTime = new JSpinner(timeModel);
 JComponent editor = (JSpinner.DefaultEditor) startTime.getEditor();
 JFormattedTextField ftf = ((JSpinner.DefaultEditor) editor).getTextField();
 ftf.setColumns(5);
 startTime.setEditor(new JSpinner.DateEditor(startTime, "HH:mm"));

代码示例来源:origin: stackoverflow.com

JSpinner startTime = new JSpinner(timeModel);
 startTime.setEditor(new JSpinner.DateEditor(startTime, "HH:mm"));
 JComponent editor = (JSpinner.DefaultEditor) startTime.getEditor();
 JFormattedTextField ftf = ((JSpinner.DefaultEditor) editor).getTextField();
 ftf.setColumns(3);

代码示例来源:origin: stackoverflow.com

private JSpinner createSpinner() {
  JSpinner spinner = new JSpinner();
  SpinnerDateModel SpinnerModel = new SpinnerDateModel();
  spinner.setModel(SpinnerModel);
  JSpinner.DateEditor dateEditor = new JSpinner.DateEditor(spinner, "hh:mm a");
  spinner.setEditor(dateEditor);
  return spinner;
}

代码示例来源:origin: com.cedarsoft.commons.swing/common

@Override
 public void setEditor(JComponent editor) {
  super.setEditor(editor);

  for (Component component : editor.getComponents()) {
   if (component instanceof AbstractButton) {
    component.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
   }
  }
 }
}

代码示例来源:origin: org.xworker/xworker_core

public static void createEditor(ActionContext actionContext){
  Thing self = (Thing) actionContext.get("self");
  JSpinner parent = (JSpinner) actionContext.get("parent");
  
  for(Thing child : self.getChilds()){
    JComponent component = (JComponent) child.doAction("create", actionContext);
    if(component != null){
      parent.setEditor(component);
      break;
    }
  }
}

相关文章