/* * @param parent the interval item's parent component */ private IntervalItemPanel(final IntervalPanel parent, final DataType type) { super(new GridLayout(1, 0)); m_parent = parent; m_bin = new JSpinner(createNumberModel(type)); m_bin.setPreferredSize(new Dimension(50, 25)); JSpinner.DefaultEditor editorBin = new JSpinner.NumberEditor(m_bin, "0.0##############"); editorBin.getTextField().setColumns(15); m_bin.setEditor(editorBin); m_bin.setPreferredSize(new Dimension(125, 25)); m_left = new JSpinner(createNumberModel(type)); JSpinner.DefaultEditor editorLeft = new JSpinner.NumberEditor(m_left, "0.0##############"); editorLeft.getTextField().setColumns(15); m_left.setEditor(editorLeft); m_left.setPreferredSize(new Dimension(125, 25)); m_right = new JSpinner(createNumberModel(type)); JSpinner.DefaultEditor editorRight = new JSpinner.NumberEditor(m_right, "0.0##############"); editorRight.getTextField().setColumns(15); m_right.setEditor(editorRight); m_right.setPreferredSize(new Dimension(125, 25)); m_borderLeft.setPreferredSize(new Dimension(50, 25)); m_borderLeft.setLightWeightPopupEnabled(false); m_borderLeft.addItem(RIGHT); m_borderLeft.addItem(LEFT); m_borderRight.setPreferredSize(new Dimension(50, 25)); m_borderRight.setLightWeightPopupEnabled(false); m_borderRight.addItem(LEFT); m_borderRight.addItem(RIGHT); }
private void createComponents(JPanel p) { String tt = "Any of these: 45.5 -120.2 or 45 30 0 n 120 12 0 w or Seattle"; JComboBox field = new JComboBox(); field.setOpaque(false); field.setEditable(true); field.setLightWeightPopupEnabled(false); field.setPreferredSize(new Dimension(200, field.getPreferredSize().height)); field.setToolTipText(tt); JLabel label = new JLabel(ImageLibrary.getIcon("gov/nasa/worldwindow/images/safari-24x24.png")); // new // ImageIcon(getClass().getResource("gov/nasa/worldwindow/images/safari-24x24.png"))); label.setOpaque(false); label.setToolTipText(tt); p.add(label, BorderLayout.WEST); p.add(field, BorderLayout.CENTER); field.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { performGazeteerAction(actionEvent); } }); }
public GlobalControls() { setLayout(new GridBagLayout()); setBorder(new TitledBorder(new EtchedBorder(), "Global Controls")); aliasCB = createCheckBox("Anti-Aliasing", true, 0); renderCB = createCheckBox("Rendering Quality", false, 1); textureCB = createCheckBox("Texture", false, 2); compositeCB = createCheckBox("AlphaComposite", false, 3); screenCombo = new JComboBox(); screenCombo.setPreferredSize(new Dimension(120, 18)); screenCombo.setLightWeightPopupEnabled(true); screenCombo.setFont(font); for (int i = 0; i < screenNames.length; i++) { screenCombo.addItem(screenNames[i]); } screenCombo.addItemListener(this); Java2Demo.addToGridBag(this, screenCombo, 0, 4, 1, 1, 0.0, 0.0); toolBarCB = createCheckBox("Tools", false, 5); slider = new JSlider(JSlider.HORIZONTAL, 0, 200, 30); slider.addChangeListener(this); TitledBorder tb = new TitledBorder(new EtchedBorder()); tb.setTitleFont(font); tb.setTitle("Anim delay = 30 ms"); slider.setBorder(tb); slider.setMinimumSize(new Dimension(80, 46)); Java2Demo.addToGridBag(this, slider, 0, 6, 1, 1, 1.0, 1.0); texturechooser = new TextureChooser(0); Java2Demo.addToGridBag(this, texturechooser, 0, 7, 1, 1, 1.0, 1.0); }
private JComboBox<DeckType> getDeckTypeComboBox() { final JComboBox<DeckType> cbo = new JComboBox<>(); cbo.setModel(new DefaultComboBoxModel<>(DeckType.values())); cbo.setLightWeightPopupEnabled(false); cbo.setFocusable(false); cbo.setFont(FontsAndBorders.FONT2); ((JLabel) cbo.getRenderer()).setHorizontalAlignment(SwingConstants.CENTER); return cbo; }
/** * Contruct a new AnimationWidget. * * @param parentf the parent JFrame * @param anim a ucar.visad.display.Animation object to manage * @param info Default values for the AnimationInfo */ public AnimationWidget(JFrame parentf, Animation anim, AnimationInfo info) { // Initialize sharing to true super("AnimationWidget", true); timesCbx = new JComboBox() { public String getToolTipText(MouseEvent event) { if (boxPanel != null) { return boxPanel.getToolTipText(); } return " "; } }; timesCbx.setToolTipText(""); timesCbxMutex = timesCbx.getTreeLock(); timesCbx.setFont(new Font("Dialog", Font.PLAIN, 9)); timesCbx.setLightWeightPopupEnabled(false); // set to non-visible until items are added timesCbx.setVisible(false); timesCbx.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (!ignoreTimesCbxEvents && (anime != null)) { debug("got timesCbx event"); setTimeFromUser((Real) timesCbx.getSelectedItem()); if (boxPanel != null) { boxPanel.setOnIndex(timesCbx.getSelectedIndex()); } } } }); animationInfo = new AnimationInfo(); if (anim != null) { setAnimation(anim); } if (anime != null) { animationInfo.set(anime.getAnimationInfo()); } if (info != null) { setProperties(info); animationInfo.setRunning(info.getRunning()); } boxPanel = new AnimationBoxPanel(this); if (timesArray != null) { updateBoxPanel(timesArray); } }
public void setSearchableCombo(final JComboBox cmb, boolean mustSort, final String noReultsText) { arrayListForComboSearch = new ArrayList<>(); final int s = cmb.getItemCount(); for (int i = 0; i < s; i++) { boolean exists = false; for (String arrayListForComboSearch1 : arrayListForComboSearch) { if (arrayListForComboSearch1.equalsIgnoreCase(cmb.getItemAt(i) + "")) { exists = true; break; } } if (!exists) { arrayListForComboSearch.add(cmb.getItemAt(i) + ""); } } if (mustSort) { Collections.sort(arrayListForComboSearch); } cmb.setEditable(true); cmb.setLightWeightPopupEnabled(true); jTextField = (JTextField) cmb.getEditor().getEditorComponent(); jTextField.addKeyListener( new KeyAdapter() { @Override public void keyReleased(KeyEvent evt) { int key = evt.getKeyCode(); if (!(key == KeyEvent.VK_ESCAPE || key == KeyEvent.VK_ENTER || key == KeyEvent.VK_DOWN || key == KeyEvent.VK_UP)) { String s = jTextField.getText(); int caret = jTextField.getCaretPosition(); cmb.hidePopup(); cmb.removeAllItems(); for (String arrayListForComboSearch1 : arrayListForComboSearch) { if (arrayListForComboSearch1 .toUpperCase() .startsWith(s.substring(0, caret).toUpperCase())) { cmb.addItem(arrayListForComboSearch1); } } cmb.showPopup(); if (cmb.getItemCount() == 0) { cmb.addItem(noReultsText); } jTextField.setText(s); jTextField.setCaretPosition(caret); } else if (key == KeyEvent.VK_ESCAPE) { cmb.setSelectedItem(jTextField.getText()); cmb.hidePopup(); } else if (key == KeyEvent.VK_ENTER && cmb.getSelectedIndex() == -1) { if (cmb.getItemCount() == 1 && !cmb.getItemAt(0).equals(noReultsText)) { cmb.setSelectedIndex(0); } else if (cmb.getItemCount() > 1) { cmb.setSelectedIndex(0); } } } }); }