List of usage examples for javax.swing DefaultComboBoxModel DefaultComboBoxModel
public DefaultComboBoxModel(Vector<E> v)
From source file:br.com.utfpr.pb.view.RelatorioPedidosView.java
/** * Creates new form UsuariosView//from ww w .ja v a2 s .co m */ public RelatorioPedidosView() { try { pessoaController = PessoaController.getInstance(); initComponents(); pessoa.setModel(new DefaultComboBoxModel(pessoaController.findAll().toArray())); Dimension desktopSize = PrincipalView.jDesktopPane.getSize(); Dimension jInternalFrameSize = getSize(); setLocation((desktopSize.width - jInternalFrameSize.width) / 2, (desktopSize.height - jInternalFrameSize.height) / 2); PrincipalView.jDesktopPane.add(this); setVisible(true); moveToFront(); setSelected(true); } catch (Exception e) { e.printStackTrace(); } }
From source file:br.com.utfpr.pb.view.RelatorioContasView.java
/** * Creates new form UsuariosView//from ww w .j a v a2 s .c om */ public RelatorioContasView() { try { pessoaController = PessoaController.getInstance(); initComponents(); pessoa.setModel(new DefaultComboBoxModel(pessoaController.findAll().toArray())); Dimension desktopSize = PrincipalView.jDesktopPane.getSize(); Dimension jInternalFrameSize = getSize(); setLocation((desktopSize.width - jInternalFrameSize.width) / 2, (desktopSize.height - jInternalFrameSize.height) / 2); PrincipalView.jDesktopPane.add(this); setVisible(true); moveToFront(); setSelected(true); } catch (Exception e) { e.printStackTrace(); } }
From source file:net.landora.video.utils.UIUtils.java
public static ComboBoxModel generateComboModel(Object[] values) { DefaultComboBoxModel model = new DefaultComboBoxModel(values); return model; }
From source file:Interfaz.adminZone.java
public adminZone() { String[] columna = new String[] { "Nombre", "Dinero Gastado", "Tipo de Cliente" }; String[] ventasM = new String[] { "Mes", "Venta Total" }; this.modeloEmp = new DefaultComboBoxModel(new String[] {}); this.modeloCliDes = new DefaultTableModel(null, columna); this.modeloVentasMes = new DefaultTableModel(null, ventasM); initComponents();/* ww w. j a v a2s .c o m*/ this.setLocationRelativeTo(null); ponerImagen(); llenar(); this.graficar(); }
From source file:eu.ggnet.dwoss.report.CreateViewCask.java
public CreateViewCask() { initComponents();//from w w w . j a va 2 s .com contractorComboBox.setModel( new DefaultComboBoxModel(Client.lookup(MandatorSupporter.class).loadContractors().all().toArray())); contractorComboBox.setRenderer(new NamedEnumCellRenderer()); viewModeComboBox.setModel(new DefaultComboBoxModel(Report.ViewMode.values())); }
From source file:com.bryan.gui.HotelBrokerApp.java
@Override public void actionPerformed(ActionEvent event) { if (event.getSource() == gui.getSearchCityButton()) { gui.getAvailableHotelLabel().setText("Available Hotel"); gui.getChooseHotelComboBox().setEnabled(true); DefaultComboBoxModel model = new DefaultComboBoxModel( DBUtil.getHotelByCity(gui.getChooseCityComboBox().getSelectedItem().toString()).toArray()); gui.getChooseHotelComboBox().setModel(model); gui.getSearchHotelButton().setEnabled(true); } else if (event.getSource() == gui.getSearchHotelButton()) { gui.getCheckingPanel().setVisible(true); gui.getMakeBookingButton().setEnabled(false); // create hotel client and connect to related hotel server; if (hotelClient != null) { hotelClient.closeClientSocket(); hotelClient = null;//from w ww . j a v a 2 s. c o m } hotelClient = new HotelClient("hotel client"); String city = gui.getChooseCityComboBox().getSelectedItem().toString(); String hotelName = gui.getChooseHotelComboBox().getSelectedItem().toString().split(" ")[0]; selectedHotel = DBUtil.getHotelByCityAndName(city, hotelName); hotelClient.runClient(selectedHotel); //hotelClient.sendMessageToServerAndGetReturn(gui.getChooseHotelComboBox().getSelectedItem().toString()); } else if (event.getSource() == gui.getCheckAvailabilityButton()) { Date checkIn = null; try { checkIn = formatter.parse(gui.getCheckInDateText().getText()); if (checkIn.getTime() < formatter.parse(formatter.format(new Date())).getTime()) { gui.displayMessageInDialog( "Check-In date should not before today: " + formatter.format(new Date())); return; } } catch (Exception e) { gui.displayMessageInDialog("Check-In date format incorrect: Should be like '2015-03-30'"); return; } int numOfNights; try { numOfNights = Integer.parseInt(gui.getNumberOfNightsText().getText()); if (numOfNights <= 0) { gui.displayMessageInDialog("Number of Nights should be positive integer"); return; } } catch (Exception e) { gui.displayMessageInDialog("Number of Nights should be positive integer"); return; } int numOfRooms; try { numOfRooms = Integer.parseInt(gui.getNumberOfRoomsText().getText()); if (numOfRooms <= 0) { gui.displayMessageInDialog("Number of Rooms should be positive integer"); return; } } catch (Exception e) { gui.displayMessageInDialog("Number of Rooms should be positive integer"); return; } String city = gui.getChooseCityComboBox().getSelectedItem().toString(); String hotelName = gui.getChooseHotelComboBox().getSelectedItem().toString().split(" ")[0]; JSONObject sendData = new JSONObject(); sendData.put("city", city); sendData.put("hotelName", hotelName); String result = hotelClient.sendMessageToServerAndGetReturn( CommProtocol.GETHOTEL.getProtocol() + "-" + sendData.toString()); String[] resultArr = result.split("-", 2); if (!resultArr[0].equals(CommProtocol.SUCCESS.getProtocol())) { gui.displayMessageInDialog("Data processing occurs error in server side, please try later"); return; } JSONObject receivedData = new JSONObject(resultArr[1]); Hotel hotel = new Hotel(receivedData.getInt(("id")), receivedData.getString("city"), receivedData.getString("name"), receivedData.getInt("port"), receivedData.getDouble("price")); sendData = new JSONObject(); sendData.put("hotelId", hotel.getId()); sendData.put("checkIn", formatter.format(checkIn)); sendData.put("numOfNights", numOfNights); sendData.put("numOfRooms", numOfRooms); result = hotelClient.sendMessageToServerAndGetReturn( CommProtocol.CHECKING_AVAILABILITY.getProtocol() + "-" + sendData.toString()); resultArr = result.split("-", 2); if (!resultArr[0].equals(CommProtocol.SUCCESS.getProtocol())) { gui.displayMessageInDialog("Data processing occurs error in server side, please try later"); return; } receivedData = new JSONObject(resultArr[1]); if (!receivedData.getBoolean("roomAvailability")) { gui.displayMessageInDialog( "Sorry, requested rooms is/are NOT available, please change your booking condition"); return; } else { gui.displayMessageInDialog("Requested Rooms is/are available"); gui.getMakeBookingButton().setEnabled(true); } } else if (event.getSource() == gui.getMakeBookingButton()) { gui.getBookingPanel().setVisible(true); } else if (event.getSource() == gui.getConfirmBookingButton()) { String checkIn = gui.getCheckInDateText().getText(); int numOfNights = Integer.parseInt(gui.getNumberOfNightsText().getText()); int numOfRooms = Integer.parseInt(gui.getNumberOfRoomsText().getText()); String firstName = gui.getFirstNameText().getText(); if (!firstName.matches("^[A-Za-z]+$")) { gui.displayMessageInDialog("First name can only contain alphabetic letter"); return; } String lastName = gui.getLastNameText().getText(); if (!lastName.matches("^[A-Za-z]+$")) { gui.displayMessageInDialog("Last name can only contain alphabetic letter"); return; } String state = gui.getStateComboBox().getSelectedItem().toString(); String streetAddress = gui.getStreetAddressText().getText(); String suburb = gui.getSuburbText().getText(); int postCode = Integer.parseInt(gui.getPostCodeText().getText()); if (postCode < 1000 || postCode > 9999) { gui.displayMessageInDialog("Post code must be 4 digit number"); return; } String email = gui.getEmailText().getText(); if (!email.matches("^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,6}$")) { gui.displayMessageInDialog("Email format incorrect, should be like example@gmail.com"); return; } String phoneNumber = gui.getPhoneNumberText().getText(); String creditCard = gui.getCreditCardText().getText(); if (!creditCard.matches("\\d{16}")) { gui.displayMessageInDialog("Credit card format incorrect, should be 16 digit number"); return; } JSONObject sendData = new JSONObject(); sendData.put("hotelId", selectedHotel.getId()); sendData.put("checkIn", checkIn); sendData.put("numOfNights", numOfNights); sendData.put("numOfRooms", numOfRooms); sendData.put("firstName", firstName); sendData.put("lastName", lastName); sendData.put("state", state); sendData.put("address", streetAddress); sendData.put("suburb", suburb); sendData.put("postCode", postCode); sendData.put("email", email); sendData.put("phone", phoneNumber); sendData.put("creditCard", creditCard); String result = hotelClient.sendMessageToServerAndGetReturn( CommProtocol.BOOKING.getProtocol() + "-" + sendData.toString()); String[] resultArr = result.split("-", 2); if (!resultArr[0].equals(CommProtocol.SUCCESS.getProtocol())) { gui.displayMessageInDialog("Data processing occurs error in server side, please try later"); return; } JSONObject receivedData = new JSONObject(resultArr[1]); if (!receivedData.getBoolean("bookingStatus")) { gui.displayMessageInDialog("Sorry, booking has been failed! Room just been booked"); return; } else { gui.displayMessageInDialog("Congratulations! Booking successed!"); return; } } else if (event.getSource() == gui.getStartAgainButton()) { String result = hotelClient.sendMessageToServerAndGetReturn( CommProtocol.CONNECTION_INTERRUPT.getProtocol() + "-Connection interrupt"); System.out.println("=========start again:" + result); hotelClient.closeClientSocket(); hotelClient = null; gui.initChoosePanel(); gui.hideCheckingPanelAndCleanFields(); gui.hideBookingPanelAndCleanFields(); } }
From source file:com.facebook.plugin.ui.AccountKitInstallActivityForm.java
@Override public void fillForm() { activitySelector .setModel(new DefaultComboBoxModel<>(AccountKitActivityConfigurator.getActivityClasses(project))); }
From source file:com.emr.schemas.ForeignDataMover.java
/** * Form for moving foreign data//from w w w .j a v a 2 s .c om * @param emrConn Connection to the emr database * @param mpiConn Connection to the mpi database * @param sourceColumn The column that has the foreign key */ public ForeignDataMover(final Connection emrConn, final Connection mpiConn, String sourceColumn) { this.emrConn = emrConn; this.mpiConn = mpiConn; this.sourceColumn = sourceColumn; sourceTables = getDatabaseTables(emrConn); sourceTablesModel = new DefaultComboBoxModel(sourceTables.toArray(new String[sourceTables.size()])); destTables = getDatabaseTables(mpiConn); destTablesModel = new DefaultComboBoxModel(destTables.toArray(new String[destTables.size()])); initComponents(); txtSelectedCollumn.setText("<html><b color='green'>" + sourceColumn + "</b></html>"); cmbForeignTables.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { String selectedTable = (String) e.getItem(); //populate primary table columns List primaryColumns = getTableColumns(selectedTable, emrConn); sourcePrimaryFields = new DefaultComboBoxModel( primaryColumns.toArray(new String[primaryColumns.size()])); cmbPrimaryKey.setModel(sourcePrimaryFields); sourceUniqueFields = new DefaultComboBoxModel( primaryColumns.toArray(new String[primaryColumns.size()])); cmbUniquekey.setModel(sourceUniqueFields); } } }); cmbMPITables.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { String selectedTable = (String) e.getItem(); //populate primary table columns List columns = getTableColumns(selectedTable, mpiConn); mpiPrimarycolumns = new DefaultComboBoxModel(columns.toArray(new String[columns.size()])); cmbMPIPrimaryKey.setModel(mpiPrimarycolumns); mpiUniquFields = new DefaultComboBoxModel(columns.toArray(new String[columns.size()])); cmbMPIUniqueField.setModel(mpiUniquFields); } } }); }
From source file:org.jdal.swing.action.ComboLinker.java
/** * {@inheritDoc}// w ww .j a va2 s . c o m * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ @SuppressWarnings("unchecked") public void actionPerformed(ActionEvent e) { Object selected = primary.getSelectedItem(); if (selected != null) { BeanWrapper wrapper = PropertyAccessorFactory.forBeanPropertyAccess(selected); Collection<Object> collection = (Collection<Object>) wrapper.getPropertyValue(propertyName); DefaultComboBoxModel model = new DefaultComboBoxModel(new Vector<Object>(collection)); dependent.setModel(model); } }
From source file:com.facebook.plugin.ui.AccountKitInstallDependenciesForm.java
@Override public void fillForm() { moduleSelector.setModel( new DefaultComboBoxModel<>(AccountKitModuleConfigurator.getModuleAvailabilities(project))); }