javax.swing.plaf.basic.BasicSpinnerUI Java Examples

The following examples show how to use javax.swing.plaf.basic.BasicSpinnerUI. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MainPanel.java    From java-swing-tips with MIT License 5 votes vote down vote up
private MainPanel() {
  super(new BorderLayout());
  SpinnerModel model = new SpinnerNumberModel(10, 0, 1000, 1);

  Box box = Box.createVerticalBox();
  box.add(makeTitledPanel("Default", new JSpinner(model)));

  JSpinner spinner1 = new JSpinner(model);
  spinner1.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
  box.add(makeTitledPanel("RIGHT_TO_LEFT", spinner1));

  JSpinner spinner2 = new JSpinner(model) {
    @Override public void updateUI() {
      super.updateUI();
      setUI(new BasicSpinnerUI() {
        @Override protected LayoutManager createLayout() {
          return new SpinnerLayout();
        }
      });
    }
  };
  box.add(makeTitledPanel("L(Prev), R(Next)", spinner2));

  JSpinner spinner3 = new JSpinner(model) {
    @Override public void setLayout(LayoutManager mgr) {
      super.setLayout(new SpinnerLayout());
    }
  };
  box.add(makeTitledPanel("L(Prev), R(Next)", spinner3));

  add(box, BorderLayout.NORTH);
  setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
  setPreferredSize(new Dimension(320, 240));
}