List of usage examples for javax.swing DefaultComboBoxModel DefaultComboBoxModel
public DefaultComboBoxModel(Vector<E> v)
From source file:org.jdal.swing.form.FormUtils.java
/** * Add a link on primary and dependent JComboBoxes by property name. * When selection changes on primary use propertyName to get a Collection and fill dependent JComboBox with it * @param primary JComboBox when selection changes * @param dependent JComboBox that are filled with collection * @param propertyName the property name for get the collection from primary selected item * @param addNull if true, add a null as first combobox item *///from w w w. j a v a 2 s . c o m @SuppressWarnings("rawtypes") public static void link(final JComboBox primary, final JComboBox dependent, final String propertyName, final boolean addNull) { primary.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Object selected = primary.getSelectedItem(); if (selected != null) { BeanWrapper wrapper = PropertyAccessorFactory.forBeanPropertyAccess(selected); if (wrapper.isWritableProperty(propertyName)) { Collection collection = (Collection) wrapper.getPropertyValue(propertyName); Vector<Object> vector = new Vector<Object>(collection); if (addNull) vector.add(0, null); DefaultComboBoxModel model = new DefaultComboBoxModel(vector); dependent.setModel(model); } else { log.error("Can't write on propety '" + propertyName + "' of class: '" + selected.getClass() + "'"); } } } }); }
From source file:de.erdesignerng.visual.editor.convertmodel.ConvertPropertyAdapter.java
@Override public void model2view(Object aModel, String aPropertyName) { ConversionInfos theInfos = (ConversionInfos) aModel; String theCurrentTypeName = helper.getText(ERDesignerBundle.CURRENTDATATYPE); String theTargetTypeName = helper.getText(ERDesignerBundle.TARGETDATATYPE); DataType[] theTargetTypes = new DataType[theInfos.getTypeMapping().keySet().size()]; List<DataType> theCurrentTypes = new ArrayList<>(); theCurrentTypes.addAll(theInfos.getTypeMapping().keySet()); Collections.sort(theCurrentTypes, new BeanComparator("name")); for (int i = 0; i < theCurrentTypes.size(); i++) { theTargetTypes[i] = theInfos.getTypeMapping().get(theCurrentTypes.get(i)); }// w ww . j av a 2 s.com DefaultTable theTable = (DefaultTable) getComponent()[0]; ConversionTableModel theModel = new ConversionTableModel(theCurrentTypeName, theTargetTypeName, theCurrentTypes, theTargetTypes); theTable.setModel(theModel); DefaultComboBox theTargetTypesEditor = new DefaultComboBox(); theTargetTypesEditor.setBorder(BorderFactory.createEmptyBorder()); theTargetTypesEditor.setModel(new DefaultComboBoxModel(theInfos.getTargetDialect().getDataTypes() .toArray(new DataType[theInfos.getTargetDialect().getDataTypes().size()]))); theTable.getColumnModel().getColumn(1).setCellEditor(new DefaultCellEditor(theTargetTypesEditor)); theTable.setRowHeight((int) theTargetTypesEditor.getPreferredSize().getHeight()); }
From source file:com.chenjw.imagegrab.ui.MainFrame.java
private void initSpring() { ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("classpath*:grab-tool.xml"); imagegrabService = (ImagegrabService) ctx.getBean("imagegrabService"); System.out.println("spring inited!"); resultPane.append("???\n"); // //from w ww . j ava 2s . c o m // List<KeyValuePair> pairs = new ArrayList<KeyValuePair>(); for (Entry<String, String> entry : GrabberContainer.getIds().entrySet()) { pairs.add(new KeyValuePair(entry.getKey(), entry.getValue())); } ComboBoxModel historyComboBox1Model = new DefaultComboBoxModel( pairs.toArray(new KeyValuePair[pairs.size()])); sourceComboBox.setModel(historyComboBox1Model); // imagegrabService.setDataHandler(new DataHandler() { @Override public void appendResult(String text) { resultPane.append(text); resultPane.setCaretPosition(resultPane.getText().length()); } @Override public void clearResult() { resultPane.setText(null); } @Override public String getSearchWord() { return searchWordComboBox.getText(); } @Override public String getSource() { KeyValuePair pair = (KeyValuePair) sourceComboBox.getSelectedItem(); if (pair == null) { return null; } return pair.key; } @Override public String getMaxNum() { return maxNumComboBox.getText(); } }); }
From source file:net.brtly.monkeyboard.plugin.ConsolePanel.java
public ConsolePanel(PluginDelegate service) { super(service); setLayout(new MigLayout("inset 5", "[grow][:100:100][24:n:24][24:n:24]", "[::24][grow]")); JComboBox comboBox = new JComboBox(); comboBox.setToolTipText("Log Level"); comboBox.setMaximumRowCount(6);// ww w . ja v a2s . c om comboBox.setModel( new DefaultComboBoxModel(new String[] { "Fatal", "Error", "Warn", "Info", "Debug", "Trace" })); comboBox.setSelectedIndex(5); add(comboBox, "cell 1 0,growx"); JButton btnC = new JButton(""); btnC.setToolTipText("Clear Buffer"); btnC.setIcon(new ImageIcon(ConsolePanel.class.getResource("/img/clear-document.png"))); btnC.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { logPangrams(); } }); add(btnC, "cell 2 0,wmax 24,hmax 26"); tglbtnV = new JToggleButton(""); tglbtnV.setToolTipText("Auto Scroll"); tglbtnV.setIcon(new ImageIcon(ConsolePanel.class.getResource("/img/auto-scroll.png"))); tglbtnV.setSelected(true); tglbtnV.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent ev) { if (ev.getStateChange() == ItemEvent.SELECTED) { _table.setAutoScroll(true); } else if (ev.getStateChange() == ItemEvent.DESELECTED) { _table.setAutoScroll(false); } } }); add(tglbtnV, "cell 3 0,wmax 24,hmax 26"); scrollPane = new JScrollPane(); scrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent e) { // TODO figure out what to do with this event? } }); add(scrollPane, "cell 0 1 4 1,grow"); _table = new JLogTable("Time", "Source", "Message"); _table.getColumnModel().getColumn(0).setMinWidth(50); _table.getColumnModel().getColumn(0).setPreferredWidth(50); _table.getColumnModel().getColumn(0).setMaxWidth(100); _table.getColumnModel().getColumn(1).setMinWidth(50); _table.getColumnModel().getColumn(1).setPreferredWidth(50); _table.getColumnModel().getColumn(1).setMaxWidth(100); _table.getColumnModel().getColumn(2).setMinWidth(50); _table.getColumnModel().getColumn(2).setWidth(255); _table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); scrollPane.setViewportView(_table); _appender = new JLogTableAppender(); _appender.setThreshold(Level.ALL); Logger.getRootLogger().addAppender(_appender); }
From source file:net.sf.maltcms.chromaui.ui.PaintScalePanel.java
/** * Creates new form PaintScalePanel/*from w w w. j ava2s .c o m*/ */ public PaintScalePanel(PaintScale activePaintScale, int alpha, int beta) { this.alpha = alpha; this.beta = beta; initComponents(); String[] s = new String[] { "res/colorRamps/bcgyr.csv", "res/colorRamps/bgr.csv", "res/colorRamps/bw.csv", "res/colorRamps/br.csv", "res/colorRamps/bgrw.csv", "res/colorRamps/rgbr.csv" }; for (String str : s) { GradientPaintScale gradientPaintScale = new GradientPaintScale(getSampleTable(samples), 0, 1, ImageTools.rampToColorArray(new ColorRampReader().readColorRamp(str))); gradientPaintScale.setLabel(str); elements.add(gradientPaintScale); } dcbm = new DefaultComboBoxModel(elements.toArray(new PaintScale[elements.size()])); jComboBox1.setModel(dcbm); jSlider1.addChangeListener(this); jSlider2.addChangeListener(this); st = getSampleTable(samples); bp = getBreakpointTable(samples); Logger.getLogger(getClass().getName()).log(Level.INFO, "Sample table: {0}", Arrays.toString(st)); if (activePaintScale == null) { gps = (PaintScale) jComboBox1.getSelectedItem(); } else { elements.add(0, activePaintScale); gps = activePaintScale; } jComboBox1.setSelectedIndex(0); if (gps instanceof GradientPaintScale) { ((GradientPaintScale) gps).setAlphaBeta(this.alpha, this.beta); } modifyPaintScale((GradientPaintScale) gps); }
From source file:com.konifar.material_icon_generator.FilterComboBox.java
public void filter(String inputText) { List<String> filterList = new ArrayList<String>(); for (String text : comboBoxList) { if (text.toLowerCase().contains(inputText.toLowerCase())) { filterList.add(text);/*from www. j ava 2s . c o m*/ } } if (!filterList.isEmpty()) { setModel(new DefaultComboBoxModel(filterList.toArray())); setSelectedItem(inputText); showPopup(); } else { hidePopup(); } }
From source file:generadorqr.jifrGestionArticulos.java
public jifrGestionArticulos() { initComponents();/*from w w w . j a v a 2s. co m*/ if (conn == null) conn = mysql.getConnect(); if (LlenarTablaArticulos() != null) jtContenidosArticulos.setModel(LlenarTablaArticulos()); btgSeleccion.add(rbtnBuscarPorCategoria); btgSeleccion.add(rbtnBuscarPorNombre); rbtnBuscarPorCategoria.setVisible(false); rbtnBuscarPorNombre.setVisible(false); contarTotalE(); sumarTotalA(); lblEtiquetaPreviewImagenes.setVisible(false); lblEtiquetaPreviewQr.setVisible(false); jcbBuscarQrCategora.setVisible(false); if (UsuarioIngresado.parametroR.contains("Consultor/a")) { btnNuevosArticulos.setVisible(false); lblNuevoArticulo.setVisible(false); btnActualizarArticulos.setVisible(false); lblActualizarA.setVisible(false); btnEliminarArticulos.setVisible(false); lblEliminarArticulo.setVisible(false); lblBuscarArticulo.setVisible(false); } String SQLC = "SELECT IDCATEGORIA,NOMBRECATEGORIA,DESCRIPCIONCATEGORIA FROM categorias"; mdlC = new DefaultComboBoxModel(ConexionBase.leerDatosVector1(SQLC)); categorias = ConexionBase.leerDatosVector1(SQLC); this.jcbBuscarQrCategora.setModel(mdlC); }
From source file:generadorqr.jifrNuevoQr.java
public jifrNuevoQr() { initComponents();/*w w w . j a va2s . c o m*/ jcbCategoriasQR.setFocusable(true); Random rnd = new Random(); Date fecha = new Date(); numeroAleatorioTitulo = rnd.nextInt(hasta - desde + 1) + desde; DateFormat formatoFechaHora = new SimpleDateFormat("ddMMyyyyHHmmss"); fechaActual = formatoFechaHora.format(fecha); //this.setLocationRelativeTo(null); conn = mysql.getConnect(); lblIdQR.setVisible(false); String SQLC = "SELECT IDCATEGORIA,NOMBRECATEGORIA,DESCRIPCIONCATEGORIA FROM categorias"; mdlC = new DefaultComboBoxModel(ConexionBase.leerDatosVector1(SQLC)); categorias = ConexionBase.leerDatosVector1(SQLC); this.jcbCategoriasQR.setModel(mdlC); lblIdQR.setVisible(false); accion = ItemSeleccionado.accionBoton; btnGenerarNuevoQr.setText(accion); try { //Muestra los usuarios existentes en la base de datos if (accion.contains("Actualizar")) { txtNombreQr.setEnabled(false); jlGenerarQr.setText(accion + " datos del QR"); lblIdQR.setText("ID del Usuario: \t\t" + ItemSeleccionado.idArticulo); lblIdQR.setVisible(true); for (int i = 0; i < categorias.size(); i++) { String tempCategoria = categorias.get(i).getNombreCategoria(); if (tempCategoria.contains(ItemSeleccionado.idCategoria)) idCat = i; } jcbCategoriasQR.setSelectedIndex(idCat); String SQLTU = "SELECT * FROM articulos WHERE IDARTICULO = " + ItemSeleccionado.idArticulo; sent = conn.createStatement(); ResultSet rs = sent.executeQuery(SQLTU); rs.next(); txtNombreQr.setText(rs.getString("NOMBREARTICULO")); txtCantidadArticulo.setText(rs.getString("CANTIDADARTICULO")); txtAreaDescripcionNuevoQr.setText(rs.getString("DESCRIPCIONARTICULO")); tempRutaActual[0] = rs.getString("IMAGENUNOARTICULO"); tempRutaActual[1] = rs.getString("IMAGENDOSARTICULO"); tempRutaActual[2] = rs.getString("IMAGENTRESARTICULO"); tempRutaActual[3] = rs.getString("SONIDOARTICULO"); tempRutaActual[4] = rs.getString("VIDEOARTICULO"); tempRutaActual[5] = rs.getString("IMAGENQRARTICULO"); rs.close(); Mostrar_Visualizador(btnImagen1, tempRutaActual[0]); if (!tempRutaActual[1].isEmpty()) Mostrar_Visualizador(btnImagen2, tempRutaActual[1]); if (!tempRutaActual[2].isEmpty()) Mostrar_Visualizador(btnImagen3, tempRutaActual[2]); if (!tempRutaActual[3].isEmpty()) jlAudioQr.setText("Audio.mp3"); if (!tempRutaActual[4].isEmpty()) jlVideoQr.setText("Video.mp4"); Mostrar_Visualizador(lblImagenQR, tempRutaActual[5]); } } catch (Exception e) { } }
From source file:jeplus.gui.JPanel_TrnsysProjectFiles.java
/** * Creates new form JPanel_EPlusProjectFiles with parameters *///from w ww . jav a 2 s. c o m public JPanel_TrnsysProjectFiles(JEPlusFrameMain frame, JEPlusProject project) { initComponents(); MainGUI = frame; Project = project; this.txtGroupID.setText(Project.getProjectID()); this.txtGroupNotes.setText(Project.getProjectNotes()); txtDCKDir.setText(Project.getDCKDir()); if (Project.getDCKTemplate() != null) { cboTemplateFile.setModel(new DefaultComboBoxModel(Project.getDCKTemplate().split("\\s*;\\s*"))); } else { cboTemplateFile.setModel(new DefaultComboBoxModel(new String[] { "Select files..." })); } txtOutputFileNames.setText(Project.getOutputFileNames()); txtRviDir.setText(Project.getRVIDir()); if (Project.getRVIFile() != null) { cboRviFile.setModel(new DefaultComboBoxModel(new String[] { Project.getRVIFile() })); } else { cboRviFile.setModel(new DefaultComboBoxModel(new String[] { "Select a file..." })); } // Set listeners to text fields DL = new DocumentListener() { Document DocProjID = txtGroupID.getDocument(); Document DocProjNotes = txtGroupNotes.getDocument(); Document DocDCKDir = txtDCKDir.getDocument(); Document DocOutputFiles = txtOutputFileNames.getDocument(); Document DocRviDir = txtRviDir.getDocument(); @Override public void insertUpdate(DocumentEvent e) { Document src = e.getDocument(); if (src == DocProjID) { Project.setProjectID(txtGroupID.getText()); } else if (src == DocProjNotes) { Project.setProjectNotes(txtGroupNotes.getText()); } else if (src == DocDCKDir) { Project.setDCKDir(txtDCKDir.getText()); } else if (src == DocOutputFiles) { Project.setOutputFileNames(txtOutputFileNames.getText()); } else if (src == DocRviDir) { Project.setRVIDir(txtRviDir.getText()); } } @Override public void removeUpdate(DocumentEvent e) { insertUpdate(e); } @Override public void changedUpdate(DocumentEvent e) { // not applicable } }; txtGroupID.getDocument().addDocumentListener(DL); txtGroupNotes.getDocument().addDocumentListener(DL); txtDCKDir.getDocument().addDocumentListener(DL); txtOutputFileNames.getDocument().addDocumentListener(DL); txtRviDir.getDocument().addDocumentListener(DL); }
From source file:de.tor.tribes.ui.windows.ClockFrame.java
/** * Creates new form ClockFrame//from ww w . j a v a 2 s . c om */ ClockFrame() { initComponents(); jSpinner1.setValue(new Date(System.currentTimeMillis())); ((DateEditor) jSpinner1.getEditor()).getFormat().applyPattern("dd.MM.yy HH:mm:ss.SSS"); tThread = new TimerThread(this); tThread.start(); jCheckBox1.setSelected(GlobalOptions.getProperties().getBoolean("clock.alwaysOnTop")); setAlwaysOnTop(jCheckBox1.isSelected()); cp = new ColoredProgressBar(0, 1000); jPanel1.add(cp, BorderLayout.CENTER); jComboBox1.setModel(new DefaultComboBoxModel(new String[] { "Alarm", "Homer", "LetsGo", "NHL", "Roadrunner", "Schwing", "Sirene", "StarTrek1", "StarTrek2" })); // <editor-fold defaultstate="collapsed" desc=" Init HelpSystem "> if (!Constants.DEBUG) { GlobalOptions.getHelpBroker().enableHelpKey(getRootPane(), "pages.clock_tool", GlobalOptions.getHelpBroker().getHelpSet()); } restoreTimers(); // </editor-fold> }