List of usage examples for java.awt.event ItemListener ItemListener
ItemListener
From source file:org.codinjutsu.tools.nosql.mongo.runner.MongoRunConfigurationEditor.java
public MongoRunConfigurationEditor(Project project) { mongoShellOptionsPanel.setBorder(IdeBorderFactory.createTitledBorder("Mongo shell options", true)); shellParametersField.setDialogCaption("Mongo arguments"); DatabaseServer[] mongoServers = getAvailableMongoServers(project); if (mongoServers.length == 0) { serverConfigurationCombobox.setEnabled(false); databaseCombobox.setEnabled(false); return;//from w w w. ja va 2s . co m } serverConfigurationCombobox.setModel(new DefaultComboBoxModel(mongoServers)); serverConfigurationCombobox.setRenderer(new ColoredListCellRenderer() { @Override protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) { DatabaseServer serverConfiguration = (DatabaseServer) value; append(serverConfiguration.getLabel()); } }); databaseCombobox.setRenderer(new ColoredListCellRenderer() { @Override protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) { SingleMongoDatabase singleMongoDatabase = (SingleMongoDatabase) value; if (value == null) { return; } append(singleMongoDatabase.getName()); } }); serverConfigurationCombobox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent itemEvent) { DatabaseServer selectedServer = (DatabaseServer) serverConfigurationCombobox.getSelectedItem(); if (selectedServer == null) { return; } databaseCombobox.removeAllItems(); for (Database mongoDatabase : selectedServer.getDatabases()) { databaseCombobox.addItem(mongoDatabase); } } }); serverConfigurationCombobox.setSelectedIndex(-1); serverConfigurationCombobox.setSelectedIndex(0); }
From source file:org.mbs3.juniuploader.gui.pnlFormVariables.java
private void initGUI() { try {// w ww .ja v a2 s . co m GridBagLayout thisLayout = new GridBagLayout(); this.setLayout(thisLayout); { btnAddPair = new JButton(); this.add(btnAddPair, new GridBagConstraints(3, 3, 3, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); btnAddPair.setText("Add a New Pair"); btnAddPair.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { btnAddPairActionPerformed(evt); } }); } { btnRemPair = new JButton(); this.add(btnRemPair, new GridBagConstraints(3, 6, 3, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); btnRemPair.setText("Remove Selected Pair"); btnRemPair.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { btnRemPairActionPerformed(evt); } }); } { cmbFormGroups = new JComboBox(); this.add(cmbFormGroups, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); cmbFormGroups.setModel(frmMain.formGroups); cmbFormGroups.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent evt) { cmbFormGroupsItemStateChanged(evt); } }); } { DefaultComboBoxModel groups = frmMain.formGroups; FormPairGroup fpg = (FormPairGroup) groups.getSelectedItem(); DefaultComboBoxModel dcbmFormPairs; if (fpg != null) dcbmFormPairs = new DefaultComboBoxModel(fpg.getPairs()); else dcbmFormPairs = new DefaultComboBoxModel(); lstFormPairValues = new JList(); lstFormPairValues.setModel(dcbmFormPairs); this.add(lstFormPairValues, new GridBagConstraints(1, 3, 1, 4, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); lstFormPairValues.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED)); } { btnAddGroup = new JButton(); this.add(btnAddGroup, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); btnAddGroup.setText("Add a Group"); btnAddGroup.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { btnAddGroupActionPerformed(evt); } }); } { btnRemSelGrp = new JButton(); this.add(btnRemSelGrp, new GridBagConstraints(5, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); btnRemSelGrp.setText("Remove This Group"); btnRemSelGrp.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { btnRemSelGrpActionPerformed(evt); } }); } { btnEditPair = new JButton(); this.add(btnEditPair, new GridBagConstraints(3, 4, 3, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); btnEditPair.setText("Edit This Pair"); btnEditPair.setEnabled(false); } thisLayout.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.1, 0.1, 0.0, 0.1, 0.0 }; thisLayout.rowHeights = new int[] { 8, 24, 9, 20, 7, 8, 7, 9 }; thisLayout.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; thisLayout.columnWidths = new int[] { 11, 335, 9, 97, 10, 119, 10 }; this.setPreferredSize(new java.awt.Dimension(614, 382)); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.litt.core.security.license.gui.ConfigPanel.java
/** * Create the panel.//from w w w . j av a 2s . c om */ public ConfigPanel(final Gui gui) { GridBagLayout gbl_configPanel = new GridBagLayout(); gbl_configPanel.columnWidths = new int[] { 0, 0, 0, 0 }; gbl_configPanel.rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; gbl_configPanel.columnWeights = new double[] { 0.0, 1.0, 0.0, Double.MIN_VALUE }; gbl_configPanel.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE }; this.setLayout(gbl_configPanel); JLabel label_18 = new JLabel("?"); GridBagConstraints gbc_label_18 = new GridBagConstraints(); gbc_label_18.insets = new Insets(0, 0, 5, 5); gbc_label_18.anchor = GridBagConstraints.EAST; gbc_label_18.gridx = 0; gbc_label_18.gridy = 0; this.add(label_18, gbc_label_18); comboBox_config = new JComboBox(); comboBox_config.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { try { LicenseConfig licenseConfig = (LicenseConfig) e.getItem(); File licenseFile = new File(licenseConfig.getLicenseFilePath()); currentLicenseConfig = licenseConfig; loadLicense(licenseFile); gui.setCurrentLicenseConfig(currentLicenseConfig); } catch (Exception e1) { JOptionPane.showMessageDialog(self, e1.getMessage()); } } } }); GridBagConstraints gbc_comboBox_config = new GridBagConstraints(); gbc_comboBox_config.insets = new Insets(0, 0, 5, 5); gbc_comboBox_config.fill = GridBagConstraints.HORIZONTAL; gbc_comboBox_config.gridx = 1; gbc_comboBox_config.gridy = 0; this.add(comboBox_config, gbc_comboBox_config); JButton button_3 = new JButton("?"); button_3.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { try { comboBox_config.removeAllItems(); File configFile = new File(Gui.HOME_PATH + File.separator + "config.xml"); Document document = XmlUtils.readXml(configFile); Element rootE = document.getRootElement(); List productList = rootE.elements(); for (int i = 0; i < productList.size(); i++) { Element productE = (Element) productList.get(i); String productCode = productE.attributeValue("code"); List customerList = productE.elements(); for (int j = 0; j < customerList.size(); j++) { Element customerE = (Element) customerList.get(j); String customerCode = customerE.attributeValue("code"); LicenseConfig licenseConfig = new LicenseConfig(); licenseConfig.setProductCode(productCode); licenseConfig.setCustomerCode(customerCode); licenseConfig.setLicenseId(customerE.elementText("licenseId")); licenseConfig.setEncryptedLicense(customerE.elementText("encryptedLicense")); licenseConfig.setRootFilePath(Gui.HOME_PATH); licenseConfig.setLicenseFilePath(Gui.HOME_PATH + File.separator + productCode + File.separator + customerCode + File.separator + "license.xml"); licenseConfig.setPriKeyFilePath( Gui.HOME_PATH + File.separator + productCode + File.separator + "private.key"); licenseConfig.setPubKeyFilePath( Gui.HOME_PATH + File.separator + productCode + File.separator + "license.key"); comboBox_config.addItem(licenseConfig); if (i == 0 && j == 0) { File licenseFile = new File(licenseConfig.getLicenseFilePath()); currentLicenseConfig = licenseConfig; loadLicense(licenseFile); gui.setCurrentLicenseConfig(currentLicenseConfig); btnDelete.setEnabled(true); } } } } catch (Exception e1) { e1.printStackTrace(); JOptionPane.showMessageDialog(self, e1.getMessage()); } } }); btnDelete = new JButton(); btnDelete.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (currentLicenseConfig != null) { try { String productCode = currentLicenseConfig.getProductCode(); String customerCode = currentLicenseConfig.getCustomerCode(); //congfig.xml File configFile = new File(Gui.HOME_PATH + File.separator + "config.xml"); Document document = XmlUtils.readXml(configFile); Element customerNode = (Element) document.selectSingleNode( "//product[@code='" + productCode + "']/customer[@code='" + customerCode + "']"); if (customerNode != null) { customerNode.detach(); XmlUtils.writeXml(configFile, document); } // File licensePathFile = new File(currentLicenseConfig.getLicenseFilePath()); if (licensePathFile.exists()) { FileUtils.deleteDirectory(licensePathFile.getParentFile()); } //comboboxitem comboBox_config.removeItemAt(comboBox_config.getSelectedIndex()); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } if (comboBox_config.getItemCount() <= 0) { btnDelete.setEnabled(false); } } } }); btnDelete.setEnabled(false); btnDelete.setIcon(new ImageIcon(ConfigPanel.class.getResource("/images/icon_delete.png"))); GridBagConstraints gbc_btnDelete = new GridBagConstraints(); gbc_btnDelete.insets = new Insets(0, 0, 5, 0); gbc_btnDelete.gridx = 2; gbc_btnDelete.gridy = 0; add(btnDelete, gbc_btnDelete); GridBagConstraints gbc_button_3 = new GridBagConstraints(); gbc_button_3.insets = new Insets(0, 0, 5, 5); gbc_button_3.gridx = 1; gbc_button_3.gridy = 1; this.add(button_3, gbc_button_3); JLabel lblid = new JLabel("?ID"); GridBagConstraints gbc_lblid = new GridBagConstraints(); gbc_lblid.anchor = GridBagConstraints.EAST; gbc_lblid.insets = new Insets(0, 0, 5, 5); gbc_lblid.gridx = 0; gbc_lblid.gridy = 2; this.add(lblid, gbc_lblid); textField_licenseId = new JTextField(); GridBagConstraints gbc_textField_licenseId = new GridBagConstraints(); gbc_textField_licenseId.insets = new Insets(0, 0, 5, 5); gbc_textField_licenseId.fill = GridBagConstraints.HORIZONTAL; gbc_textField_licenseId.gridx = 1; gbc_textField_licenseId.gridy = 2; this.add(textField_licenseId, gbc_textField_licenseId); textField_licenseId.setColumns(10); JLabel label = new JLabel("?"); GridBagConstraints gbc_label = new GridBagConstraints(); gbc_label.anchor = GridBagConstraints.EAST; gbc_label.insets = new Insets(0, 0, 5, 5); gbc_label.gridx = 0; gbc_label.gridy = 3; add(label, gbc_label); comboBox_licenseType = new JComboBox(MapComboBoxModel.getLicenseTypeOptions().toArray()); GridBagConstraints gbc_comboBox_licenseType = new GridBagConstraints(); gbc_comboBox_licenseType.insets = new Insets(0, 0, 5, 5); gbc_comboBox_licenseType.fill = GridBagConstraints.HORIZONTAL; gbc_comboBox_licenseType.gridx = 1; gbc_comboBox_licenseType.gridy = 3; add(comboBox_licenseType, gbc_comboBox_licenseType); JLabel label_23 = new JLabel("???"); GridBagConstraints gbc_label_23 = new GridBagConstraints(); gbc_label_23.anchor = GridBagConstraints.EAST; gbc_label_23.insets = new Insets(0, 0, 5, 5); gbc_label_23.gridx = 0; gbc_label_23.gridy = 4; this.add(label_23, gbc_label_23); textField_productName = new JTextField(); GridBagConstraints gbc_textField_productName = new GridBagConstraints(); gbc_textField_productName.insets = new Insets(0, 0, 5, 5); gbc_textField_productName.fill = GridBagConstraints.HORIZONTAL; gbc_textField_productName.gridx = 1; gbc_textField_productName.gridy = 4; this.add(textField_productName, gbc_textField_productName); textField_productName.setColumns(10); JLabel label_24 = new JLabel("???"); GridBagConstraints gbc_label_24 = new GridBagConstraints(); gbc_label_24.anchor = GridBagConstraints.EAST; gbc_label_24.insets = new Insets(0, 0, 5, 5); gbc_label_24.gridx = 0; gbc_label_24.gridy = 5; this.add(label_24, gbc_label_24); textField_companyName = new JTextField(); GridBagConstraints gbc_textField_companyName = new GridBagConstraints(); gbc_textField_companyName.insets = new Insets(0, 0, 5, 5); gbc_textField_companyName.fill = GridBagConstraints.HORIZONTAL; gbc_textField_companyName.gridx = 1; gbc_textField_companyName.gridy = 5; this.add(textField_companyName, gbc_textField_companyName); textField_companyName.setColumns(10); JLabel label_25 = new JLabel("??"); GridBagConstraints gbc_label_25 = new GridBagConstraints(); gbc_label_25.anchor = GridBagConstraints.EAST; gbc_label_25.insets = new Insets(0, 0, 5, 5); gbc_label_25.gridx = 0; gbc_label_25.gridy = 6; this.add(label_25, gbc_label_25); textField_customerName = new JTextField(); GridBagConstraints gbc_textField_customerName = new GridBagConstraints(); gbc_textField_customerName.insets = new Insets(0, 0, 5, 5); gbc_textField_customerName.fill = GridBagConstraints.HORIZONTAL; gbc_textField_customerName.gridx = 1; gbc_textField_customerName.gridy = 6; this.add(textField_customerName, gbc_textField_customerName); textField_customerName.setColumns(10); JLabel label_26 = new JLabel(""); GridBagConstraints gbc_label_26 = new GridBagConstraints(); gbc_label_26.anchor = GridBagConstraints.EAST; gbc_label_26.insets = new Insets(0, 0, 5, 5); gbc_label_26.gridx = 0; gbc_label_26.gridy = 7; this.add(label_26, gbc_label_26); textField_version = new JTextField(); GridBagConstraints gbc_textField_version = new GridBagConstraints(); gbc_textField_version.insets = new Insets(0, 0, 5, 5); gbc_textField_version.fill = GridBagConstraints.HORIZONTAL; gbc_textField_version.gridx = 1; gbc_textField_version.gridy = 7; this.add(textField_version, gbc_textField_version); textField_version.setColumns(10); JLabel label_27 = new JLabel(""); GridBagConstraints gbc_label_27 = new GridBagConstraints(); gbc_label_27.insets = new Insets(0, 0, 5, 5); gbc_label_27.gridx = 0; gbc_label_27.gridy = 8; this.add(label_27, gbc_label_27); datePicker_expiredDate = new DatePicker(new Date(), "yyyy-MM-dd", null, null); //datePicker_expiredDate.setTimePanleVisible(false); GridBagConstraints gbc_datePicker_expiredDate = new GridBagConstraints(); gbc_datePicker_expiredDate.anchor = GridBagConstraints.WEST; gbc_datePicker_expiredDate.insets = new Insets(0, 0, 5, 5); gbc_datePicker_expiredDate.gridx = 1; gbc_datePicker_expiredDate.gridy = 8; this.add(datePicker_expiredDate, gbc_datePicker_expiredDate); JButton button_5 = new JButton(""); button_5.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (currentLicenseConfig != null) { try { File priKeyFile = new File(currentLicenseConfig.getPriKeyFilePath()); File licenseFile = new File(currentLicenseConfig.getLicenseFilePath()); //?? License license = new License(); license.setLicenseId(textField_licenseId.getText()); license.setLicenseType( ((MapComboBoxModel) comboBox_licenseType.getSelectedItem()).getValue().toString()); license.setProductName(textField_productName.getText()); license.setCompanyName(textField_companyName.getText()); license.setCustomerName(textField_customerName.getText()); license.setVersion(Version.parseVersion(textField_version.getText())); license.setCreateDate(new Date()); license.setExpiredDate(Utility.parseDate(datePicker_expiredDate.getText())); //???? DigitalSignatureTool utils = new DigitalSignatureTool("DSA"); utils.readPriKey(priKeyFile.getAbsolutePath()); //?? String signedData = utils.sign(license.toString()); //?????? license.setSignature(signedData); LicenseManager.writeLicense(license, licenseFile); //config.xml String licenseContent = XmlUtils.readXml(licenseFile).asXML(); //DES ISecurity security = new DESTool(currentLicenseConfig.getLicenseId(), Algorithm.BLOWFISH); licenseContent = security.encrypt(licenseContent); txt_encryptContent.setText(licenseContent); currentLicenseConfig.setEncryptedLicense(licenseContent); System.out.println(licenseContent); File configFile = new File(Gui.HOME_PATH + File.separator + "config.xml"); XMLConfiguration config = new XMLConfiguration(configFile); config.setAutoSave(true); config.setProperty("product.customer.encryptedLicense", licenseContent); //??zip? File customerPath = licenseFile.getParentFile(); //???license????? File licensePath = new File(customerPath.getParent(), "license"); if (!licensePath.exists() && !licensePath.isDirectory()) { licensePath.mkdir(); } else { FileUtils.cleanDirectory(licensePath); } //? FileUtils.copyDirectory(customerPath, licensePath); String currentTime = FormatDateTime.formatDateTimeNum(new Date()); ZipUtils.zip(licensePath, new File(licensePath.getParentFile(), currentLicenseConfig.getCustomerCode() + "-" + currentTime + ".zip")); //license FileUtils.deleteDirectory(licensePath); JOptionPane.showMessageDialog(self, "??"); } catch (Exception e1) { e1.printStackTrace(); JOptionPane.showMessageDialog(self, e1.getMessage()); } } else { JOptionPane.showMessageDialog(self, "???"); } } }); GridBagConstraints gbc_button_5 = new GridBagConstraints(); gbc_button_5.insets = new Insets(0, 0, 5, 5); gbc_button_5.gridx = 1; gbc_button_5.gridy = 9; this.add(button_5, gbc_button_5); JScrollPane scrollPane = new JScrollPane(); GridBagConstraints gbc_scrollPane = new GridBagConstraints(); gbc_scrollPane.insets = new Insets(0, 0, 0, 5); gbc_scrollPane.fill = GridBagConstraints.BOTH; gbc_scrollPane.gridx = 1; gbc_scrollPane.gridy = 10; this.add(scrollPane, gbc_scrollPane); txt_encryptContent = new JTextArea(); txt_encryptContent.setLineWrap(true); scrollPane.setViewportView(txt_encryptContent); // txt_encryptContent = new JTextArea(20, 20); // GridBagConstraints gbc_6 = new GridBagConstraints(); // gbc_6.gridx = 1; // gbc_6.gridy = 10; // this.add(txt_encryptContent, gbc_6); }
From source file:misc.TrayIconDemo.java
private static void createAndShowGUI() { //Check the SystemTray support if (!SystemTray.isSupported()) { System.out.println("SystemTray is not supported"); return;//from www . j a v a 2 s.co m } final PopupMenu popup = new PopupMenu(); final TrayIcon trayIcon = new TrayIcon(createImage("images/bulb.gif", "tray icon")); final SystemTray tray = SystemTray.getSystemTray(); // Create a popup menu components MenuItem aboutItem = new MenuItem("About"); CheckboxMenuItem cb1 = new CheckboxMenuItem("Set auto size"); CheckboxMenuItem cb2 = new CheckboxMenuItem("Set tooltip"); Menu displayMenu = new Menu("Display"); MenuItem errorItem = new MenuItem("Error"); MenuItem warningItem = new MenuItem("Warning"); MenuItem infoItem = new MenuItem("Info"); MenuItem noneItem = new MenuItem("None"); MenuItem exitItem = new MenuItem("Exit"); //Add components to popup menu popup.add(aboutItem); popup.addSeparator(); popup.add(cb1); popup.add(cb2); popup.addSeparator(); popup.add(displayMenu); displayMenu.add(errorItem); displayMenu.add(warningItem); displayMenu.add(infoItem); displayMenu.add(noneItem); popup.add(exitItem); trayIcon.setPopupMenu(popup); try { tray.add(trayIcon); } catch (AWTException e) { System.out.println("TrayIcon could not be added."); return; } trayIcon.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(null, "This dialog box is run from System Tray"); } }); aboutItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(null, "This dialog box is run from the About menu item"); } }); cb1.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { int cb1Id = e.getStateChange(); if (cb1Id == ItemEvent.SELECTED) { trayIcon.setImageAutoSize(true); } else { trayIcon.setImageAutoSize(false); } } }); cb2.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { int cb2Id = e.getStateChange(); if (cb2Id == ItemEvent.SELECTED) { trayIcon.setToolTip("Sun TrayIcon"); } else { trayIcon.setToolTip(null); } } }); ActionListener listener = new ActionListener() { public void actionPerformed(ActionEvent e) { MenuItem item = (MenuItem) e.getSource(); //TrayIcon.MessageType type = null; System.out.println(item.getLabel()); if ("Error".equals(item.getLabel())) { //type = TrayIcon.MessageType.ERROR; trayIcon.displayMessage("Sun TrayIcon Demo", "This is an error message", TrayIcon.MessageType.ERROR); } else if ("Warning".equals(item.getLabel())) { //type = TrayIcon.MessageType.WARNING; trayIcon.displayMessage("Sun TrayIcon Demo", "This is a warning message", TrayIcon.MessageType.WARNING); } else if ("Info".equals(item.getLabel())) { //type = TrayIcon.MessageType.INFO; trayIcon.displayMessage("Sun TrayIcon Demo", "This is an info message", TrayIcon.MessageType.INFO); } else if ("None".equals(item.getLabel())) { //type = TrayIcon.MessageType.NONE; trayIcon.displayMessage("Sun TrayIcon Demo", "This is an ordinary message", TrayIcon.MessageType.NONE); } } }; errorItem.addActionListener(listener); warningItem.addActionListener(listener); infoItem.addActionListener(listener); noneItem.addActionListener(listener); exitItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { tray.remove(trayIcon); System.exit(0); } }); }
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);/*from w w w .j a va2s.c o m*/ 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:com.opendoorlogistics.studio.components.geocoder.SearchResultsPanel.java
SearchResultsPanel(final NominatimConfig config, final GeocodeModel model) { this.model = model; this.config = config; // server selector at top serverBox = Controls.createServerBox(config.getServer()); serverBox.addValueChangedListener(new ValueChangedListener<String>() { @Override//from w w w . ja v a 2s .com public void comboValueChanged(String newValue) { updateAppearance(); } }); countryCode = Controls.createCountryBox(config.getCountryCode()); countryCode.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { updateAppearance(); } }); // refresh button by server selector refresh = new JButton(Icons.loadFromStandardPath("view-refresh-6.png")); refresh.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { refreshResults(); } }); refresh.setToolTipText("Re-run the query"); // add the controls addLine(Controls.createServerLabel(), serverBox); addWhitespace(6); addLine(Controls.createCountryFilterLabel(), countryCode, Box.createRigidArea(new Dimension(10, 1)), refresh); addWhitespace(); // results table in the middle table = new JTable(); table.setColumnSelectionAllowed(false); table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { readSelectedIntoModel(); } }); table.setFillsViewportHeight(true); JScrollPane scrollPane = new JScrollPane(table); add(scrollPane); setTableModel(); model.addListener(this); updateAppearance(); }
From source file:uk.ac.ebi.mnb.dialog.tools.DownloadStructuresDialog.java
public DownloadStructuresDialog(JFrame frame, TargetedUpdate updater, ReportManager messages, SelectionController controller, UndoableEditListener undoableEdits) { super(frame, updater, messages, controller, undoableEdits, "RunDialog"); // blend the list in resourceSelection.setBackground(getBackground()); resourceSelection.setForeground(LabelFactory.newFormLabel("").getForeground()); resourceSelection.setVisibleRowCount(6); ws.addItemListener(new ItemListener() { @Override//from w ww . ja v a2s. c om public void itemStateChanged(ItemEvent e) { updateResourceList(); } }); setDefaultLayout(); }
From source file:org.csml.tommo.sugar.modules.heatmap.MixedHeatmapDialog.java
public MixOperationComboBox createMixOperationComboBox() { MixOperationComboBox comboBox = new MixOperationComboBox(); comboBox.addItemListener(new ItemListener() { @Override/*from w w w. j av a2 s . c om*/ public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { MixOperationComboBox box = (MixOperationComboBox) e.getSource(); double param = mixOperation.getParameter(); IMixOperation newMixOperation = box.getSelectedItem().getMixer(); newMixOperation.setParameter(param); updateMixOperation(newMixOperation); } } }); return comboBox; }
From source file:com.konifar.material_icon_generator.MaterialDesignIconGenerateDialog.java
private void initSizeCheckBox() { checkBoxMdpi.addItemListener(new ItemListener() { @Override//from w w w. j ava2 s . c o m public void itemStateChanged(ItemEvent event) { if (model != null) model.setMdpi(checkBoxMdpi.isSelected()); } }); checkBoxHdpi.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent event) { if (model != null) model.setHdpi(checkBoxHdpi.isSelected()); } }); checkBoxXhdpi.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent event) { if (model != null) model.setXhdpi(checkBoxXhdpi.isSelected()); } }); checkBoxXxhdpi.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent event) { if (model != null) model.setXxhdpi(checkBoxXxhdpi.isSelected()); } }); checkBoxXxxhdpi.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent event) { if (model != null) model.setXxxhdpi(checkBoxXxxhdpi.isSelected()); } }); }
From source file:com.eviware.soapui.impl.rest.panels.mock.RestMockResponseDesktopPanel.java
private JComponent createMediaTypeCombo() { MediaTypeComboBox mediaTypeComboBox = new MediaTypeComboBox(this.getModelItem()); mediaTypeComboBox.addItemListener(new ItemListener() { @Override// w ww . j a va 2s. c om public void itemStateChanged(ItemEvent e) { setMediaType(getResponseEditor().getInputArea(), e.getItem().toString()); } }); JComponent innerPanel = createPanelWithLabel("Content | Media type: ", mediaTypeComboBox); JPanel outerPanel = new JPanel(); outerPanel.setLayout(new BoxLayout(outerPanel, BoxLayout.X_AXIS)); outerPanel.add(innerPanel); outerPanel.add(Box.createHorizontalGlue()); outerPanel .add(UISupport.createFormButton(new ShowOnlineHelpAction(HelpUrls.REST_MOCK_RESPONSE_EDITOR_BODY))); return outerPanel; }