Java Code Examples for javax.swing.JSpinner#setPreferredSize()
The following examples show how to use
javax.swing.JSpinner#setPreferredSize() .
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: JResizerPanel.java From MtgDesktopCompanion with GNU General Public License v3.0 | 6 votes |
private void init() { setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5)); spinner = new JSpinner(); spinner.setPreferredSize(new Dimension(60, 20)); spinner.setModel(new SpinnerNumberModel(0, null, null, 1)); add(spinner); lblDimension = new JLabel(""); add(lblDimension); update(); spinner.addChangeListener(ce-> { Number val = (Number)spinner.getValue(); int w = (int) (dimension.getWidth()+val.intValue()); int h = (int) (w*MTGConstants.CARD_PICS_RATIO); dimension.setSize(w, h); update(); }); }
Example 2
Source File: JPlagCreator.java From jplag with GNU General Public License v3.0 | 5 votes |
public static JSpinner createSpinner(int width, int height, String toolTip) { SpinnerNumberModel model = new SpinnerNumberModel(1, 1, 100, 1); JSpinner spinner = new JSpinner(model); spinner.setFont(JPlagCreator.SYSTEM_FONT); spinner.setPreferredSize(new java.awt.Dimension(width, height)); spinner.setEnabled(true); spinner.setBackground(java.awt.Color.WHITE); if (toolTip != null && !toolTip.equals("")) ((JSpinner.DefaultEditor) spinner.getEditor()).getTextField().setToolTipText(toolTip); return spinner; }
Example 3
Source File: ConnectionPropertiesPanel.java From bigtable-sql with Apache License 2.0 | 5 votes |
private JPanel getSleepTimePanel() { JPanel sleepTimePanel = new JPanel(); sleepTimePanel.setLayout(new GridBagLayout()); SpinnerNumberModel spinnerNumberModel = new SpinnerNumberModel(_props.getKeepAliveSleepTimeSeconds(), 10, Integer.MAX_VALUE, 10); sleepTime = new JSpinner(spinnerNumberModel); sleepTime.setPreferredSize(new Dimension(75, 25)); sleepForLabel = new JLabel(i18n.SLEEP_FOR_LABEL); GridBagConstraints gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.EAST; gbc.gridx = 0; gbc.gridy = 0; gbc.weightx = .05; gbc.insets = new Insets(0, 5, 0, 0); sleepTimePanel.add(sleepForLabel, gbc); gbc.anchor = GridBagConstraints.CENTER; gbc.gridx++; gbc.weightx = .05; sleepTimePanel.add(sleepTime, gbc); secondsLabel = new JLabel(i18n.SECONDS_LABEL); gbc.anchor = GridBagConstraints.WEST; gbc.gridx++; gbc.weightx = .9; sleepTimePanel.add(secondsLabel, gbc); return sleepTimePanel; }
Example 4
Source File: GUIFrame.java From jaamsim with Apache License 2.0 | 5 votes |
private void addSpeedMultiplier(JToolBar mainToolBar, Insets margin) { SpinnerNumberModel numberModel = new SpinnerModel(Simulation.DEFAULT_REAL_TIME_FACTOR, Simulation.MIN_REAL_TIME_FACTOR, Simulation.MAX_REAL_TIME_FACTOR, 1); spinner = new JSpinner(numberModel); // show up to 6 decimal places JSpinner.NumberEditor numberEditor = new JSpinner.NumberEditor(spinner,"0.######"); spinner.setEditor(numberEditor); // make sure spinner TextField is no wider than 9 digits int diff = ((JSpinner.DefaultEditor)spinner.getEditor()).getTextField().getPreferredSize().width - getPixelWidthOfString_ForFont("9", spinner.getFont()) * 9; Dimension dim = spinner.getPreferredSize(); dim.width -= diff; spinner.setPreferredSize(dim); spinner.addChangeListener(new ChangeListener() { @Override public void stateChanged( ChangeEvent e ) { Double val = (Double)((JSpinner)e.getSource()).getValue(); if (MathUtils.near(val, sim.getSimulation().getRealTimeFactor())) return; NumberFormat nf = NumberFormat.getNumberInstance(Locale.US); DecimalFormat df = (DecimalFormat)nf; df.applyPattern("0.######"); KeywordIndex kw = InputAgent.formatArgs("RealTimeFactor", df.format(val)); InputAgent.storeAndExecute(new KeywordCommand(sim.getSimulation(), kw)); controlStartResume.requestFocusInWindow(); } }); spinner.setToolTipText(formatToolTip("Speed Multiplier (< and > keys)", "Target ratio of simulation time to wall clock time when Real Time mode is selected.")); spinner.setEnabled(false); mainToolBar.add( spinner ); }
Example 5
Source File: PlanManager.java From cropplanning with GNU General Public License v3.0 | 5 votes |
@Override protected void buildContentsPanel() { cmboPlanList = new JComboBox(); cmboPlanList.setEditable(true); cmboPlanList.addActionListener(this); spnYear = new JSpinner(); SpinnerDateModel spnMod = new SpinnerDateModel(); spnMod.setCalendarField( Calendar.YEAR ); spnYear.setModel( spnMod ); spnYear.setEditor( new JSpinner.DateEditor( spnYear, "yyyy" ) ); spnYear.setPreferredSize( new Dimension( 70, spnYear.getPreferredSize().height )); tfldDesc = new JTextField( 20 ); JPanel jplCont = new JPanel( new MigLayout( "gapy 0px!, insets 2px", "[align right][]") ); jplCont.add( new JLabel( "Plan:" ) ); jplCont.add( cmboPlanList, "wrap" ); jplCont.add( new JLabel( "Year:" ) ); jplCont.add( spnYear, "wrap" ); jplCont.add( new JLabel( "Description:" ) ); jplCont.add( tfldDesc, "wrap" ); jplCont.setBorder( BorderFactory.createEmptyBorder( 10, 10, 0, 10)); contentsPanelBuilt = true; add( jplCont ); }
Example 6
Source File: ReservedCheckinWindow.java From Hotel-Properties-Management-System with GNU General Public License v2.0 | 4 votes |
/** * Create the dialog. */ public ReservedCheckinWindow(Room roomNumber) { this.ownInjectedRoom = roomNumber; loggingEngine = LoggingEngine.getInstance(); loggingEngine.setMessage("User is : " + sessionBean.getNickName()); setMinimumSize(new Dimension(750, 495)); setPreferredSize(new Dimension(750, 495)); setLocationRelativeTo(null); this.setIconImage(Toolkit.getDefaultToolkit(). getImage(getClass().getResource(LOGOPATH))); getContentPane().setForeground(new Color(255, 99, 71)); getContentPane().setFocusCycleRoot(true); getContentPane().setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); getContentPane().setFont(new Font("Verdana", Font.BOLD, 12)); setModalExclusionType(ModalExclusionType.APPLICATION_EXCLUDE); setDefaultCloseOperation(DISPOSE_ON_CLOSE); setModal(true); setResizable(false); this.setTitle("Coder HPMSA - [Checkin]"); contentPanel.setAutoscrolls(true); contentPanel.setPreferredSize(new Dimension(10, 415)); contentPanel.setBackground(Color.decode("#066d95")); contentPanel.setLayout(new BorderLayout(0, 0)); getContentPane().add(contentPanel, BorderLayout.SOUTH); upperPanel = new JPanel(); upperPanel.setBorder(new SoftBevelBorder(BevelBorder.RAISED, null, null, null, null)); upperPanel.setBackground(new Color(135, 206, 235)); upperPanel.setPreferredSize(new Dimension(10, 35)); contentPanel.add(upperPanel, BorderLayout.NORTH); JLabel lblChangeRoomPerson = new JLabel("Change person count : "); lblChangeRoomPerson.setFont(new Font("Arial", Font.PLAIN, 15)); upperPanel.add(lblChangeRoomPerson); spinner = new JSpinner(); spinner.setModel(new SpinnerNumberModel(1, 1, 3, 1)); spinner.setPreferredSize(new Dimension(40, 20)); spinner.setMinimumSize(new Dimension(35, 20)); spinner.addChangeListener(customerCounterListener()); upperPanel.add(spinner); JPanel buttonPanel = new JPanel(); buttonPanel.setBorder(new SoftBevelBorder(BevelBorder.RAISED, null, null, null, null)); buttonPanel.setPreferredSize(new Dimension(10, 50)); buttonPanel.setLayout(null); getContentPane().add(buttonPanel, BorderLayout.NORTH); JButton roomCheckinBtn = new JButton("Room checkin"); roomCheckinBtn.addActionListener(this); roomCheckinBtn.setIcon(new ImageIcon(ReservedCheckinWindow.class .getResource("/com/coder/hms/icons/extra_checkin.png"))); roomCheckinBtn.setBounds(7, 4, 130, 42); buttonPanel.add(roomCheckinBtn); final JSeparator separator = new JSeparator(); separator.setBackground(Color.DARK_GRAY); separator.setBounds(149, 6, 10, 36); separator.setOrientation(SwingConstants.VERTICAL); separator.setFocusable(true); separator.setForeground(Color.DARK_GRAY); separator.setAutoscrolls(true); separator.setPreferredSize(new Dimension(10, 20)); buttonPanel.add(separator); JLabel lblRoom = new JLabel("ROOM : "); lblRoom.setFont(new Font("Verdana", Font.BOLD, 15)); lblRoom.setBounds(330, 8, 68, 33); buttonPanel.add(lblRoom); JLabel roomNumberLbl = new JLabel(ownInjectedRoom.getNumber()); roomNumberLbl.setForeground(new Color(220, 20, 60)); roomNumberLbl.setFont(new Font("Verdana", Font.BOLD, 17)); roomNumberLbl.setBounds(406, 8, 103, 33); buttonPanel.add(roomNumberLbl); contentPanel.add(customerFormOne.setCustomerDetailPanel(), BorderLayout.WEST); prepareCustomerForms(ownInjectedRoom.getNumber()); }
Example 7
Source File: BayMunitionsChoicePanel.java From megamek with GNU General Public License v2.0 | 4 votes |
AmmoRowPanel(Mounted bay, int at, int rackSize, List<Mounted> ammoMounts) { this.bay = bay; this.at = at; this.rackSize = rackSize; this.ammoMounts = new ArrayList<>(ammoMounts); this.spinners = new ArrayList<>(); Dimension spinnerSize =new Dimension(55, 25); final Optional<WeaponType> wtype = bay.getBayWeapons().stream() .map(wNum -> entity.getEquipment(wNum)) .map(m -> (WeaponType) m.getType()).findAny(); // set the bay's tech base to that of any weapon in the bay // an assumption is made here that bays don't mix clan-only and IS-only tech base this.techBase = wtype.isPresent() ? wtype.get().getTechBase() : WeaponType.TECH_BASE_ALL; munitions = AmmoType.getMunitionsFor(at).stream() .filter(this::includeMunition).collect(Collectors.toList()); tonnage = ammoMounts.stream().mapToDouble(m -> m.getAmmoCapacity()).sum(); Map<String,Integer> starting = new HashMap<>(); ammoMounts.forEach(m -> starting.merge(m.getType().getInternalName(), m.getBaseShotsLeft(), Integer::sum)); for (AmmoType atype : munitions) { JSpinner spn = new JSpinner(new SpinnerNumberModel(starting.getOrDefault(atype.getInternalName(), 0), 0, null, 1)); spn.setPreferredSize(spinnerSize); spn.setName(atype.getInternalName()); spn.addChangeListener(this); if (atype.getTonnage(entity) > 1) { spn.setToolTipText(String.format(Messages.getString("CustomMechDialog.formatMissileTonnage"), atype.getName(), atype.getTonnage(entity))); } else { spn.setToolTipText(String.format(Messages.getString("CustomMechDialog.formatShotsPerTon"), atype.getName(), atype.getShots())); } spinners.add(spn); } setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(0, 5, 0, 5); gbc.gridwidth = 5; add(new JLabel("(" + entity.getLocationAbbr(bay.getLocation()) + ") " + (wtype.isPresent()? wtype.get().getName() : "?")), gbc); gbc.gridx = 5; gbc.gridwidth = 1; gbc.weightx = 1.0; add(lblTonnage, gbc); gbc.gridx = 0; gbc.gridy = 1; gbc.gridwidth = 1; gbc.weightx = 0.0; for (int i = 0; i < munitions.size(); i++) { add(new JLabel(createMunitionLabel(munitions.get(i))), gbc); gbc.gridx++; add(spinners.get(i), gbc); gbc.gridx++; if (gbc.gridx > 5) { gbc.gridx = 0; gbc.gridy++; } } recalcMaxValues(); }
Example 8
Source File: CalendarSpinner.java From Astrosoft with GNU General Public License v2.0 | 4 votes |
private void createSpinner(){ SpinnerModel model = new SpinnerDateModel(); spinner = new JSpinner(model); spinner.setPreferredSize(spinnerSize); editor = new JSpinner.DateEditor(spinner, dateFormat); spinner.setEditor(editor); spinner.addChangeListener(new ChangeListener(){ public void stateChanged(ChangeEvent e) { selectionChanged(e); } }); }