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); } }
/** Method to create link annotation GUI. */ private void createGUI() { // Create and setup an Appearance panel setBorder( new TitledBorder( new EtchedBorder(EtchedBorder.LOWERED), messageBundle.getString("viewer.utilityPane.annotation.ink.appearance.title"), TitledBorder.LEFT, TitledBorder.DEFAULT_POSITION)); // Line thickness lineThicknessBox = new JComboBox(LINE_THICKNESS_LIST); lineThicknessBox.setSelectedIndex(DEFAULT_LINE_THICKNESS); lineThicknessBox.addItemListener(this); add(new JLabel(messageBundle.getString("viewer.utilityPane.annotation.ink.lineThickness"))); add(lineThicknessBox); // Line style lineStyleBox = new JComboBox(LINE_STYLE_LIST); lineStyleBox.setSelectedIndex(DEFAULT_LINE_STYLE); lineStyleBox.addItemListener(this); add(new JLabel(messageBundle.getString("viewer.utilityPane.annotation.ink.lineStyle"))); add(lineStyleBox); // border colour colorBorderButton = new JButton(); colorBorderButton.addActionListener(this); colorBorderButton.setOpaque(true); colorBorderButton.setBackground(DEFAULT_BORDER_COLOR); add(new JLabel(messageBundle.getString("viewer.utilityPane.annotation.ink.colorBorderLabel"))); add(colorBorderButton); }
protected void initComponents() { activation = new JComboBox(new String[] {KEY_EQUIVALENT, TAB_TRIGGER}); final CardLayout cardLayout = new CardLayout(); activationSpec = new JPanel(); activationSpec.setLayout(cardLayout); keyEquivalent = new JTextField(); tabTrigger = new JTextField(); name = new JTextField(); activationSpec.add(keyEquivalent, KEY_EQUIVALENT); activationSpec.add(tabTrigger, TAB_TRIGGER); activation.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent itemEvent) { if (itemEvent.getStateChange() != ItemEvent.SELECTED) return; cardLayout.show(activationSpec, (String) itemEvent.getItem()); } }); scope = new JTextField(); }
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); }
public FramesPanel(Project project, DebuggerStateManager stateManager) { super(project, stateManager); myStateManager = stateManager; setLayout(new BorderLayout()); myThreadsCombo = new ComboBoxWithWidePopup(); myThreadsCombo.setRenderer(new DebuggerComboBoxRenderer()); myThreadsListener = new ThreadsListener(); myThreadsCombo.addItemListener(myThreadsListener); myFramesList = new FramesList(); myFramesListener = new FramesListener(); myFramesList.addListSelectionListener(myFramesListener); myFramesList.addMouseListener( new MouseAdapter() { public void mousePressed(final MouseEvent e) { int index = myFramesList.locationToIndex(e.getPoint()); if (index >= 0 && myFramesList.isSelectedIndex(index)) { processListValue(myFramesList.getModel().getElementAt(index)); } } }); registerThreadsPopupMenu(myFramesList); setBorder(null); add(myThreadsCombo, BorderLayout.NORTH); add(new JScrollPane(myFramesList), BorderLayout.CENTER); }
private void dodajListeners() { RacunovodstvoSpaseniObracuniController racunovodstvoSpaseniObracuniController = new RacunovodstvoSpaseniObracuniController(this); obracunZaJComboBox.addItemListener(racunovodstvoSpaseniObracuniController.getSpaseniObracuniObracunZaJComboBoxItemListener()); obrisiObracunJButton.addActionListener(racunovodstvoSpaseniObracuniController.getSpaseniObracuniObrisiJButtonActionListener()); kreirajPdfJButton.addActionListener(racunovodstvoSpaseniObracuniController.getPDFJButtonActionListener()); }
private void initializeUI() { this.setLayout(new BorderLayout()); this.setPreferredSize(new Dimension(400, 200)); JLabel label = new JLabel("Tab size: "); Object[] items = {2, 4, 8, 10, 20}; final JComboBox comboBox = new JComboBox(items); JPanel tabPanel = new JPanel(new FlowLayout()); tabPanel.add(label); tabPanel.add(comboBox); this.add(tabPanel, BorderLayout.NORTH); final JTextArea textArea = new JTextArea(); textArea.setLineWrap(true); textArea.setWrapStyleWord(true); // // Sets the number of characters to expand tabs to. // textArea.setTabSize((Integer) comboBox.getSelectedItem()); comboBox.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { textArea.setTabSize((Integer) comboBox.getSelectedItem()); } }); JScrollPane pane = new JScrollPane(textArea); pane.setPreferredSize(new Dimension(400, 200)); pane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); this.add(pane, BorderLayout.CENTER); }
/** * Constructs a ClutoTree diaplay which is initialized with tableModel as the data model, and the * given selection model. * * @param clutoSolution The clustering solution * @param tableContext The context which manages views and selections. * @param tableModel the data model for the parallel coordinate display */ public ClutoTree(ClutoSolution clutoSolution, TableContext tableContext, TableModel tableModel) { ctx = tableContext; tm = tableModel; lsm = ctx.getRowSelectionModel(tm); // labelModel int ncol = tm.getColumnCount(); for (int i = 0; i < ncol; i++) { labelModel.addElement(tm.getColumnName(i)); } setLayout(new BorderLayout()); btnP = new JToolBar(); add(btnP, BorderLayout.NORTH); labelChoice.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { labelColumn = 0; String ln = (String) e.getItem(); if (ln != null) { for (int c = 0; c < tm.getColumnCount(); c++) { if (ln.equals(tm.getColumnName(c))) { labelColumn = c; break; } } } graph.invalidate(); validate(); repaint(); } } }); btnP.add(labelChoice); graph = new SimpleGraph(); graph.getGraphDisplay().setOpaque(true); graph.getGraphDisplay().setBackground(Color.white); graph.getGraphDisplay().setGridColor(new Color(220, 220, 220)); graph.showGrid(false); graph.showAxis(BorderLayout.WEST, false); graph.showAxis(BorderLayout.EAST, true); graph.getAxisDisplay(BorderLayout.EAST).setZoomable(true); graph.getAxisDisplay(BorderLayout.EAST).setAxisLabeler(labeler); ((LinearAxis) graph.getYAxis()).setTickIncrement(-1.); graph.getAxisDisplay(BorderLayout.SOUTH).setZoomable(true); gs = new GraphSegments(); gs.setColor(Color.blue); idxSelColor = new IndexSelectColor(Color.cyan, null, new DefaultListSelectionModel()); gs.setIndexedColor(idxSelColor); graph.addGraphItem(gs); graph.getGraphDisplay().addMouseListener(ma); add(graph); if (lsm != null) { lsm.addListSelectionListener(selListener); } display(makeTree(clutoSolution)); }
public LicenseDialog(Component parent) { setTitle("Licensing information"); pnlButtons.add(bttnOk); cbLang.addItem("English"); cbLang.addItem("Eesti"); FlowLayout fl = new FlowLayout(); fl.setAlignment(FlowLayout.LEFT); pnlHeader.setLayout(fl); pnlHeader.add(lblLang); pnlHeader.add(cbLang); pnlMain.setLayout(new BorderLayout()); pnlMain.add(pnlHeader, BorderLayout.NORTH); pnlMain.add(scrollPane, BorderLayout.CENTER); pnlMain.add(pnlButtons, BorderLayout.SOUTH); taLicenseText.setText(getLicenseText()); taLicenseText.setCaretPosition(0); taLicenseText.setLineWrap(true); taLicenseText.setEditable(false); taLicenseText.setWrapStyleWord(true); getContentPane().add(pnlMain); setPreferredSize(new Dimension(500, 600)); setLocationRelativeTo(parent); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); bttnOk.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { if (evt.getSource() == bttnOk) { dispose(); } } // end actionPerformed }); // end bttnOk Action Listener cbLang.addItemListener( new ItemListener() { public void itemStateChanged(final ItemEvent event) { if (event.getSource() == cbLang && event.getStateChange() == ItemEvent.SELECTED && cbLang.getItemCount() > 0) { taLicenseText.setText(getLicenseText()); taLicenseText.setCaretPosition(0); } } }); // end cbLang item listener pack(); setVisible(true); } // PortPropertiesDialog
/** populates the comptype combo box with the COMPONENT_TYPES */ private void populateCompType() { DefaultComboBoxModel model = (DefaultComboBoxModel) comptype.getModel(); for (int count = 0; count < COMPONENT_TYPES.length; count++) { model.addElement(COMPONENT_TYPES[count]); } comptype.addItemListener(this); }
/** * Creates component. * * @param collection collection to show. * @param treeMode <code>TRUE</code> to set tree mode by default. * @param readingLists <code>TRUE</code> if showing reading lists. */ public CListTree(Collection collection, boolean treeMode, boolean readingLists) { this.collection = collection; this.readingLists = readingLists; itemListener = new CItemListener(); setLayout(new BorderLayout()); setTreeMode(treeMode); BBFormBuilder builder = new BBFormBuilder("p, 2dlu, p, 0:grow"); JComboBox cbViewMode = new JComboBox( new Object[] { Strings.message("collections.viewmode.tree"), Strings.message("collections.viewmode.list") }); cbViewMode.setSelectedIndex(treeMode ? 0 : 1); cbViewMode.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { JComboBox box = (JComboBox) e.getSource(); boolean isTree = box.getSelectedIndex() == 0; setTreeMode(isTree); } }); builder.append(Strings.message("collections.viewmode"), cbViewMode); builder.appendRelatedComponentsGapRow(2); add(builder.getPanel(), BorderLayout.NORTH); // Description area taDescription = new JEditorPane(); Color back = taDescription.getBackground(); taDescription.setEditable(false); taDescription.setBackground(back); taDescription.setEditorKit(new CustomHTMLEditorKit()); HTMLDocument doc = (HTMLDocument) taDescription.getDocument(); Style def = doc.getStyle("default"); Font font = UIManager.getFont("TextArea.font"); if (SystemUtils.IS_OS_MAC) font = UifUtilities.applyFontBias(font, -2); UifUtilities.setFontAttributes(doc.addStyle(TEXT_STYLE, def), font); builder = new BBFormBuilder("0:grow"); builder.appendUnrelatedComponentsGapRow(2); builder.appendRow("p"); builder.append(Strings.message("collections.description"), 1); builder.appendRelatedComponentsGapRow(2); builder.appendRow("50px"); builder.append(taDescription, 1, CellConstraints.FILL, CellConstraints.FILL); add(builder.getPanel(), BorderLayout.SOUTH); }
/** * Add a listener to the given combobox that will set the state to unconnected * * @param box The box to listen to. */ protected void clearOnChange(final JComboBox box) { box.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { if (!ignoreStateChangedEvents) { setState(STATE_UNCONNECTED); } } }); }
protected void createButtons(JPanel panel) { panel.add(new Filler(24, 20)); JComboBox drawingChoice = new JComboBox(); drawingChoice.addItem(fgUntitled); String param = getParameter("DRAWINGS"); if (param == null) { param = ""; } StringTokenizer st = new StringTokenizer(param); while (st.hasMoreTokens()) { drawingChoice.addItem(st.nextToken()); } if (drawingChoice.getItemCount() > 1) { panel.add(drawingChoice); } else { panel.add(new JLabel(fgUntitled)); } drawingChoice.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { loadDrawing((String) e.getItem()); } } }); panel.add(new Filler(6, 20)); JButton button; button = new CommandButton(new DeleteCommand("Delete", this)); panel.add(button); button = new CommandButton(new DuplicateCommand("Duplicate", this)); panel.add(button); button = new CommandButton(new GroupCommand("Group", this)); panel.add(button); button = new CommandButton(new UngroupCommand("Ungroup", this)); panel.add(button); button = new JButton("Help"); button.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { showHelp(); } }); panel.add(button); fUpdateButton = new JButton("Simple Update"); fUpdateButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { if (fSimpleUpdate) { setBufferedDisplayUpdate(); } else { setSimpleDisplayUpdate(); } } }); }
private void prepareTextComboBox(final Object propertyValue) { // _textComboBox wird in der letzten Zeile editierbar gemacht, und es wird // der übergebene Wert in diese Zeile eingetragen und selektiert, wenn er nicht // einem der anderen Einträge entspricht. if (propertyValue != null) { String propertyValueAsString = (String) propertyValue; final int size = _textComboBox.getModel().getSize(); boolean propertyValueFound = false; for (int i = 0; i < size - 1; i++) { if (propertyValueAsString.equals((String) _textComboBox.getItemAt(i))) { propertyValueFound = true; _textComboBox.setSelectedIndex(i); break; } } if (!propertyValueFound) { _textComboBox.removeItemAt(size - 1); _textComboBox.addItem(propertyValueAsString); _textComboBox.setSelectedIndex(size - 1); } } ItemListener textComboBoxItemListener = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { if (_textComboBox.getSelectedIndex() == DOTPointPainter.DYNAMIC_TEXT_ITEMS.length - 1) { _textComboBox.setEditable(true); } else { _textComboBox.setEditable(false); } } } }; _textComboBox.addItemListener(textComboBoxItemListener); ActionListener editorActionListener = new ActionListener() { public void actionPerformed(ActionEvent e) { final int length = DOTPointPainter.DYNAMIC_TEXT_ITEMS.length; final int index = length - 1; final ComboBoxEditor editor = _textComboBox.getEditor(); String editedItem = (String) editor.getItem(); _textComboBox.insertItemAt(editedItem, index); final DefaultComboBoxModel model = (DefaultComboBoxModel) _textComboBox.getModel(); if (model.getSize() > length) { // Sieht komisch aus, aber der direkte Weg ging nicht. model.removeElementAt(length); } } }; _textComboBox.getEditor().addActionListener(editorActionListener); }
private void addPainter(myjava.gui.syntax.Painter painter) { EntryListPanel newPanel = new EntryListPanel(painter); listPanelSet.add(newPanel); centerPanel.add(newPanel, painter.getName()); painterComboBox.removeItemListener(painterChangeListener); painterComboBox.removeAllItems(); for (EntryListPanel p : listPanelSet) { painterComboBox.addItem(p.getPainter()); } removedPainters.remove(painter); painterComboBox.addItemListener(painterChangeListener); }
private void applySelectedValue(JComboBox comboBox, Object value) { comboBox.removeItemListener(this); ValueLabelItem currentItem; for (int i = 0; i < comboBox.getItemCount(); i++) { currentItem = (ValueLabelItem) comboBox.getItemAt(i); if (currentItem.getValue().equals(value)) { comboBox.setSelectedIndex(i); break; } } comboBox.addItemListener(this); }
public CapabilitiesTest(GraphicsDevice dev) { super(dev.getDefaultConfiguration()); addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent ev) { System.exit(0); } }); initComponents(getContentPane()); GraphicsConfiguration[] gcs = dev.getConfigurations(); for (int i = 0; i < gcs.length; i++) { gcSelection.addItem(new GCWrapper(gcs[i], i)); } gcSelection.addItemListener(this); gcChanged(); }
@Override protected void initClassCombo(JComboBox classCombo) { classCombo.setRenderer(new ClassCellRenderer(classCombo.getRenderer())); classCombo.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { if (myMemberSelectionPanel != null) { ((MyMemberInfoModel) myMemberInfoModel).setSuperClass(getSuperClass()); myMemberSelectionPanel.getTable().setMemberInfos(myMemberInfos); myMemberSelectionPanel.getTable().fireExternalDataChange(); } } } }); }
DropdownImp() { b.setOpaque(false); b.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent ie) { if (ie.getStateChange() != ItemEvent.SELECTED && onSelectionChange != null && !selecting) { getInterface().getOwner().getCallbackHandler().callHandleErrors(onSelectionChange); } } }); add(b); }
private void _setUpEvents() { mHeadingComboBox.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent itemEvent) { if (itemEvent.getStateChange() == ItemEvent.SELECTED) { String key = itemEvent.getItem().toString(); Integer fontSize = HEADING_LIST.get(key); Font cFont = mTextEditor.getFont(); Font font = new Font(cFont.getFamily(), cFont.getStyle(), fontSize); _applyFontStyleForSelection(font); } } }); mTextEditor.addKeyListener( new KeyListener() { public void keyTyped(KeyEvent keyEvent) {} public void keyPressed(KeyEvent keyEvent) {} public void keyReleased(KeyEvent keyEvent) { if (keyEvent.isControlDown() && keyEvent.getKeyCode() == KeyEvent.VK_B) { Font font = new Font(mTextEditor.getFont().getFamily(), Font.BOLD, 12); _applyFontStyleForSelection(font); CharArrayWriter caw = new CharArrayWriter(); try { mTextEditor.write(caw); MutableAttributeSet set = mTextEditor.getInputAttributes(); Enumeration e = set.getAttributeNames(); while (e.hasMoreElements()) { try { StyleConstants.FontConstants at = (StyleConstants.FontConstants) e.nextElement(); } catch (Exception ex) { ex.printStackTrace(); } } System.out.println(caw.toString()); } catch (IOException e) { e.printStackTrace(); // To change body of catch statement use File | Settings | // File Templates. } } } }); }
public AddNewUser() { super("Add New User", true, false, true, true); msg = new JOptionPane(); rand = new RandomPassword(); ec = new EasyCrypt(); db = new ExecDb(); AddNewUserLayout customLayout = new AddNewUserLayout(); getContentPane().setFont(new Font("Helvetica", Font.PLAIN, 12)); getContentPane().setLayout(customLayout); accType = new JComboBox(); accType.addItem("Student"); accType.addItem("Teacher"); accType.addItem("Officer"); getContentPane().add(accType); accTxt = new JTextField(""); getContentPane().add(accTxt); label_1 = new JLabel("Add new user account", JLabel.CENTER); getContentPane().add(label_1); label_2 = new JLabel("Account Type : "); getContentPane().add(label_2); label_3 = new JLabel("Account ID : "); getContentPane().add(label_3); button_1 = new JButton("ADD"); getContentPane().add(button_1); button_2 = new JButton("CLOSE"); getContentPane().add(button_2); passTxt = new JTextField(""); passTxt.setEditable(false); getContentPane().add(passTxt); label_4 = new JLabel("Random Password : "); getContentPane().add(label_4); setSize(getPreferredSize()); accType.addItemListener(this); button_1.addActionListener(this); button_2.addActionListener(this); }
private JComponent createPanel() { final JPanel contentPane = new JPanel(); contentPane.setLayout(new GridBagLayout()); GridBagConstraints _gbc = GridBagUtils.createDefaultConstraints(); _gbc.fill = GridBagConstraints.HORIZONTAL; _gbc.anchor = GridBagConstraints.NORTHWEST; _gbc.insets.top = 2; _gbc.insets.bottom = 2; _gbc.gridx = 0; _gbc.gridy = 0; contentPane.add(new JLabel("Source Bands:"), _gbc); _gbc.fill = GridBagConstraints.BOTH; _gbc.gridx = 1; contentPane.add(new JScrollPane(bandList), _gbc); _gbc.fill = GridBagConstraints.HORIZONTAL; _gbc.gridy++; _gbc.gridx = 0; contentPane.add(selectEigenvaluesByLabel, _gbc); _gbc.gridx = 1; contentPane.add(selectEigenvaluesBy, _gbc); selectEigenvaluesBy.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent event) { updateSelectEigenvaluesBy(true); } }); int savedY = ++_gbc.gridy; DialogUtils.addComponent(contentPane, _gbc, eigenvalueThresholdLabel, eigenvalueThreshold); _gbc.gridy = savedY; DialogUtils.addComponent(contentPane, _gbc, numberOfEigenvaluesLabel, numberOfEigenvalues); _gbc.gridy++; _gbc.gridx = 0; contentPane.add(showEigenvalues, _gbc); _gbc.gridy++; contentPane.add(subtractMeanImage, _gbc); updateSelectEigenvaluesBy(true); return contentPane; }
public RunningBuy() { super(); setTitle("空闲房间查询"); setBounds(200, 40, 800, 600); setVisible(true); setLayout(null); JLabel roomkind = new JLabel("房间种类"); roomkind.setBounds(100, 80, 120, 40); add(roomkind); Container container = getContentPane(); container.add(jp); jp.setBounds(280, 80, 160, 40); jc.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { System.out.println(e.getItem()); } }); jc.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) {} }); // int index=jc.getSelectedIndex(); jp.add(jc); JTextField tf = new JTextField(); tf.setBounds(100, 200, 300, 100); add(tf); /*if(index==1){ gconn.select("select `roomID` from `tb_room` where `roomtype`= '标准双人间' and `roomstate` = 'E'"); try{String selectid=gconn.hotelrs.getString("roomID"); tf.setText(selectid);} catch(Exception e){ e.printStackTrace(); System.out.println("插入失败"); } }//*/ }
/** * This method is used to add a listner for a combobox to choose the type of the parameters of an * {@link ObixObject} in the GUI. * * @param parameterComboBox The combobox to which the listener is added. * @param paramUnitLabelxPosition The x position of the unit label of the parameter. * @param paramUnitLabelyPosition The y position of the unit label of the parameter. * @param parameterUnitLabel The unit label of the parameter. * @param parameterUnitTextField The unit textfield of the parameter. * @param pane The pane to which sates are added. * @param paramAddStateButton The button which is used to add states to the pane. * @param vbox The vbox in which the states are added. */ private void addParameterBoxListener( JComboBox parameterComboBox, int paramUnitLabelxPosition, int paramUnitLabelyPosition, JLabel parameterUnitLabel, JTextField parameterUnitTextField, Container pane, JButton paramAddStateButton, Box vbox) { parameterComboBox.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { GridBagConstraints cTemp = new GridBagConstraints(); cTemp.gridx = paramUnitLabelxPosition + 1; cTemp.gridy = paramUnitLabelyPosition; if (parameterComboBox.getSelectedItem().equals("&colibri;StateParameter")) { parameterUnitLabel.setEnabled(false); parameterUnitTextField.setEnabled(false); // stateDescriptionPanel.add(vBox1); pane.add(paramAddStateButton, cTemp); vbox.repaint(); vbox.revalidate(); cTemp.gridx++; pane.add(vbox, cTemp); } else { pane.remove(paramAddStateButton); Iterator<StateRepresentation> iter = listOfStateRepresentations.iterator(); while (iter.hasNext()) { StateRepresentation s = iter.next(); if (paramAddStateButton.equals(s.getAddButton())) { vbox.removeAll(); pane.remove(s.getContainerVBox()); iter.remove(); s.getParameter().getStateDescriptions().clear(); } } parameterUnitLabel.setEnabled(true); parameterUnitTextField.setEnabled(true); } pane.revalidate(); pane.repaint(); } }); }
public void addComponentToPane(Container pane) { // Put the JComboBox in a JPanel to get a nicer look. JPanel birdsPanel = new JPanel(); // use FlowLayout String[] comboBoxItems = store.getBirdsTypeArray(); JComboBox comboBoxBirds = new JComboBox(comboBoxItems); comboBoxBirds.setEditable(false); comboBoxBirds.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { CardLayout cl = (CardLayout) (cards.getLayout()); cl.show(cards, (String) e.getItem()); } }); birdsPanel.add(comboBoxBirds); // cards = new JPanel(new CardLayout()); for (String item : comboBoxItems) { JPanel card = new JPanel(); JLabel label = new JLabel(item); card.add(label); System.out.println( item + "==" + BirdsType.valueOf(item) + "===" + store.getBirdsByTypeList(item).size()); for (Bird bird : store.getBirdsByTypeList(item)) { System.out.println(bird.getName()); JRadioButton rButton = new JRadioButton(bird.getName()); rButton.setActionCommand(bird.getName()); card.add(rButton); } cards.add(card, item); } pane.add(birdsPanel, BorderLayout.PAGE_START); pane.add(cards, BorderLayout.CENTER); }
private void initToolbar() { JToolBar tbTraceFilters = new JToolBar(); tbTraceFilters.setFloatable(false); tbTraceFilters.setRollover(true); tbTraceFilters.add(new JLabel("Min time:")); txtMinTime = new JTextField(4); tbTraceFilters.add(txtMinTime); JButton btnFilterByTime = new JButton(new FilterByTimeAction()); btnFilterByTime.setFocusable(false); btnFilterByTime.setToolTipText("Filter by trace execution time"); tbTraceFilters.add(btnFilterByTime); tbTraceFilters.addSeparator(); btnFilterErrors = new JToggleButton(new FilterByErrorAction()); btnFilterErrors.setFocusable(false); btnFilterErrors.setToolTipText("Show only traces with errors"); tbTraceFilters.add(btnFilterErrors); tbTraceFilters.addSeparator(); cmbTraceType = new JComboBox(); cmbTraceType.addItem("*"); cmbTraceType.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { String item = (String) e.getItem(); traceLabel = "*".equals(item) ? null : item; tbmTraces.setDataSet(dataSet, traceFilter); } } }); tbTraceFilters.add(cmbTraceType); add(tbTraceFilters, BorderLayout.NORTH); }
public ChangeListChooser(List<? extends ChangeList> lists) { super(new BorderLayout(4, 2)); myChooser = new JComboBox(); //noinspection unchecked myChooser.setRenderer( new ColoredListCellRendererWrapper<LocalChangeList>() { @Override protected void doCustomize( JList list, LocalChangeList value, int index, boolean selected, boolean hasFocus) { if (value != null) { String name = value.getName().trim(); if (name.length() > MAX_LEN) { name = name.substring(0, MAX_LEN - 3) + "..."; } append( name, value.isDefault() ? SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES : SimpleTextAttributes.REGULAR_ATTRIBUTES); } } }); myChooser.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { final LocalChangeList changeList = (LocalChangeList) myChooser.getSelectedItem(); setSelectedList(changeList); myChooser.setToolTipText(changeList == null ? "" : (changeList.getName())); } } }); updateLists(lists); myChooser.setEditable(false); add(myChooser, BorderLayout.CENTER); JLabel label = new JLabel(VcsBundle.message("commit.dialog.changelist.label")); label.setLabelFor(myChooser); add(label, BorderLayout.WEST); }
private StaticPanel createStaticTextPanel(PrimitiveForm primitiveForm, DOTProperty property) { StaticPanel theTextPanel = createStaticComboBoxPanel( primitiveForm, property, "Text: ", DOTPointPainter.STATIC_TEXT_ITEMS); final JComboBox theComboBox = theTextPanel.getComboBox(); if (theComboBox == null) { return theTextPanel; } ItemListener comboBoxItemListener = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { if (theComboBox.getSelectedIndex() == DOTPointPainter.STATIC_TEXT_ITEMS.length - 1) { theComboBox.setEditable(true); } else { theComboBox.setEditable(false); } } } }; theComboBox.addItemListener(comboBoxItemListener); ActionListener editorActionListener = new ActionListener() { public void actionPerformed(ActionEvent e) { final int length = DOTPointPainter.STATIC_TEXT_ITEMS.length; final int index = length - 1; final ComboBoxEditor editor = theComboBox.getEditor(); String editedItem = (String) editor.getItem(); theComboBox.insertItemAt(editedItem, index); final DefaultComboBoxModel model = (DefaultComboBoxModel) theComboBox.getModel(); if (model.getSize() > length) { // Sieht komisch aus, aber der direkte Weg ging nicht. model.removeElementAt(length); } } }; theComboBox.getEditor().addActionListener(editorActionListener); return theTextPanel; }
private void initializeGUI() { frame = new JFrame("bug4523758"); tools = new JToolBar(); frame.getContentPane().add(tools, BorderLayout.NORTH); combo = new JComboBox( new Object[] {"Red", "Orange", "Yellow", "Green", "Blue", "Indigo", "Violet"}); combo.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent event) { itemStateChanged = true; synchronized (itemLock) { try { itemLock.notifyAll(); } catch (Exception e) { } } } }); tools.add(combo); frame.setSize(250, 400); frame.setLocation(700, 0); frame.setVisible(true); }
public ConditionPanel(TriggerDialog owner, @Nullable Condition condition) { super(); BoxLayout layout = new BoxLayout(this, BoxLayout.Y_AXIS); setLayout(layout); setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 5)); this.owner = owner; ConditionTemplate[] templates = ConditionTemplates.getInstance().getTemplates(); Arrays.sort(templates); conditionType = new JComboBox(templates); parameterPanels = new JPanel(new GridLayout(0, 1, 0, 5)); addCondition = new JButton("+"); removeCondition = new JButton("-"); final JPanel header = new JPanel(); header.add(conditionType); header.add(removeCondition); header.add(addCondition); add(header); add(parameterPanels); final TriggerDialog dialog = this.owner; conditionType.addItemListener( new ItemListener() { public void itemStateChanged(@Nonnull ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { parameterPanels.removeAll(); ConditionTemplate template = (ConditionTemplate) e.getItem(); for (int i = 0; i < template.size(); ++i) { ParameterPanel parameter = new ParameterPanel(template.getParameter(i)); parameterPanels.add(parameter); } dialog.pack(); dialog.validate(); } else if (e.getStateChange() == ItemEvent.DESELECTED) { parameterPanels.removeAll(); dialog.pack(); dialog.validate(); } } }); conditionType.setSelectedIndex(-1); if (condition != null) { conditionType.setSelectedItem( ConditionTemplates.getInstance().getTemplate(condition.getType())); Object[] parameters = condition.getParameters(); for (int i = 0; i < parameters.length; ++i) { ParameterPanel panel = (ParameterPanel) parameterPanels.getComponent(i); panel.setParameter(parameters[i]); } } addCondition.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialog.addCondition(); } }); final ConditionPanel conditionPanel = this; removeCondition.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialog.removeCondition(conditionPanel); } }); }