List of usage examples for javax.swing DefaultComboBoxModel addElement
public void addElement(E anObject)
From source file:paquete.HollywoodUI.java
private void btn_save_actorMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btn_save_actorMouseClicked try {/* ww w. j ava 2s. c o m*/ label_profile.setIcon(new ImageIcon("./src/sources/user_profile.png")); String nombre = tf_nombre.getText(); int edad = Integer.parseInt(tf_edad.getText()); String nacionalidad = tf_nacionalidad.getText(); temp.setNombre(nombre); temp.setEdad(edad); temp.setNacionalidad(nacionalidad); tf_nombre.setText(""); tf_edad.setText(""); tf_nacionalidad.setText(""); DefaultComboBoxModel model = (DefaultComboBoxModel) this.cb_actores_existentes.getModel(); DefaultComboBoxModel model_list_modifica = (DefaultComboBoxModel) this.cb_list_modifica.getModel(); DefaultComboBoxModel model_relacion1 = (DefaultComboBoxModel) this.cb_Actor_uno.getModel(); DefaultComboBoxModel model_relacion2 = (DefaultComboBoxModel) this.cb_Actor_dos.getModel(); DefaultComboBoxModel model_relacion3 = (DefaultComboBoxModel) this.cb_Actor_uno1.getModel(); DefaultComboBoxModel model_relacion4 = (DefaultComboBoxModel) this.cb_Actor_dos1.getModel(); DefaultComboBoxModel model_relacion5 = (DefaultComboBoxModel) this.cb_Actor_uno2.getModel(); DefaultComboBoxModel model_relacion6 = (DefaultComboBoxModel) this.cb_Actor_dos2.getModel(); DefaultComboBoxModel model_relacion7 = (DefaultComboBoxModel) this.cb_list_eliminar.getModel(); boolean agregar = true; actoresArray = new ArrayList<>(HollyUniverseGraph.getVertices()); for (int i = 0; i < actoresArray.size(); i++) { if (nombre.equals(actoresArray.get(i).getNombre())) { agregar = false; } } if (agregar) { JOptionPane.showMessageDialog(add_actor, "Actor agregado con exito\nahora puede agregar al grafico!!!", "Agregado", JOptionPane.INFORMATION_MESSAGE); HollyUniverseGraph.addVertex(temp); actoresArray.add(temp); historialGestion.agregarElemento(temp, "Se registro un actor"); System.out.println(HollyUniverseGraph.getVertices().toString()); model.addElement(temp); model_list_modifica.addElement(temp); model_relacion1.addElement(temp); model_relacion2.addElement(temp); model_relacion3.addElement(temp); model_relacion4.addElement(temp); model_relacion5.addElement(temp); model_relacion6.addElement(temp); model_relacion7.addElement(temp); } else { JOptionPane.showMessageDialog(add_actor, "Actor NO agregado, el actor ya fue agregado anteriormente ", "Agregado", JOptionPane.ERROR_MESSAGE); } label_grafico.setIcon(new ImageIcon("./src/sources/hollywoodUniverseV2.jpg")); temp = new Actor();//reinicio de actor nuevo add_actor.setVisible(false); } catch (Exception e) { JOptionPane.showMessageDialog(add_actor, "Actor NO agregado, Ocurrio un error inesperado!!! ", "ERROR", JOptionPane.ERROR_MESSAGE); } // modelo_history.addElement(historialGestion.historial.pop()); // list_history.setModel(modelo_history); }
From source file:paquete.HollywoodUI.java
private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MouseClicked try {/*ww w .j av a 2 s . co m*/ Peliculas.remove(cb_delete_movie.getSelectedIndex()); if (Peliculas.isEmpty()) { DefaultComboBoxModel model = (DefaultComboBoxModel) cb_delete_movie.getModel(); model.removeAllElements(); model.addElement("No hay mas peliculas"); } else { DefaultComboBoxModel model = (DefaultComboBoxModel) cb_delete_movie.getModel(); model.removeElementAt(Peliculas.size() - 1); model.addElement(Peliculas.get(Peliculas.size() - 1)); } JOptionPane.showMessageDialog(delete_movie, "Pelicula eliminada por completo", "INFO", JOptionPane.INFORMATION_MESSAGE); } catch (Exception e) { JOptionPane.showMessageDialog(delete_movie, "Error al tratar de eliminar la pelicula", "Error", JOptionPane.ERROR_MESSAGE); } }
From source file:pipeline.GUI_utils.ListOfPointsView.java
@SuppressWarnings("unchecked") public void setFieldForColoring(@NonNull String fieldName) { @SuppressWarnings("rawtypes") DefaultComboBoxModel comboBoxModel = (DefaultComboBoxModel) coloringComboBox.getModel(); for (int i = 0; i < comboBoxModel.getSize(); i++) { if (fieldName.equals(comboBoxModel.getElementAt(i))) { comboBoxModel.setSelectedItem(fieldName); return; }//from w w w . j a v a 2 s .co m } comboBoxModel.addElement(fieldName); comboBoxModel.setSelectedItem(fieldName); }
From source file:pipeline.GUI_utils.ListOfPointsView.java
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override/*from ww w . j av a 2 s . c o m*/ public void show() { if (frame != null) frame.toFront(); if (table == null) { spreadsheetEngine = new DependencyEngine(new BasicEngineProvider()); setupTableModel(points); silenceUpdates.incrementAndGet(); table = new JXTablePerColumnFiltering(tableModel); table.setRolloverEnabled(true); // table.setDragEnabled(true); table.setFillsViewportHeight(false); table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); table.setShowGrid(true); table.setShowHorizontalLines(true); table.setColumnSelectionAllowed(true); table.setRowSelectionAllowed(true); table.setColumnControlVisible(true); table.setHighlighters(new Highlighter[] { HighlighterFactory.createAlternateStriping() }); table.addPropertyChangeListener("horizontalScrollEnabled", new PropertyChangeListener() { JViewport viewPort, filteringViewPort, columnDescViewPort; int lastX; ChangeListener scrollListener = new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { if (viewPort == null || filteringViewPort == null) { return; } Point position = viewPort.getViewPosition(); if (position.x == lastX) { return; } filteringViewPort.setViewPosition(position); columnDescViewPort.setViewPosition(position); lastX = position.x; } }; @Override public void propertyChange(PropertyChangeEvent evt) { if (viewPort != null) { viewPort.removeChangeListener(scrollListener); } if (evt.getNewValue().equals(true)) { viewPort = getTableViewPort(table); if (viewPort == null) { return; } table.filteringTable.setHorizontalScrollEnabled(true); table.tableForColumnDescriptions.setHorizontalScrollEnabled(true); table.updateFilteringTableSetup(); filteringViewPort = getTableViewPort(table.filteringTable); columnDescViewPort = getTableViewPort(table.tableForColumnDescriptions); viewPort.addChangeListener(scrollListener); scrollListener.stateChanged(null); } else { table.filteringTable.setHorizontalScrollEnabled(false); table.tableForColumnDescriptions.setHorizontalScrollEnabled(false); } } }); modelForColumnDescriptions = new dataModelAllEditable(1, tableModel.getColumnCount()); Vector<String> rowVector0 = (Vector<String>) modelForColumnDescriptions.getDataVector().get(0); for (int j = 0; j < tableModel.getColumnCount(); j++) { rowVector0.setElementAt(tableModel.getColumnName(j), j); } boolean done; do { done = true; for (TableColumn i : table.getColumns(true)) { TableColumnExt iCast = (TableColumnExt) i; if (iCast.getTitle().equals("Class") || iCast.getTitle().equals("c") || iCast.getTitle().equals("t") || iCast.getTitle().equals("clusterID") || iCast.getTitle().equals("userCell 2") || iCast.getTitle().equals("userCell 3")) { if (iCast.isVisible()) { iCast.setVisible(false); done = false; break; } } } } while (!done); SwingUtilities.invokeLater(modelForColumnDescriptions::fireTableDataChanged); JScrollPane scrollPane = new JScrollPane(table); scrollPane.setPreferredSize(new Dimension(2000, 2000)); updateColumnDescriptions(); silenceUpdates.decrementAndGet(); setSpreadsheetColumnEditorAndRenderer(); tableForColumnDescriptions = new JXTable(modelForColumnDescriptions); table.tableForColumnDescriptions = tableForColumnDescriptions; JScrollPane jScrollPaneForNames = new JScrollPane(tableForColumnDescriptions); jScrollPaneForNames.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); JPanel controlPanel = new JPanel(); controlPanel.setLayout(new FlowLayout()); JButton createScatterPlotButton = new JButton("Scatter plot from selected columns"); controlPanel.add(createScatterPlotButton); createScatterPlotButton.setActionCommand("Scatter plot from selected columns"); createScatterPlotButton.addActionListener(this); realTimeUpdateCheckbox = new JCheckBox("Update display in real time"); controlPanel.add(realTimeUpdateCheckbox); realTimeUpdateCheckbox.setActionCommand("Update display in real time"); realTimeUpdateCheckbox.addActionListener(this); JButton forceUpdate = new JButton("Force display update"); controlPanel.add(forceUpdate); forceUpdate.setActionCommand("Force display update"); forceUpdate.addActionListener(this); JButton extendFormula = new JButton("Extend formula to column"); controlPanel.add(extendFormula); extendFormula.setActionCommand("Extend formula to column"); extendFormula.addActionListener(this); JButton saveFormulas = new JButton("Save user formulas..."); saveFormulas.addActionListener(this); saveFormulas.setActionCommand("Save user formulas"); controlPanel.add(saveFormulas); JButton reloadFormulas = new JButton("Reload user formulas..."); reloadFormulas.addActionListener(this); reloadFormulas.setActionCommand("Reload user formulas"); controlPanel.add(reloadFormulas); controlPanel.add(new JLabel("Color with:")); coloringComboBox = new JComboBox(); controlPanel.add(coloringComboBox); DefaultComboBoxModel comboBoxModel = (DefaultComboBoxModel) coloringComboBox.getModel(); coloringComboBox.addActionListener(this); for (int i = 0; i < tableModel.getColumnCount(); i++) { comboBoxModel.addElement(tableModel.getColumnName(i)); } JButton saveTableToFile = new JButton("Save table to file"); controlPanel.add(saveTableToFile); saveTableToFile.setActionCommand("Save table to file"); saveTableToFile.addActionListener(this); /* final JCheckBox useCalibration = new JCheckBox("Use calibration"); useCalibration.addActionListener(e -> { if (points == null) return; boolean selected = useCalibration.isSelected(); if (selected && !(points instanceof PluginIOCalibrable)) { Utils.displayMessage("Type " + points.getClass().getName() + " does not have calibration", true, LogLevel.ERROR); return; } PluginIOCalibrable calibrable = (PluginIOCalibrable) points; if (selected && (calibrable.getCalibration() == null)) { Utils.displayMessage("Calibration information is not present in the segmentation; one " + "way of adding it is to give the source image (with calibration) as an input " + "to the active contour plugin", true, LogLevel.ERROR); return; } float xyCalibration = selected ? ((float) calibrable.getCalibration().pixelWidth) : 0; float zCalibration = selected ? ((float) calibrable.getCalibration().pixelDepth) : 0; updateCalibration(xyCalibration, zCalibration); }); PluginIOCalibrable calibrable = null; if (points instanceof PluginIOCalibrable) calibrable = (PluginIOCalibrable) points; boolean calibrationPresent = calibrable != null && calibrable.getCalibration() != null; useCalibration.setSelected(calibrationPresent); if (calibrationPresent) { updateCalibration((float) calibrable.getCalibration().pixelWidth, (float) calibrable.getCalibration().pixelDepth); } controlPanel.add(useCalibration); */ frame = new JFrame(points.getName()); frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); listener = new WindowListenerWeakRef(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { close();// So all references to data are nulled, to ensure garbage collection } }); frame.addWindowListener(listener); frame.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.gridx = 0; c.gridy = GridBagConstraints.RELATIVE; c.weighty = 0.75; c.weightx = 1.0; c.gridwidth = 1; c.gridheight = 1; frame.add(scrollPane, c); c.weighty = 0.0; JScrollPane scrollPane2 = new JScrollPane(table.filteringTable); scrollPane2.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane2.setMinimumSize(new Dimension(1, 250)); frame.add(scrollPane2, c); c.weighty = 0.0; jScrollPaneForNames.setMinimumSize(new Dimension(1, 40)); jScrollPaneForNames.setMaximumSize(new Dimension(9999999, 40)); frame.add(jScrollPaneForNames, c); c.weighty = 0.0; c.fill = GridBagConstraints.HORIZONTAL; controlPanel.setMinimumSize(new Dimension(1, 80)); frame.add(controlPanel, c); table.setHorizontalScrollEnabled(true); table.updateFilteringTableSetup(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); int height = screenSize.height; int width = screenSize.width; frame.setSize((int) (0.67 * width), height / 2); frame.setLocation((int) (0.33 * width), height / 2); frame.setVisible(true); } if ((tableUpdateThread == null) || (!tableUpdateThread.isAlive())) { tableUpdateThread = new Thread(() -> { try { checkForDirtiness(); } catch (Exception e) { Utils.log("Exception in ListOfPointsView GUI update thread", LogLevel.ERROR); Utils.printStack(e); } }, "ListOfPointsView GUI update thread"); tableUpdateThread.start(); } }
From source file:pl.otros.logview.gui.LogViewPanel.java
protected void initMessageDetailsToolbar() { final JButton buttonFormatters = new JButton("Message formatters", Icons.MESSAGE_FORMATTER); buttonFormatters.addMouseListener(new MouseAdapter() { @Override/*from w w w. java 2s .c om*/ public void mouseClicked(MouseEvent e) { showMessageFormatterOrColorizerPopupMenu(e, "Message formatters", selectedMessageFormattersContainer, messageFormattersContainer); } }); buttonFormatters.setToolTipText("Select used message formatters"); messageDetailToolbar.add(buttonFormatters); final JButton buttonColorizers = new JButton("Message colorizers", Icons.MESSAGE_COLORIZER); buttonColorizers.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { showMessageFormatterOrColorizerPopupMenu(e, "Message colorizers", selectedMessageColorizersContainer, messageColorizersContainer); } }); buttonColorizers.setToolTipText("Select used message colorizers"); messageDetailToolbar.add(buttonColorizers); messageDetailToolbar.add(new CopyStyledMessageDetailAction(otrosApplication, dateFormat, selectedMessageColorizersContainer, selectedMessageFormattersContainer)); messageDetailToolbar.add(new JLabel("Maximum message size for format")); final DefaultComboBoxModel defaultComboBoxModel = new DefaultComboBoxModel(new String[] {}); String[] values = new String[] { "10kB", "100kB", "200kB", "300kB", "400kB", "500kB", "600kB", "700kB", "800kB", "900kB", "1MB", "2MB", "3MB", "4MB", "5MB" }; for (String value : values) { defaultComboBoxModel.addElement(value); } final JXComboBox messageMaximumSize = new JXComboBox(defaultComboBoxModel); messageMaximumSize.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String max = (String) defaultComboBoxModel.getElementAt(messageMaximumSize.getSelectedIndex()); configuration.setProperty(ConfKeys.MESSAGE_FORMATTER_MAX_SIZE, max); messageDetailListener.setMaximumMessageSize((int) new FileSize(max).getBytes()); } }); messageMaximumSize.setEditable(false); AutoCompleteDecorator.decorate(messageMaximumSize); messageMaximumSize.setMaximumSize(new Dimension(100, 50)); messageDetailToolbar.add(messageMaximumSize); String messageMaxSize = configuration.getString(ConfKeys.MESSAGE_FORMATTER_MAX_SIZE, (String) defaultComboBoxModel.getElementAt(messageMaximumSize.getSelectedIndex())); if (defaultComboBoxModel.getIndexOf(messageMaxSize) >= 0) { messageMaximumSize.setSelectedItem(messageMaxSize); } }
From source file:proyecto4.Principal.java
private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed // TODO add your handling code here: DefaultComboBoxModel modelo = new DefaultComboBoxModel(); for (int i = 0; i < lista_ingredientes.size(); i++) { modelo.addElement(lista_ingredientes.get(i).toString()); }// w w w .j a v a2s . co m cb_elimi_ingre.setModel(modelo); jd_eliminar_ingrediente.setModal(true); jd_eliminar_ingrediente.pack(); jd_eliminar_ingrediente.setVisible(true); }
From source file:proyecto4.Principal.java
private void btn_eliminar_ingreMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btn_eliminar_ingreMouseClicked // TODO add your handling code here: //System.out.println(lista_ingredientes.toString()); try {//from ww w. java 2 s .c o m int elim = cb_elimi_ingre.getSelectedIndex(); lista_ingredientes.remove(elim); cb_elimi_ingre.removeItem(elim); DefaultComboBoxModel modelo = new DefaultComboBoxModel(); for (int i = 0; i < lista_ingredientes.size(); i++) { modelo.addElement(lista_ingredientes.get(i).toString()); } cb_elimi_ingre.setModel(modelo); JOptionPane.showMessageDialog(this, "Ingrediente eliminado"); } catch (Exception e) { JOptionPane.showMessageDialog(this, "Ingrediente no ah sido eliminado"); } //System.out.println(lista_ingredientes.toString()); }
From source file:proyecto4.Principal.java
private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed // TODO add your handling code here: DefaultComboBoxModel modelo = new DefaultComboBoxModel(); for (int i = 0; i < lista_ordenes_espera.size(); i++) { modelo.addElement(lista_ordenes_espera.get(i).getNombre().toString()); }/* ww w .j a va2 s. co m*/ cb_modif_prod.setModel(modelo); jd_modif_productos.setModal(true); jd_modif_productos.pack(); jd_modif_productos.setVisible(true); }
From source file:proyecto4.Principal.java
private void jCheckBoxMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxMenuItem1ActionPerformed // TODO add your handling code here: DefaultComboBoxModel modelo1 = new DefaultComboBoxModel(); for (int i = 0; i < lista_ordenes_espera.size(); i++) { modelo1.addElement(lista_ordenes_espera.get(i).getNombre().toString()); }/*from w ww . j a va2s .co m*/ cb_eliminar_prod.setModel(modelo1); jd_eliminar_prod.setModal(true); jd_eliminar_prod.pack(); jd_eliminar_prod.setVisible(true); }
From source file:proyecto4.Principal.java
private void btn_eliminar_productosMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btn_eliminar_productosMouseClicked // TODO add your handling code here: try {//from www . j a va 2 s. c o m int elim = cb_eliminar_prod.getSelectedIndex(); lista_ordenes_espera.remove(elim); cb_eliminar_prod.removeItem(elim); DefaultComboBoxModel modelo = new DefaultComboBoxModel(); for (int i = 0; i < lista_ordenes_espera.size(); i++) { modelo.addElement(lista_ordenes_espera.get(i).getNombre().toString()); } cb_eliminar_prod.setModel(modelo); JOptionPane.showMessageDialog(this, "Producto ah sido agregado"); } catch (Exception e) { JOptionPane.showMessageDialog(this, "No ah sido eliminado"); } }