List of usage examples for javax.swing JButton setActionCommand
public void setActionCommand(String actionCommand)
From source file:ffx.ui.ModelingPanel.java
private JPanel getAminoAcidPanel() { if (aminoPanel != null) { return aminoPanel; }/*from w w w . ja v a2 s . c om*/ JPanel buttonPanel = new JPanel(new GridLayout(4, 5, 2, 2)); Residue.AA3 a[] = Residue.AA3.values(); for (int i = 0; i < 20; i++) { JButton button = new JButton(a[i].name()); button.setActionCommand("PROTEIN"); button.addActionListener(this); buttonPanel.add(button); } buttonPanel.setMaximumSize(buttonPanel.getPreferredSize()); aminoPanel = new JPanel(); aminoPanel.setLayout(new BoxLayout(aminoPanel, BoxLayout.Y_AXIS)); aminoPanel.add(buttonPanel); conformationComboBox = new JComboBox<>(Residue.Ramachandran); conformationComboBox.setFont(Font.decode("Monospaced")); conformationComboBox.setMaximumSize(buttonPanel.getPreferredSize()); aminoPanel.add(conformationComboBox); return aminoPanel; }
From source file:ffx.ui.ModelingPanel.java
private JPanel getNucleicAcidPanel() { if (nucleicPanel != null) { return nucleicPanel; }/* w ww .j a v a2 s .c om*/ nucleicPanel = new JPanel(new GridLayout(3, 4, 2, 2)); Residue.NA3 a[] = Residue.NA3.values(); for (int i = 0; i < 8; i++) { JButton button = new JButton(a[i].name()); button.setActionCommand("NUCLEIC"); button.addActionListener(this); nucleicPanel.add(button); } JButton button = new JButton("MOL"); button.setActionCommand("NUCLEIC"); button.addActionListener(this); nucleicPanel.add(button); nucleicPanel.add(Box.createHorizontalBox()); nucleicPanel.add(Box.createHorizontalBox()); nucleicPanel.add(Box.createHorizontalBox()); nucleicPanel.setMaximumSize(nucleicPanel.getPreferredSize()); return nucleicPanel; }
From source file:com.floreantpos.ui.model.PizzaItemForm.java
private JPanel getModifierGroupTab() { JPanel tabModifierGroup = new JPanel(new MigLayout("fill")); JButton btnNewModifierGroup = new javax.swing.JButton(); JButton btnEditModifierGroup = new javax.swing.JButton(); JButton btnDeleteModifierGroup = new javax.swing.JButton(); tableTicketItemModifierGroups = new javax.swing.JTable(); JScrollPane jScrollPane1 = new javax.swing.JScrollPane(); jScrollPane1.setViewportView(tableTicketItemModifierGroups); tabModifierGroup.add(jScrollPane1, "span,grow"); tabModifierGroup.add(btnNewModifierGroup, "left,split 3"); tabModifierGroup.add(btnEditModifierGroup); tabModifierGroup.add(btnDeleteModifierGroup); btnNewModifierGroup.setText(com.floreantpos.POSConstants.ADD); btnNewModifierGroup.setActionCommand("AddModifierGroup"); //$NON-NLS-1$ btnNewModifierGroup.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnNewModifierGroupActionPerformed(evt); }/* w w w. j ava 2s. com*/ }); btnDeleteModifierGroup.setText(com.floreantpos.POSConstants.DELETE); btnDeleteModifierGroup.setActionCommand("DeleteModifierGroup"); //$NON-NLS-1$ btnEditModifierGroup.setText(com.floreantpos.POSConstants.EDIT); btnEditModifierGroup.setActionCommand("EditModifierGroup"); //$NON-NLS-1$ menuItemMGListModel = new MenuItemMGListModel(); tableTicketItemModifierGroups.setModel(menuItemMGListModel); btnNewModifierGroup.addActionListener(this); btnEditModifierGroup.addActionListener(this); btnDeleteModifierGroup.addActionListener(this); return tabModifierGroup; }
From source file:org.jets3t.apps.uploader.Uploader.java
/** * Initialises the application's GUI elements. */// w w w .j av a 2 s. c o m private void initGui() { // Initialise skins factory. skinsFactory = SkinsFactory.getInstance(uploaderProperties.getProperties()); // Set Skinned Look and Feel. LookAndFeel lookAndFeel = skinsFactory.createSkinnedMetalTheme("SkinnedLookAndFeel"); try { UIManager.setLookAndFeel(lookAndFeel); } catch (UnsupportedLookAndFeelException e) { log.error("Unable to set skinned LookAndFeel", e); } // Apply branding String applicationTitle = replaceMessageVariables( uploaderProperties.getStringProperty("gui.applicationTitle", null)); if (applicationTitle != null) { ownerFrame.setTitle(applicationTitle); } String applicationIconPath = uploaderProperties.getStringProperty("gui.applicationIcon", null); if (!isRunningAsApplet && applicationIconPath != null) { guiUtils.applyIcon(ownerFrame, applicationIconPath); } String footerHtml = uploaderProperties.getStringProperty("gui.footerHtml", null); String footerIconPath = uploaderProperties.getStringProperty("gui.footerIcon", null); // Footer for branding boolean includeFooter = false; JHtmlLabel footerLabel = skinsFactory.createSkinnedJHtmlLabel("FooterLabel"); footerLabel.setHyperlinkeActivatedListener(this); footerLabel.setHorizontalAlignment(JLabel.CENTER); if (footerHtml != null) { footerLabel.setText(replaceMessageVariables(footerHtml)); includeFooter = true; } if (footerIconPath != null) { guiUtils.applyIcon(footerLabel, footerIconPath); } userInputFields = new UserInputFields(insetsDefault, this, skinsFactory); // Screeen 1 : User input fields. JPanel screen1Panel = skinsFactory.createSkinnedJPanel("Screen1Panel"); screen1Panel.setLayout(GRID_BAG_LAYOUT); userInputFields.buildFieldsPanel(screen1Panel, uploaderProperties); // Screen 2 : Drag/drop panel. JPanel screen2Panel = skinsFactory.createSkinnedJPanel("Screen2Panel"); screen2Panel.setLayout(GRID_BAG_LAYOUT); dragDropTargetLabel = skinsFactory.createSkinnedJHtmlLabel("DragDropTargetLabel"); dragDropTargetLabel.setHyperlinkeActivatedListener(this); dragDropTargetLabel.setHorizontalAlignment(JLabel.CENTER); dragDropTargetLabel.setVerticalAlignment(JLabel.CENTER); JButton chooseFileButton = skinsFactory.createSkinnedJButton("ChooseFileButton"); chooseFileButton.setActionCommand("ChooseFile"); chooseFileButton.addActionListener(this); configureButton(chooseFileButton, "screen.2.browseButton"); screen2Panel.add(dragDropTargetLabel, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsDefault, 0, 0)); screen2Panel.add(chooseFileButton, new GridBagConstraints(0, 1, 1, 1, 1, 1, GridBagConstraints.NORTH, GridBagConstraints.NONE, insetsDefault, 0, 0)); // Screen 3 : Information about the file to be uploaded. JPanel screen3Panel = skinsFactory.createSkinnedJPanel("Screen3Panel"); screen3Panel.setLayout(GRID_BAG_LAYOUT); fileToUploadLabel = skinsFactory.createSkinnedJHtmlLabel("FileToUploadLabel"); fileToUploadLabel.setHyperlinkeActivatedListener(this); fileToUploadLabel.setHorizontalAlignment(JLabel.CENTER); fileToUploadLabel.setVerticalAlignment(JLabel.CENTER); screen3Panel.add(fileToUploadLabel, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsDefault, 0, 0)); // Screen 4 : Upload progress. JPanel screen4Panel = skinsFactory.createSkinnedJPanel("Screen4Panel"); screen4Panel.setLayout(GRID_BAG_LAYOUT); fileInformationLabel = skinsFactory.createSkinnedJHtmlLabel("FileInformationLabel"); fileInformationLabel.setHyperlinkeActivatedListener(this); fileInformationLabel.setHorizontalAlignment(JLabel.CENTER); progressBar = skinsFactory.createSkinnedJProgressBar("ProgressBar", 0, 100); progressBar.setStringPainted(true); progressStatusTextLabel = skinsFactory.createSkinnedJHtmlLabel("ProgressStatusTextLabel"); progressStatusTextLabel.setHyperlinkeActivatedListener(this); progressStatusTextLabel.setText(" "); progressStatusTextLabel.setHorizontalAlignment(JLabel.CENTER); progressTransferDetailsLabel = skinsFactory.createSkinnedJHtmlLabel("ProgressTransferDetailsLabel"); progressTransferDetailsLabel.setHyperlinkeActivatedListener(this); progressTransferDetailsLabel.setText(" "); progressTransferDetailsLabel.setHorizontalAlignment(JLabel.CENTER); cancelUploadButton = skinsFactory.createSkinnedJButton("CancelUploadButton"); cancelUploadButton.setActionCommand("CancelUpload"); cancelUploadButton.addActionListener(this); configureButton(cancelUploadButton, "screen.4.cancelButton"); screen4Panel.add(fileInformationLabel, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); screen4Panel.add(progressBar, new GridBagConstraints(0, 1, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); screen4Panel.add(progressStatusTextLabel, new GridBagConstraints(0, 2, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); screen4Panel.add(progressTransferDetailsLabel, new GridBagConstraints(0, 3, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); screen4Panel.add(cancelUploadButton, new GridBagConstraints(0, 4, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, insetsDefault, 0, 0)); // Screen 5 : Thankyou message. JPanel screen5Panel = skinsFactory.createSkinnedJPanel("Screen5Panel"); screen5Panel.setLayout(GRID_BAG_LAYOUT); finalMessageLabel = skinsFactory.createSkinnedJHtmlLabel("FinalMessageLabel"); finalMessageLabel.setHyperlinkeActivatedListener(this); finalMessageLabel.setHorizontalAlignment(JLabel.CENTER); screen5Panel.add(finalMessageLabel, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsDefault, 0, 0)); // Wizard Button panel. backButton = skinsFactory.createSkinnedJButton("backButton"); backButton.setActionCommand("Back"); backButton.addActionListener(this); nextButton = skinsFactory.createSkinnedJButton("nextButton"); nextButton.setActionCommand("Next"); nextButton.addActionListener(this); buttonsPanel = skinsFactory.createSkinnedJPanel("ButtonsPanel"); buttonsPanelCardLayout = new CardLayout(); buttonsPanel.setLayout(buttonsPanelCardLayout); JPanel buttonsInvisiblePanel = skinsFactory.createSkinnedJPanel("ButtonsInvisiblePanel"); JPanel buttonsVisiblePanel = skinsFactory.createSkinnedJPanel("ButtonsVisiblePanel"); buttonsVisiblePanel.setLayout(GRID_BAG_LAYOUT); buttonsVisiblePanel.add(backButton, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insetsDefault, 0, 0)); buttonsVisiblePanel.add(nextButton, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); buttonsPanel.add(buttonsInvisiblePanel, "invisible"); buttonsPanel.add(buttonsVisiblePanel, "visible"); // Overall content panel. appContentPanel = skinsFactory.createSkinnedJPanel("ApplicationContentPanel"); appContentPanel.setLayout(GRID_BAG_LAYOUT); JPanel userGuidancePanel = skinsFactory.createSkinnedJPanel("UserGuidancePanel"); userGuidancePanel.setLayout(GRID_BAG_LAYOUT); primaryPanel = skinsFactory.createSkinnedJPanel("PrimaryPanel"); primaryPanelCardLayout = new CardLayout(); primaryPanel.setLayout(primaryPanelCardLayout); JPanel navigationPanel = skinsFactory.createSkinnedJPanel("NavigationPanel"); navigationPanel.setLayout(GRID_BAG_LAYOUT); appContentPanel.add(userGuidancePanel, new GridBagConstraints(0, 0, 1, 1, 1, 0.2, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsDefault, 0, 0)); appContentPanel.add(primaryPanel, new GridBagConstraints(0, 1, 1, 1, 1, 0.6, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsDefault, 0, 0)); appContentPanel.add(navigationPanel, new GridBagConstraints(0, 2, 1, 1, 1, 0.2, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsDefault, 0, 0)); if (includeFooter) { log.debug("Adding footer for branding"); appContentPanel.add(footerLabel, new GridBagConstraints(0, 3, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); } this.getContentPane().add(appContentPanel); userGuidanceLabel = skinsFactory.createSkinnedJHtmlLabel("UserGuidanceLabel"); userGuidanceLabel.setHyperlinkeActivatedListener(this); userGuidanceLabel.setHorizontalAlignment(JLabel.CENTER); userGuidancePanel.add(userGuidanceLabel, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsNone, 0, 0)); navigationPanel.add(buttonsPanel, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsNone, 0, 0)); primaryPanel.add(screen1Panel, "screen1"); primaryPanel.add(screen2Panel, "screen2"); primaryPanel.add(screen3Panel, "screen3"); primaryPanel.add(screen4Panel, "screen4"); primaryPanel.add(screen5Panel, "screen5"); // Set preferred sizes int preferredWidth = uploaderProperties.getIntProperty("gui.minSizeWidth", 400); int preferredHeight = uploaderProperties.getIntProperty("gui.minSizeHeight", 500); this.setBounds(new Rectangle(new Dimension(preferredWidth, preferredHeight))); // Initialize drop target. initDropTarget(new Component[] { this }); // Revert to default Look and Feel for all future GUI elements (eg Dialog boxes). try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { log.error("Unable to set default system LookAndFeel", e); } wizardStepForward(); }
From source file:org.jfree.chart.demo.JFreeChartDemo.java
/** * Creates a tabbed pane containing descriptions of the demo charts. * * @param resources localised resources. * * @return a tabbed pane./* w w w . java 2 s. c o m*/ */ private JTabbedPane createTabbedPane(final ResourceBundle resources) { final Font font = new Font("Dialog", Font.PLAIN, 12); final JTabbedPane tabs = new JTabbedPane(); int tab = 1; final Vector titles = new Vector(0); final String[] tabTitles; String title = null; while (tab > 0) { try { title = resources.getString("tabs." + tab); if (title != null) { titles.add(title); } else { tab = -1; } ++tab; } catch (Exception ex) { tab = -1; } } if (titles.size() == 0) { titles.add("Default"); } tab = titles.size(); this.panels = new JPanel[tab]; tabTitles = new String[tab]; --tab; for (; tab >= 0; --tab) { title = titles.get(tab).toString(); tabTitles[tab] = title; } titles.removeAllElements(); for (int i = 0; i < tabTitles.length; ++i) { this.panels[i] = new JPanel(); this.panels[i].setLayout(new LCBLayout(20)); this.panels[i].setPreferredSize(new Dimension(360, 20)); this.panels[i].setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); tabs.add(tabTitles[i], new JScrollPane(this.panels[i])); } String description; final String buttonText = resources.getString("charts.display"); JButton b1; // Load the CHARTS ... String usage = null; for (int i = 0; i <= CHART_COMMANDS.length - 1; ++i) { try { usage = resources.getString(CHART_COMMANDS[i][2] + ".usage"); } catch (Exception ex) { usage = null; } if ((usage == null) || usage.equalsIgnoreCase("All") || usage.equalsIgnoreCase("Swing")) { title = resources.getString(CHART_COMMANDS[i][2] + ".title"); description = resources.getString(CHART_COMMANDS[i][2] + ".description"); try { tab = Integer.parseInt(resources.getString(CHART_COMMANDS[i][2] + ".tab")); --tab; } catch (Exception ex) { System.err.println("Demo : Error retrieving tab identifier for chart " + CHART_COMMANDS[i][2]); System.err.println("Demo : Error = " + ex.getMessage()); tab = 0; } if ((tab < 0) || (tab >= this.panels.length)) { tab = 0; } System.out.println("Demo : adding " + CHART_COMMANDS[i][0] + " to panel " + tab); this.panels[tab].add(RefineryUtilities.createJLabel(title, font)); this.panels[tab].add(new DescriptionPanel(new JTextArea(description))); b1 = RefineryUtilities.createJButton(buttonText, font); b1.setActionCommand(CHART_COMMANDS[i][0]); b1.addActionListener(this); this.panels[tab].add(b1); } } return tabs; }
From source file:ffx.ui.ModelingPanel.java
private void loadCommand() { synchronized (this) { // Force Field X Command Element command;/*from w w w . j a v a2 s . co m*/ // Command Options NodeList options; Element option; // Option Values NodeList values; Element value; // Options may be Conditional based on previous Option values (not // always supplied) NodeList conditionalList; Element conditional; // JobPanel GUI Components that change based on command JPanel optionPanel; // Clear the previous components commandPanel.removeAll(); optionsTabbedPane.removeAll(); conditionals.clear(); String currentCommand = (String) currentCommandBox.getSelectedItem(); if (currentCommand == null) { commandPanel.validate(); commandPanel.repaint(); return; } command = null; for (int i = 0; i < commandList.getLength(); i++) { command = (Element) commandList.item(i); String name = command.getAttribute("name"); if (name.equalsIgnoreCase(currentCommand)) { break; } } int div = splitPane.getDividerLocation(); descriptTextArea.setText(currentCommand.toUpperCase() + ": " + command.getAttribute("description")); splitPane.setBottomComponent(descriptScrollPane); splitPane.setDividerLocation(div); // The "action" tells Force Field X what to do when the // command finishes commandActions = command.getAttribute("action").trim(); // The "fileType" specifies what file types this command can execute // on String string = command.getAttribute("fileType").trim(); String[] types = string.split(" +"); commandFileTypes.clear(); for (String type : types) { if (type.contains("XYZ")) { commandFileTypes.add(FileType.XYZ); } if (type.contains("INT")) { commandFileTypes.add(FileType.INT); } if (type.contains("ARC")) { commandFileTypes.add(FileType.ARC); } if (type.contains("PDB")) { commandFileTypes.add(FileType.PDB); } if (type.contains("ANY")) { commandFileTypes.add(FileType.ANY); } } // Determine what options are available for this command options = command.getElementsByTagName("Option"); int length = options.getLength(); for (int i = 0; i < length; i++) { // This Option will be enabled (isEnabled = true) unless a // Conditional disables it boolean isEnabled = true; option = (Element) options.item(i); conditionalList = option.getElementsByTagName("Conditional"); /* * Currently, there can only be 0 or 1 Conditionals per Option * There are three types of Conditionals implemented. 1.) * Conditional on a previous Option, this option may be * available 2.) Conditional on input for this option, a * sub-option may be available 3.) Conditional on the presence * of keywords, this option may be available */ if (conditionalList != null) { conditional = (Element) conditionalList.item(0); } else { conditional = null; } // Get the command line flag String flag = option.getAttribute("flag").trim(); // Get the description String optionDescript = option.getAttribute("description"); JTextArea optionTextArea = new JTextArea(" " + optionDescript.trim()); optionTextArea.setEditable(false); optionTextArea.setLineWrap(true); optionTextArea.setWrapStyleWord(true); optionTextArea.setBorder(etchedBorder); // Get the default for this Option (if one exists) String defaultOption = option.getAttribute("default"); // Option Panel optionPanel = new JPanel(new BorderLayout()); optionPanel.add(optionTextArea, BorderLayout.NORTH); String swing = option.getAttribute("gui"); JPanel optionValuesPanel = new JPanel(new FlowLayout()); optionValuesPanel.setBorder(etchedBorder); ButtonGroup bg = null; if (swing.equalsIgnoreCase("CHECKBOXES")) { // CHECKBOXES allows selection of 1 or more values from a // predefined set (Analyze, for example) values = option.getElementsByTagName("Value"); for (int j = 0; j < values.getLength(); j++) { value = (Element) values.item(j); JCheckBox jcb = new JCheckBox(value.getAttribute("name")); jcb.addMouseListener(this); jcb.setName(flag); if (defaultOption != null && jcb.getActionCommand().equalsIgnoreCase(defaultOption)) { jcb.setSelected(true); } optionValuesPanel.add(jcb); } } else if (swing.equalsIgnoreCase("TEXTFIELD")) { // TEXTFIELD takes an arbitrary String as input JTextField jtf = new JTextField(20); jtf.addMouseListener(this); jtf.setName(flag); if (defaultOption != null && defaultOption.equals("ATOMS")) { FFXSystem sys = mainPanel.getHierarchy().getActive(); if (sys != null) { jtf.setText("" + sys.getAtomList().size()); } } else if (defaultOption != null) { jtf.setText(defaultOption); } optionValuesPanel.add(jtf); } else if (swing.equalsIgnoreCase("RADIOBUTTONS")) { // RADIOBUTTONS allows one choice from a set of predifined // values bg = new ButtonGroup(); values = option.getElementsByTagName("Value"); for (int j = 0; j < values.getLength(); j++) { value = (Element) values.item(j); JRadioButton jrb = new JRadioButton(value.getAttribute("name")); jrb.addMouseListener(this); jrb.setName(flag); bg.add(jrb); if (defaultOption != null && jrb.getActionCommand().equalsIgnoreCase(defaultOption)) { jrb.setSelected(true); } optionValuesPanel.add(jrb); } } else if (swing.equalsIgnoreCase("PROTEIN")) { // Protein allows selection of amino acids for the protein // builder optionValuesPanel.setLayout(new BoxLayout(optionValuesPanel, BoxLayout.Y_AXIS)); optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5))); optionValuesPanel.add(getAminoAcidPanel()); optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5))); acidComboBox.removeAllItems(); JButton add = new JButton("Edit"); add.setActionCommand("PROTEIN"); add.addActionListener(this); add.setAlignmentX(Button.CENTER_ALIGNMENT); JPanel comboPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); comboPanel.add(acidTextField); comboPanel.add(add); optionValuesPanel.add(comboPanel); optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5))); JButton remove = new JButton("Remove"); add.setMinimumSize(remove.getPreferredSize()); add.setPreferredSize(remove.getPreferredSize()); remove.setActionCommand("PROTEIN"); remove.addActionListener(this); remove.setAlignmentX(Button.CENTER_ALIGNMENT); comboPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); comboPanel.add(acidComboBox); comboPanel.add(remove); optionValuesPanel.add(comboPanel); optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5))); optionValuesPanel.add(acidScrollPane); optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5))); JButton reset = new JButton("Reset"); reset.setActionCommand("PROTEIN"); reset.addActionListener(this); reset.setAlignmentX(Button.CENTER_ALIGNMENT); optionValuesPanel.add(reset); optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5))); acidTextArea.setText(""); acidTextField.setText(""); } else if (swing.equalsIgnoreCase("NUCLEIC")) { // Nucleic allows selection of nucleic acids for the nucleic // acid builder optionValuesPanel.setLayout(new BoxLayout(optionValuesPanel, BoxLayout.Y_AXIS)); optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5))); optionValuesPanel.add(getNucleicAcidPanel()); optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5))); acidComboBox.removeAllItems(); JButton add = new JButton("Edit"); add.setActionCommand("NUCLEIC"); add.addActionListener(this); add.setAlignmentX(Button.CENTER_ALIGNMENT); JPanel comboPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); comboPanel.add(acidTextField); comboPanel.add(add); optionValuesPanel.add(comboPanel); optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5))); JButton remove = new JButton("Remove"); add.setMinimumSize(remove.getPreferredSize()); add.setPreferredSize(remove.getPreferredSize()); remove.setActionCommand("NUCLEIC"); remove.addActionListener(this); remove.setAlignmentX(Button.CENTER_ALIGNMENT); comboPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); comboPanel.add(acidComboBox); comboPanel.add(remove); optionValuesPanel.add(comboPanel); optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5))); optionValuesPanel.add(acidScrollPane); optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5))); JButton button = new JButton("Reset"); button.setActionCommand("NUCLEIC"); button.addActionListener(this); button.setAlignmentX(Button.CENTER_ALIGNMENT); optionValuesPanel.add(button); optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5))); acidTextArea.setText(""); acidTextField.setText(""); } else if (swing.equalsIgnoreCase("SYSTEMS")) { // SYSTEMS allows selection of an open system JComboBox<FFXSystem> jcb = new JComboBox<>(mainPanel.getHierarchy().getNonActiveSystems()); jcb.setSize(jcb.getMaximumSize()); jcb.addActionListener(this); optionValuesPanel.add(jcb); } // Set up a Conditional for this Option if (conditional != null) { isEnabled = false; String conditionalName = conditional.getAttribute("name"); String conditionalValues = conditional.getAttribute("value"); String cDescription = conditional.getAttribute("description"); String cpostProcess = conditional.getAttribute("postProcess"); if (conditionalName.toUpperCase().startsWith("KEYWORD")) { optionPanel.setName(conditionalName); String keywords[] = conditionalValues.split(" +"); if (activeSystem != null) { Hashtable<String, Keyword> systemKeywords = activeSystem.getKeywords(); for (String key : keywords) { if (systemKeywords.containsKey(key.toUpperCase())) { isEnabled = true; } } } } else if (conditionalName.toUpperCase().startsWith("VALUE")) { isEnabled = true; // Add listeners to the values of this option so // the conditional options can be disabled/enabled. for (int j = 0; j < optionValuesPanel.getComponentCount(); j++) { JToggleButton jtb = (JToggleButton) optionValuesPanel.getComponent(j); jtb.addActionListener(this); jtb.setActionCommand("Conditional"); } JPanel condpanel = new JPanel(); condpanel.setBorder(etchedBorder); JLabel condlabel = new JLabel(cDescription); condlabel.setEnabled(false); condlabel.setName(conditionalValues); JTextField condtext = new JTextField(10); condlabel.setLabelFor(condtext); if (cpostProcess != null) { condtext.setName(cpostProcess); } condtext.setEnabled(false); condpanel.add(condlabel); condpanel.add(condtext); conditionals.add(condlabel); optionPanel.add(condpanel, BorderLayout.SOUTH); } else if (conditionalName.toUpperCase().startsWith("REFLECTION")) { String[] condModifiers; if (conditionalValues.equalsIgnoreCase("AltLoc")) { condModifiers = activeSystem.getAltLocations(); if (condModifiers != null && condModifiers.length > 1) { isEnabled = true; bg = new ButtonGroup(); for (int j = 0; j < condModifiers.length; j++) { JRadioButton jrbmi = new JRadioButton(condModifiers[j]); jrbmi.addMouseListener(this); bg.add(jrbmi); optionValuesPanel.add(jrbmi); if (j == 0) { jrbmi.setSelected(true); } } } } else if (conditionalValues.equalsIgnoreCase("Chains")) { condModifiers = activeSystem.getChainNames(); if (condModifiers != null && condModifiers.length > 0) { isEnabled = true; for (int j = 0; j < condModifiers.length; j++) { JRadioButton jrbmi = new JRadioButton(condModifiers[j]); jrbmi.addMouseListener(this); bg.add(jrbmi); optionValuesPanel.add(jrbmi, j); } } } } } optionPanel.add(optionValuesPanel, BorderLayout.CENTER); optionPanel.setPreferredSize(optionPanel.getPreferredSize()); optionsTabbedPane.addTab(option.getAttribute("name"), optionPanel); optionsTabbedPane.setEnabledAt(optionsTabbedPane.getTabCount() - 1, isEnabled); } } optionsTabbedPane.setPreferredSize(optionsTabbedPane.getPreferredSize()); commandPanel.setLayout(borderLayout); commandPanel.add(optionsTabbedPane, BorderLayout.CENTER); commandPanel.validate(); commandPanel.repaint(); loadLogSettings(); statusLabel.setText(" " + createCommandInput()); }
From source file:windows.sensorWindow.java
/** * window constructor for chart window// w w w. ja va2s . c o m * * @param title * title for the new window */ public sensorWindow(final String title) { super(title); System.out.println("create sensorWindow"); // font customizing // ------------------------------------------------------- /* * Font font1 = null; try { font1 = Font.createFont(Font.TRUETYPE_FONT, * new File("U:/workspace/SWTtest/fonts/roboto/Roboto-Black.ttf")); } * catch (FontFormatException | IOException e1) { e1.printStackTrace(); * } StandardChartTheme chartTheme = new * StandardChartTheme("robotTheme"); * chartTheme.setExtraLargeFont(font1.deriveFont(24f)); * chartTheme.setLargeFont(font1.deriveFont(16f)); * chartTheme.setRegularFont(font1.deriveFont(12f)); * chartTheme.setSmallFont(font1.deriveFont(10f)); * ChartFactory.setChartTheme(chartTheme); */ Font font1 = new Font("Tahoma", Font.BOLD, 16); Font font2 = new Font("Tahoma", Font.PLAIN, 12); Font font3 = new Font("Tahoma", Font.BOLD, 16); customFonts.put("axisLabelFont", font1); customFonts.put("axisValueFont", font2); customFonts.put("titleFont", font3); // ------------------------------------------------------------------------- this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); plot = new CombinedDomainXYPlot(new DateAxis("Time")); for (int i = 0; i < connectionData.presentedBrickList.size(); i++) { Brick tmpBrick = connectionData.presentedBrickList.get(i); addPlot(tmpBrick); } final JFreeChart chart = new JFreeChart("", plot); // chart.setBorderPaint(Color.black); // chart.setBorderVisible(true); // chart.setBackgroundPaint(Color.white); chart.removeLegend(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); // plot.setRenderer(renderer2); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 4, 4, 4, 4)); final ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true); axis.setFixedAutoRange(chartRangeSec * 1000); // chart range seconds axis.setLabelFont(customFonts.get("axisLabelFont")); axis.setTickLabelFont(customFonts.get("axisValueFont")); //final JPanel content = new JPanel(new BorderLayout()); content = new JPanel(new BorderLayout()); JScrollPane scrollPane = new JScrollPane(); JViewport viewport = scrollPane.getViewport(); viewport.setView(content); final ChartPanel chartPanel = new ChartPanel(chart); content.add(chartPanel, BorderLayout.NORTH); // content.add(getScrollBar(xAxe), BorderLayout.SOUTH); // disable zoom chartPanel.setRangeZoomable(false); chartPanel.setDomainZoomable(false); // mouse selection chartPanel.addMouseListener(new MouseMarker(chartPanel)); chartPanel.setPreferredSize(new java.awt.Dimension(500, 470)); // chartPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); // setContentPane(content); // =================================================== // buttons buttonPanel = new JPanel(new FlowLayout()); for (int i = 0; i < connectionData.presentedBrickList.size(); i++) { for (int i2 = 0; i2 < 2; i2++) { Brick tmpBrick = connectionData.presentedBrickList.get(i); JButton button = new JButton(tmpBrick.uid + " start"); button.setActionCommand(buttonComAddBtn + tmpBrick.uid + i + "(" + i2 + ")"); button.addActionListener(this); tmplButtons.put(tmpBrick.uid, button); // if ((tmpBrick.ctrlTmpl[0]) || (tmpBrick.ctrlTmpl[1])) // { // buttonPanel.add(button); // } changeTmplCntrl(tmpBrick, i2); } } content.add(buttonPanel, BorderLayout.SOUTH); // =================================================== // =================================================== // scroll bar final JPanel sliderPanel = new JPanel(new FlowLayout()); slider = new JSlider(1, sliderValuesNumber); slider.setValue(sliderValuesNumber); slider.setEnabled(false); slider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { if (sliderData.sliderActive == true) { int sliderValue = slider.getValue(); if (sliderValue == sliderValuesNumber) sliderUpdate = true; else sliderUpdate = false; /* System.out.println("slider : " + sliderValue); System.out.println("Millis first: " + sliderData.getMilliseconds( sliderValue - sliderValuesNumber) .toString()); System.out.println("Millis last : " + sliderData.getMilliseconds(sliderValue) .toString()); */ DateRange range = new DateRange( sliderData.getMilliseconds(sliderValue - sliderValuesNumber).getFirstMillisecond(), sliderData.getMilliseconds(sliderValue).getFirstMillisecond()); plot.getDomainAxis().setRange(range); } } }); sliderPanel.add(slider); // chartPanel.add(slider); /* * final Panel chartPanel2 = new Panel(); chartPanel2.add(slider); * content.add(chartPanel2, BorderLayout.SOUTH); */ content.add(sliderPanel, BorderLayout.CENTER); // =================================================== // =================================================== // scrolling /* * String[] data = {"one", "two", "three", "four", "five", "six", * "seven", "eight", "nine", "ten"}; JList list = new JList(data); * * // give the list some scrollbars. // the horizontal (bottom) * scrollbar will only appear // when the screen is too wide. The * vertical // scrollbar is always present, but disabled if the // list * is small. JScrollPane jsp = new JScrollPane(list, * JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, * JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); * * // add the JScrollPane (not the list) to the window. * getContentPane().add(jsp, BorderLayout.CENTER); */ // ================================================== setContentPane(content); this.addComponentListener(new java.awt.event.ComponentAdapter() { public void componentResized(java.awt.event.ComponentEvent e) { chartPanel.setMaximumDrawWidth((int) e.getComponent().getSize().getWidth()); chartPanel.setMaximumDrawHeight((int) e.getComponent().getSize().getHeight()); //chartPanel.setPreferredSize(e.getComponent().getPreferredSize()); //chartPanel.setSize(e.getComponent().getSize()); //chartPanel.setLocation(0,0); } }); // start auto update plot autoUpdatePlot(); this.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.out.println("close sensor window"); functions.windowController.closeSensorWindow(); } }); }
From source file:com.smart.aqimonitor.client.AqiSettingDialog.java
/** * Create the dialog./* w ww . j a v a 2s . co m*/ */ public AqiSettingDialog(Frame owner, final AbstractAqiParser aqiParser) { super(owner); this.aqiParser = aqiParser; setTitle("\u8BBE\u7F6E"); setResizable(false); setBounds(100, 100, 450, 135); getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, BorderLayout.CENTER); GridBagLayout gbl_contentPanel = new GridBagLayout(); gbl_contentPanel.columnWidths = new int[] { 33, 48, 66, 41, 48, 66, 0, 0 }; gbl_contentPanel.rowHeights = new int[] { 21, 0, 0 }; gbl_contentPanel.columnWeights = new double[] { 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE }; gbl_contentPanel.rowWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE }; contentPanel.setLayout(gbl_contentPanel); { JLabel lblRetryTimes = new JLabel("\u91CD\u8BD5\u6B21\u6570\uFF1A"); GridBagConstraints gbc_lblRetryTimes = new GridBagConstraints(); gbc_lblRetryTimes.anchor = GridBagConstraints.WEST; gbc_lblRetryTimes.insets = new Insets(0, 0, 5, 5); gbc_lblRetryTimes.gridx = 1; gbc_lblRetryTimes.gridy = 0; contentPanel.add(lblRetryTimes, gbc_lblRetryTimes); } { tfRetryTimes = new JTextField(); tfRetryTimes.setPreferredSize(new Dimension(6, 29)); tfRetryTimes.setMinimumSize(new Dimension(60, 29)); GridBagConstraints gbc_tfRetryTimes = new GridBagConstraints(); gbc_tfRetryTimes.anchor = GridBagConstraints.NORTHWEST; gbc_tfRetryTimes.insets = new Insets(0, 0, 5, 5); gbc_tfRetryTimes.gridx = 2; gbc_tfRetryTimes.gridy = 0; contentPanel.add(tfRetryTimes, gbc_tfRetryTimes); tfRetryTimes.setColumns(10); } { JLabel lblRetryGap = new JLabel("\u91CD\u8BD5\u95F4\u9694\uFF1A"); GridBagConstraints gbc_lblRetryGap = new GridBagConstraints(); gbc_lblRetryGap.anchor = GridBagConstraints.WEST; gbc_lblRetryGap.insets = new Insets(0, 0, 5, 5); gbc_lblRetryGap.gridx = 4; gbc_lblRetryGap.gridy = 0; contentPanel.add(lblRetryGap, gbc_lblRetryGap); } { tfRetryGap = new JTextField(); tfRetryGap.setMinimumSize(new Dimension(60, 29)); tfRetryGap.setPreferredSize(new Dimension(60, 29)); GridBagConstraints gbc_tfRetryGap = new GridBagConstraints(); gbc_tfRetryGap.insets = new Insets(0, 0, 5, 5); gbc_tfRetryGap.anchor = GridBagConstraints.NORTHWEST; gbc_tfRetryGap.gridx = 5; gbc_tfRetryGap.gridy = 0; contentPanel.add(tfRetryGap, gbc_tfRetryGap); tfRetryGap.setColumns(10); } { JLabel label = new JLabel("\u5206\u949F"); GridBagConstraints gbc_label = new GridBagConstraints(); gbc_label.insets = new Insets(0, 0, 5, 0); gbc_label.gridx = 6; gbc_label.gridy = 0; contentPanel.add(label, gbc_label); } { JLabel lblExportPath = new JLabel("\u8F93\u51FA\u8DEF\u5F84\uFF1A"); GridBagConstraints gbc_lblExportPath = new GridBagConstraints(); gbc_lblExportPath.anchor = GridBagConstraints.EAST; gbc_lblExportPath.insets = new Insets(0, 0, 0, 5); gbc_lblExportPath.gridx = 1; gbc_lblExportPath.gridy = 1; contentPanel.add(lblExportPath, gbc_lblExportPath); } { tfExportPath = new JTextField(); tfExportPath.setEditable(false); tfExportPath.setPreferredSize(new Dimension(180, 29)); tfExportPath.setMinimumSize(new Dimension(180, 29)); GridBagConstraints gbc_tfExportPath = new GridBagConstraints(); gbc_tfExportPath.gridwidth = 4; gbc_tfExportPath.insets = new Insets(0, 0, 0, 5); gbc_tfExportPath.fill = GridBagConstraints.HORIZONTAL; gbc_tfExportPath.gridx = 2; gbc_tfExportPath.gridy = 1; contentPanel.add(tfExportPath, gbc_tfExportPath); tfExportPath.setColumns(10); } { JButton button = new JButton("..."); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { fDialog = new JFileChooser(); // fDialog.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int result = fDialog.showOpenDialog(contentPanel); if (result == JFileChooser.APPROVE_OPTION) { tfExportPath.setText(fDialog.getSelectedFile().getAbsolutePath()); } } }); GridBagConstraints gbc_button = new GridBagConstraints(); gbc_button.gridx = 6; gbc_button.gridy = 1; contentPanel.add(button, gbc_button); } { JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); getContentPane().add(buttonPane, BorderLayout.SOUTH); { JButton okButton = new JButton("\u786E\u5B9A"); okButton.setName("settingOk"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String retryTimes = tfRetryTimes.getText(); if (StringUtils.isEmpty(retryTimes) || !isNumeric(retryTimes)) { JOptionPane.showMessageDialog(contentPanel, "", "", JOptionPane.ERROR_MESSAGE); return; } String retryGap = tfRetryGap.getText(); if (StringUtils.isEmpty(retryGap) || !isNumeric(retryGap)) { JOptionPane.showMessageDialog(contentPanel, "", "", JOptionPane.ERROR_MESSAGE); return; } String exportPath = tfExportPath.getText(); if (StringUtils.isEmpty(exportPath)) { JOptionPane.showMessageDialog(contentPanel, "", "", JOptionPane.ERROR_MESSAGE); return; } File testFile = new File(exportPath); if (!testFile.exists()) { JOptionPane.showMessageDialog(contentPanel, "", "", JOptionPane.ERROR_MESSAGE); return; } props.put("query.retryTimes", retryTimes); props.put("query.retryGap", retryGap); props.put("result.path", exportPath); try { props.store(new FileOutputStream(propertiesResource.getFile()), ""); aqiParser.setRetryTimes(Integer.parseInt(retryTimes)); aqiParser.setRetryGap(Integer.parseInt(retryGap)); aqiParser.setFilePath(exportPath); } catch (IOException e1) { e1.printStackTrace(); } finally { dispose(); } } }); okButton.setActionCommand("OK"); buttonPane.add(okButton); getRootPane().setDefaultButton(okButton); } { JButton cancelButton = new JButton("\u53D6\u6D88"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dispose(); } }); cancelButton.setActionCommand("Cancel"); buttonPane.add(cancelButton); } } }
From source file:com.nikonhacker.gui.EmulatorUI.java
protected JButton makeButton(String imageName, String actionCommand, String toolTipText, String altText) { //Look for the image. String imgLocation = "images/" + imageName + ".png"; URL imageURL = EmulatorUI.class.getResource(imgLocation); //Create and initialize the button. JButton button = new JButton(); button.setActionCommand(actionCommand); button.setToolTipText(toolTipText);/*from w w w . j a v a 2s . c om*/ button.addActionListener(this); button.setMargin(toolbarButtonMargin); if (imageURL != null) { ImageIcon icon = new ImageIcon(imageURL, altText); button.putClientProperty(BUTTON_PROPERTY_KEY_ICON, icon); button.setIcon(icon); } else { button.setText(altText); System.err.println("Resource not found: " + imgLocation); } return button; }
From source file:AppearanceExplorer.java
JPanel setupPanel() { JPanel panel = new JPanel(); panel.setLayout(new GridLayout(0, 1)); // This order of the names must match the cases in the Switch in // setupSceneSwitch String[] dataNames = { "Point Array", "Line Array", "Triangle Array", "Line Strip Array", "Triangle Strip Array", "Triangle Fan Array", "Textured Triangles", "Textured Square", "Large Texture Square", "Color Cube", "Norm Gen Cube - Crease", "Norm Gen Cube - Smooth", "Tri with hole", "Sphere", "Low-res Sphere", "High-res Sphere", "Text 3D", galleonString, beethovenString, };// www . j a v a 2 s . com IntChooser dataChooser = new IntChooser("Data:", dataNames); dataChooser.addIntListener(new IntListener() { public void intChanged(IntEvent event) { int value = event.getValue(); if (sceneSwitch.getChild(value) == beethovenPlaceholder) { beethoven = createBeethoven(); sceneSwitch.setChild(beethoven, beethovenIndex); } else if (sceneSwitch.getChild(value) == galleonPlaceholder) { galleon = createGalleon(); sceneSwitch.setChild(galleon, galleonIndex); } sceneSwitch.setWhichChild(value); } }); dataChooser.setValueByName("Sphere"); panel.add(dataChooser); panel.add(bgChooser); String[] lightNames = { "Ambient Only", "Directional", "Point Light 1", "Point Light 2", }; int[] lightValues = { Switch.CHILD_NONE, 0, 1, 2 }; IntChooser lightChooser = new IntChooser("Light:", lightNames, lightValues, 0); lightChooser.addIntListener(new IntListener() { public void intChanged(IntEvent event) { int value = event.getValue(); lightSwitch.setWhichChild(value); } }); lightChooser.setValueByName("Point Light 1"); panel.add(lightChooser); panel.add(new JLabel("")); if (isApplication) { JButton snapButton = new JButton(snapImageString); snapButton.setActionCommand(snapImageString); snapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doSnapshot(); } }); panel.add(snapButton); } return panel; }