List of usage examples for javax.swing DefaultComboBoxModel addElement
public void addElement(E anObject)
From source file:user.Screen.java
private void setCheckBox(String[] items) { DefaultComboBoxModel model = (DefaultComboBoxModel) choiceBox2.getModel(); model.removeAllElements();//from w w w . j av a2 s .c om for (String item : items) { model.addElement(item); } choiceBox2.setModel(model); }
From source file:de.naoth.xabsleditor.graphpanel.AgentVisualizer.java
private void recreateAgentSelector(XABSLContext context) { DefaultComboBoxModel model = new DefaultComboBoxModel(); model.addElement("(all)"); for (String agent : context.getAgentMap().keySet()) { model.addElement(agent);//from www .j a v a2s .c o m } cbAgentSelector.setModel(model); if (lastSelectedAgentName != null) { model.setSelectedItem(lastSelectedAgentName); } }
From source file:com.game.ui.views.CharachterEditorPanel.java
public void doGui() { setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); JLabel noteLbl = new JLabel("Pls select a value to choose an enemy or you can create a new " + "Enemy entity below. Once selected an Enemy character, its' details will be available below"); noteLbl.setAlignmentX(0);//from ww w . j a v a 2s . c o m // noteLbl.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); add(noteLbl); DefaultComboBoxModel model = new DefaultComboBoxModel(); for (GameCharacter character : GameBean.enemyDetails) { System.out.println(character.getName()); model.addElement(character.getName()); } comboBox = new JComboBox(model); comboBox.setSelectedIndex(-1); comboBox.setMaximumSize(new Dimension(100, 30)); comboBox.setAlignmentX(0); comboBox.setActionCommand("dropDown"); comboBox.addActionListener(this); add(Box.createVerticalStrut(10)); add(comboBox); add(Box.createVerticalStrut(10)); JPanel panel1 = new JPanel(); panel1.setAlignmentX(0); panel1.setBorder(LineBorder.createGrayLineBorder()); panel1.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(5, 5, 5, 5); c.weightx = 1; c.weighty = 1; c.gridwidth = 2; JLabel enemyDtlLbl = new JLabel("Enemy Character Details : "); enemyDtlLbl.setFont(new Font("Times New Roman", Font.BOLD, 15)); panel1.add(enemyDtlLbl, c); c.gridwidth = 1; c.gridy = 1; JLabel nameLbl = new JLabel("Name : "); panel1.add(nameLbl, c); c.gridx = 1; JTextField name = new JTextField(""); name.setColumns(20); panel1.add(name, c); c.gridx = 0; c.gridy = 2; JLabel imageLbl = new JLabel("Image Path : "); panel1.add(imageLbl, c); c.gridx = 1; JTextField image = new JTextField(""); image.setColumns(20); panel1.add(image, c); c.gridx = 0; c.gridy = 3; JLabel healthLbl = new JLabel("Health Pts : "); panel1.add(healthLbl, c); c.gridx = 1; JTextField health = new JTextField(""); health.setColumns(20); panel1.add(health, c); c.gridx = 0; c.gridy = 4; JLabel attackPtsLbl = new JLabel("Attack Points : "); panel1.add(attackPtsLbl, c); c.gridx = 1; JTextField attackPts = new JTextField(""); attackPts.setColumns(20); panel1.add(attackPts, c); c.gridx = 0; c.gridy = 5; JLabel armoursPtsLbl = new JLabel("Armour Points : "); panel1.add(armoursPtsLbl, c); c.gridx = 1; JTextField armourPts = new JTextField(""); armourPts.setColumns(20); panel1.add(armourPts, c); c.gridx = 0; c.gridy = 6; JLabel attackRngeLbl = new JLabel("Attack Range : "); panel1.add(attackRngeLbl, c); c.gridx = 1; JTextField attackRnge = new JTextField(""); attackRnge.setColumns(20); panel1.add(attackRnge, c); c.gridx = 0; c.gridy = 7; JLabel movementLbl = new JLabel("Movement : "); panel1.add(movementLbl, c); c.gridx = 1; JTextField movement = new JTextField(""); movement.setColumns(20); panel1.add(movement, c); c.gridx = 0; c.gridy = 8; c.gridwidth = 2; JButton submit = new JButton("Save"); submit.addActionListener(this); submit.setActionCommand("button"); panel1.add(submit, c); add(panel1); c.gridx = 0; c.gridy = 9; JLabel validationMess = new JLabel("Pls enter all the fields or pls choose a character from the drop down"); validationMess.setForeground(Color.red); validationMess.setVisible(false); add(validationMess, c); add(Box.createVerticalGlue()); }
From source file:com.game.ui.views.PlayerEditor.java
public void doGui() { // setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); setLayout(new GridBagLayout()); GridBagConstraints c1 = new GridBagConstraints(); c1.fill = GridBagConstraints.NONE; c1.anchor = GridBagConstraints.WEST; c1.insets = new Insets(10, 5, 10, 5); c1.weightx = 0;//from w ww. j a v a2 s .c o m c1.weighty = 0; JLabel noteLbl = new JLabel("Pls select a value to choose a Player or you can create a new " + "Player entity below. Once selected a Player character, its' details will be available below"); add(noteLbl, c1); DefaultComboBoxModel model = new DefaultComboBoxModel(); for (GameCharacter character : GameBean.playerDetails) { model.addElement(((Player) character).getType()); } c1.gridy = 1; comboBox = new JComboBox(model); comboBox.setSelectedIndex(-1); comboBox.setMaximumSize(new Dimension(100, 30)); comboBox.setActionCommand("dropDown"); comboBox.addActionListener(this); add(comboBox, c1); JPanel wrapperPanel = new JPanel(new GridLayout(1, 2, 10, 10)); wrapperPanel.setBorder(LineBorder.createGrayLineBorder()); leftPanel = new JPanel(); leftPanel.setAlignmentX(0); leftPanel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(5, 5, 5, 5); c.weightx = 1; c.weighty = 1; c.gridwidth = 2; JLabel enemyDtlLbl = new JLabel("Enemy Character Details : "); enemyDtlLbl.setFont(new Font("Times New Roman", Font.BOLD, 15)); leftPanel.add(enemyDtlLbl, c); c.gridwidth = 1; c.gridy = 1; JLabel nameLbl = new JLabel("Name : "); leftPanel.add(nameLbl, c); c.gridx = 1; JTextField name = new JTextField(""); name.setColumns(20); leftPanel.add(name, c); c.gridx = 0; c.gridy = 2; JLabel imageLbl = new JLabel("Image Path : "); leftPanel.add(imageLbl, c); c.gridx = 1; JTextField image = new JTextField(""); image.setColumns(20); leftPanel.add(image, c); c.gridx = 0; c.gridy = 3; JLabel healthLbl = new JLabel("Health Pts : "); leftPanel.add(healthLbl, c); c.gridx = 1; JTextField health = new JTextField(""); health.setColumns(20); leftPanel.add(health, c); c.gridx = 0; c.gridy = 4; JLabel attackPtsLbl = new JLabel("Attack Points : "); leftPanel.add(attackPtsLbl, c); c.gridx = 1; JTextField attackPts = new JTextField(""); attackPts.setColumns(20); leftPanel.add(attackPts, c); c.gridx = 0; c.gridy = 5; JLabel armoursPtsLbl = new JLabel("Armour Points : "); leftPanel.add(armoursPtsLbl, c); c.gridx = 1; JTextField armourPts = new JTextField(""); armourPts.setColumns(20); leftPanel.add(armourPts, c); c.gridx = 0; c.gridy = 6; JLabel attackRngeLbl = new JLabel("Attack Range : "); leftPanel.add(attackRngeLbl, c); c.gridx = 1; JTextField attackRnge = new JTextField(""); attackRnge.setColumns(20); leftPanel.add(attackRnge, c); c.gridx = 0; c.gridy = 7; JLabel movementLbl = new JLabel("Movement : "); leftPanel.add(movementLbl, c); c.gridx = 1; JTextField movement = new JTextField(""); movement.setColumns(20); leftPanel.add(movement, c); c.gridx = 0; c.gridy = 8; JLabel typeLbl = new JLabel("Type : "); leftPanel.add(typeLbl, c); c.gridx = 1; JTextField typeTxt = new JTextField(""); typeTxt.setColumns(20); leftPanel.add(typeTxt, c); c.gridx = 0; c.gridy = 9; JLabel weaponLbl = new JLabel("Equipped Weapon : "); leftPanel.add(weaponLbl, c); c.gridx = 1; DefaultComboBoxModel weapon = new DefaultComboBoxModel(); for (Item item : GameBean.weaponDetails) { if (item instanceof Weapon) { weapon.addElement(((Weapon) item).getName()); } } JComboBox weaponDrpDown = new JComboBox(weapon); weaponDrpDown.setSelectedIndex(-1); weaponDrpDown.setMaximumSize(new Dimension(100, 30)); leftPanel.add(weaponDrpDown, c); c.gridx = 0; c.gridy = 10; c.gridwidth = 2; JButton submit = new JButton("Save"); submit.addActionListener(this); submit.setActionCommand("button"); leftPanel.add(submit, c); wrapperPanel.add(leftPanel); lvlPanel = new LevelPanel(true, null); wrapperPanel.add(lvlPanel); c1.gridy = 2; c1.fill = GridBagConstraints.BOTH; add(wrapperPanel, c1); c1.fill = GridBagConstraints.NONE; validationMess = new JLabel("Pls enter all the fields or pls choose a character from the drop down"); validationMess.setForeground(Color.red); validationMess.setVisible(false); c1.gridy = 3; add(validationMess, c1); c1.weightx = 1; c1.fill = GridBagConstraints.BOTH; c1.weighty = 1; c1.gridy = 4; add(new JPanel(), c1); }
From source file:InterfaceModule.JRobert.java
private ComboBoxModel createParkingMeterList() { Controller c = Controller.getInstance(); DefaultComboBoxModel model = new DefaultComboBoxModel(); Set<String> set = (Set<String>) c.getParkingMeterList(); for (String id : set) model.addElement(id); return model; }
From source file:co.com.soinsoftware.hotelero.view.JFRoomDetail.java
private void setCompanyModel(final List<Company> companyList) { final DefaultComboBoxModel<String> model = new DefaultComboBoxModel<String>(); model.addElement("Ninguna"); for (final Company company : companyList) { model.addElement(company.getName()); }//from w w w .j a v a 2 s .c o m this.jcbCompany.setModel(model); }
From source file:com.qualixium.executor.ToolbarPanel.java
public void initializeCbxCommands() { DefaultComboBoxModel<Command> modelCommands = new DefaultComboBoxModel<>(); String jsonCustomCommands = NbPreferences.forModule(CommandsConfigurationDialog.class).get(CUSTOM_COMMANDS, "");//from w w w. j a v a2 s . com if (!jsonCustomCommands.isEmpty()) { try { JsonNode jsonData = MAPPER.readTree(jsonCustomCommands); for (JsonNode node : jsonData) { modelCommands.addElement( new Command(node.get(COLUMN_NAME).textValue(), node.get(COLUMN_COMMAND).textValue())); } } catch (IOException ex) { Exceptions.printStackTrace(ex); } } cbxCommands.setModel(modelCommands); cbxCommands.addPopupMenuListener(popupMenuListener); cbxCommands.setPrototypeDisplayValue("scrot -cd 5 /home/pedro/Desktop/file1.png"); }
From source file:gtu._work.ui.ObnfExceptionLogDownloadUI.java
private void initGUI() { try {//w w w . ja v a 2s . com JCommonUtil.frameCloseConfirm(this); BorderLayout thisLayout = new BorderLayout(); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); getContentPane().setLayout(thisLayout); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); { jPanel1 = new JPanel(); FlowLayout jPanel1Layout = new FlowLayout(); jTabbedPane1.addTab("", null, jPanel1, null); jPanel1.setLayout(jPanel1Layout); { jLabel1 = new JLabel(); jPanel1.add(jLabel1); jLabel1.setText("\u532f\u51fa\u76ee\u9304"); } { exportTextField = new JTextField(); JCommonUtil.jTextFieldSetFilePathMouseEvent(exportTextField, true); jPanel1.add(exportTextField); exportTextField.setPreferredSize(new java.awt.Dimension(187, 22)); } { jLabel2 = new JLabel(); jPanel1.add(jLabel2); jLabel2.setText("domainJar"); jLabel2.setPreferredSize(new java.awt.Dimension(56, 15)); } { domainJarText = new JTextField(); ObnfRepairDBBatch batch = new ObnfRepairDBBatch(); domainJarText.setText(batch.fetchDomainJar()); JCommonUtil.jTextFieldSetFilePathMouseEvent(domainJarText, false); jPanel1.add(domainJarText); domainJarText.setPreferredSize(new java.awt.Dimension(185, 22)); } { jScrollPane1 = new JScrollPane(); jPanel1.add(jScrollPane1); jScrollPane1.setPreferredSize(new java.awt.Dimension(512, 262)); { messageIdArea = new JTextArea(); jScrollPane1.setViewportView(messageIdArea); } } { DefaultComboBoxModel jComboBox1Model = new DefaultComboBoxModel(); for (FtpSite f : FtpSite.values()) { jComboBox1Model.addElement(f); } siteFtpComboBox = new JComboBox(); jPanel1.add(siteFtpComboBox); siteFtpComboBox.setModel(jComboBox1Model); } { downloadBtn = new JButton(); jPanel1.add(downloadBtn); downloadBtn.setText("\u4e0b\u8f09"); downloadBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { downloadBtnAction(); } }); } { makeReportBtn = new JButton(); jPanel1.add(makeReportBtn); makeReportBtn.setText("\u7522\u751f\u5831\u8868"); makeReportBtn.setPreferredSize(new java.awt.Dimension(102, 22)); makeReportBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { makeReportBtnPerformed(); } }); } } { jPanel2 = new JPanel(); BorderLayout jPanel2Layout = new BorderLayout(); jPanel2.setLayout(jPanel2Layout); jTabbedPane1.addTab("log", null, jPanel2, null); { jScrollPane2 = new JScrollPane(); jPanel2.add(jScrollPane2, BorderLayout.CENTER); jScrollPane2.setPreferredSize(new java.awt.Dimension(529, 340)); { logArea = new JTextArea(); jScrollPane2.setViewportView(logArea); } } } } pack(); this.setSize(542, 394); } catch (Exception e) { //add your error handling code here e.printStackTrace(); } }
From source file:com.github.alexfalappa.nbspringboot.projects.initializr.InitializrProjectPanelVisual1.java
private void fillCombo(JsonNode attrNode, DefaultComboBoxModel<NamedItem> comboModel, JComboBox combo) { JsonNode valArray = attrNode.path("values"); comboModel.removeAllElements();//from w ww. ja v a 2s .co m for (JsonNode val : valArray) { comboModel.addElement(new NamedItem(val.get("id").asText(), val.get("name").asText())); } combo.setModel(comboModel); combo.setSelectedItem(new NamedItem(attrNode.path("default").asText(), "")); }
From source file:de.tor.tribes.ui.views.DSWorkbenchDistanceFrame.java
public void resetView(boolean pClear) { if (pClear) { DistanceManager.getSingleton().clear(); }//from w w w . ja va 2 s . c o m jDistanceTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); int w0 = 200; for (int i = 0; i < jDistanceTable.getColumnCount(); i++) { TableColumnExt column = jDistanceTable.getColumnExt(i); if (i == 0) { column.setWidth(w0); column.setPreferredWidth(w0); column.setMaxWidth(w0); column.setMinWidth(w0); column.setResizable(false); } else { String v = (String) column.getHeaderValue(); int w = getGraphics().getFontMetrics().stringWidth(v); column.setWidth(w); column.setPreferredWidth(w); } } jDistanceTable.getTableHeader().setDefaultRenderer(new DefaultTableHeaderRenderer()); if (pClear) { ((DistanceTableModel) jDistanceTable.getModel()).fireTableStructureChanged(); } else { ((DistanceTableModel) jDistanceTable.getModel()).fireTableDataChanged(); } DefaultComboBoxModel model = new DefaultComboBoxModel(); model.addElement(UnknownUnit.getSingleton()); for (UnitHolder unit : DataHolder.getSingleton().getUnits()) { model.addElement(unit); } unitBox.setModel(model); }