List of usage examples for javax.swing JLabel setFont
@BeanProperty(preferred = true, visualUpdate = true, description = "The font for the component.") public void setFont(Font font)
From source file:org.openmicroscopy.shoola.util.ui.UIUtilities.java
/** * Displays the specified string into a {@link JLabel} and sets * the font to <code>bold</code>. * //w w w . ja v a2s .c o m * @param s The string to display. * @param fontStyle The style of the font. * @return See above. */ public static JLabel setTextFont(String s, int fontStyle) { if (s == null) s = ""; JLabel label = new JLabel(s); Font font = label.getFont(); Font newFont = font.deriveFont(fontStyle); label.setFont(newFont); return label; }
From source file:org.openmicroscopy.shoola.util.ui.UIUtilities.java
/** * Displays the specified string into a {@link JLabel} and sets * the font to <code>bold</code>. * //from w w w. j av a 2 s . co m * @param s The string to display. * @param fontStyle The style of font. * @param fontSize The size of the font. * @return See above. */ public static JLabel setTextFont(String s, int fontStyle, int fontSize) { if (s == null) s = ""; JLabel label = new JLabel(s); Font font = label.getFont(); label.setFont(font.deriveFont(fontStyle, fontSize)); return label; }
From source file:org.openmrs.test.BaseContextSensitiveTest.java
/** * Utility method for obtaining username and password through Swing interface for tests. Any * tests extending the org.openmrs.BaseTest class may simply invoke this method by name. * Username and password are returned in a two-member String array. If the user aborts, null is * returned. <b> <em>Do not call for non-interactive tests, since this method will try to * render an interactive dialog box for authentication!</em></b> * // w w w . j a va2 s .c o m * @param message string to display above username field * @return Two-member String array containing username and password, respectively, or * <code>null</code> if user aborts dialog */ public static synchronized String[] askForUsernameAndPassword(String message) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { } if (message == null || "".equals(message)) message = "Enter username/password to authenticate to OpenMRS..."; JPanel panel = new JPanel(new GridBagLayout()); JLabel usernameLabel = new JLabel("Username"); usernameLabel.setFont(font); usernameField = new JTextField(20); usernameField.setFont(font); JLabel passwordLabel = new JLabel("Password"); passwordLabel.setFont(font); JPasswordField passwordField = new JPasswordField(20); passwordField.setFont(font); panel.add(usernameLabel, new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 5, 0)); panel.add(usernameField, new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); panel.add(passwordLabel, new GridBagConstraints(0, 1, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 5, 0)); panel.add(passwordField, new GridBagConstraints(1, 1, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); frame = new JFrame(); Window window = new Window(frame); frame.setVisible(true); frame.setTitle("JUnit Test Credentials"); // We use a TimerTask to force focus on username, but still use // JOptionPane for model dialog TimerTask later = new TimerTask() { @Override public void run() { if (frame != null) { // bring the dialog's window to the front frame.toFront(); usernameField.grabFocus(); } } }; // try setting focus half a second from now new Timer().schedule(later, 500); // attention grabber for those people that aren't as observant TimerTask laterStill = new TimerTask() { @Override public void run() { if (frame != null) { frame.toFront(); // bring the dialog's window to the // front usernameField.grabFocus(); } } }; // if the user hasn't done anything in 10 seconds, tell them the window // is there new Timer().schedule(laterStill, 10000); // show the dialog box int response = JOptionPane.showConfirmDialog(window, panel, message, JOptionPane.OK_CANCEL_OPTION); // clear out the window so the timer doesn't screw up laterStill.cancel(); frame.setVisible(false); window.setVisible(false); frame = null; // response of 2 is the cancel button, response of -1 is the little red // X in the top right return (response == 2 || response == -1 ? null : new String[] { usernameField.getText(), String.valueOf(passwordField.getPassword()) }); }
From source file:org.openpnp.gui.AboutDialog.java
public AboutDialog(Frame frame) { super(frame, true); setTitle("About OpenPnP"); setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); setBounds(100, 100, 347, 360);//w w w .j a v a 2 s . c om getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, BorderLayout.CENTER); contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.Y_AXIS)); JLabel lblOpenpnp = new JLabel("OpenPnP"); lblOpenpnp.setAlignmentX(Component.CENTER_ALIGNMENT); lblOpenpnp.setFont(new Font("Lucida Grande", Font.BOLD, 32)); contentPanel.add(lblOpenpnp); JLabel lblCopyright = new JLabel("Copyright 2011 - 2016 Jason von Nieda"); lblCopyright.setFont(new Font("Lucida Grande", Font.PLAIN, 10)); lblCopyright.setAlignmentX(Component.CENTER_ALIGNMENT); contentPanel.add(lblCopyright); JLabel lblVersion = new JLabel("Version: " + Main.getVersion()); lblVersion.setFont(new Font("Lucida Grande", Font.PLAIN, 10)); lblVersion.setAlignmentX(Component.CENTER_ALIGNMENT); contentPanel.add(lblVersion); textPane = new JTextPane(); textPane.setEditable(false); contentPanel.add(new JScrollPane(textPane)); JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); getContentPane().add(buttonPane, BorderLayout.SOUTH); JButton okButton = new JButton("OK"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { setVisible(false); } }); okButton.setActionCommand("OK"); buttonPane.add(okButton); getRootPane().setDefaultButton(okButton); try { String s = FileUtils.readFileToString(new File("CHANGES.md")); textPane.setText(s); textPane.setCaretPosition(0); } catch (Exception e) { } }
From source file:org.openstatic.irc.client.O5Client.java
public O5Client() { super("O5 IRC"); this.chat_panels = new Hashtable<String, O5ChatPanel>(); this.server_panels = new Hashtable<String, O5ServerPanel>(); this.token_id = null; this.addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(WindowEvent winEvt) { System.exit(0);// w ww.ja v a 2 s . c o m } }); this.tabbed = new JTabbedPane(); JPanel main_pane = new JPanel(); main_pane.setLayout(new BorderLayout()); // Setup tab JPanel pane = new JPanel(new GridLayout(0, 2, 6, 6)); pane.setSize(50, 100); JLabel server_label = new JLabel("Server:", JLabel.TRAILING); server_field = new JTextField(15); server_field.setText("127.0.0.1:4050"); JLabel username_label = new JLabel("Username:", JLabel.TRAILING); username_field = new JTextField(15); JLabel password_label = new JLabel("Password:", JLabel.TRAILING); password_field = new JTextField(15); login_btn = new JButton("Connect"); login_btn.setActionCommand("login"); login_btn.addActionListener(this); pane.add(server_label); pane.add(server_field); pane.add(username_label); pane.add(username_field); pane.add(password_label); pane.add(password_field); pane.add(new JLabel("")); pane.add(login_btn); JPanel page_start = new JPanel(new BorderLayout()); JLabel page_header = new JLabel("O5 Client"); page_header.setFont(new Font("Monospaced", Font.BOLD, 36)); page_start.add(page_header, BorderLayout.PAGE_START); page_start.add(pane, BorderLayout.PAGE_END); main_pane.add(page_start, BorderLayout.PAGE_START); tabbed.addTab("Connect", null, main_pane, ""); // finish window this.add(tabbed); centerWindow(); this.setVisible(true); }
From source file:org.piraso.ui.base.PreferencePanel.java
private void initPreferenceComponentsVerticalChildLayout() { CellConstraints c = new CellConstraints(); int size = CollectionUtils.size(provider.getPreferences()); int l = 0, r = 2; chkPreferences = new JCheckBox[size]; preferenceKeys = new PreferenceProperty[size]; JLabel lblHeader = new JLabel(provider.getName()); Font of = lblHeader.getFont(); lblHeader.setFont(of.deriveFont(Font.BOLD)); pnlPreferences.add(lblHeader, c.xyw(2, r, 5)); r += 2;//from w w w .j a v a 2 s.c o m Iterator<? extends PreferenceProperty> itrp = provider.getPreferences().iterator(); for (int j = 0; j < provider.getPreferences().size(); j++, l++) { PreferenceProperty prop = itrp.next(); preferenceKeys[l] = prop; chkPreferences[l] = new JCheckBox(); chkPreferences[l].setText(provider.getMessage(prop.getName())); chkPreferences[l].setSelected(prop.isDefaultValue()); chkPreferences[l].addActionListener(new CheckBoxClickHandler(l)); if (prop.isParent()) { chkPreferences[l].setFont(chkPreferences[l].getFont().deriveFont(Font.BOLD)); } if (prop.isChild()) { pnlPreferences.add(chkPreferences[l], c.xy(6, r)); } else { pnlPreferences.add(chkPreferences[l], c.xyw(4, r, 3)); } r += 2; } }
From source file:org.piraso.ui.base.PreferencePanel.java
private void initPreferenceComponentsHorizontalChildLayout() { handlers = new ArrayList<ParentChildHandler>(); CellConstraints c = new CellConstraints(); int size = CollectionUtils.size(provider.getPreferences()); int l = 0, r = 2; chkPreferences = new JCheckBox[size]; preferenceKeys = new PreferenceProperty[size]; JLabel lblHeader = new JLabel(provider.getName()); Font of = lblHeader.getFont(); lblHeader.setFont(of.deriveFont(Font.BOLD)); pnlPreferences.add(lblHeader, c.xyw(2, r, 5)); r += 2;/* w ww.ja v a2s .c o m*/ JButton parentToggle = null; JPanel childrenPanel = null; ParentChildHandler parentChildHandler = null; Iterator<? extends PreferenceProperty> itrp = provider.getPreferences().iterator(); for (int j = 0; j < provider.getPreferences().size(); j++, l++) { PreferenceProperty prop = itrp.next(); preferenceKeys[l] = prop; chkPreferences[l] = new JCheckBox(); chkPreferences[l].setText(provider.getMessage(prop.getName())); chkPreferences[l].setSelected(prop.isDefaultValue()); if (prop.isChild()) { if (childrenPanel == null) { childrenPanel = new JPanel(); childrenPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 1, 1)); childrenPanel.setOpaque(false); childrenPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 1)); childrenPanel.setVisible(false); if (parentChildHandler != null) { parentChildHandler.setChildrenPanel(childrenPanel); } pnlPreferences.add(childrenPanel, c.xy(6, r)); r += 2; } if (parentChildHandler != null) { parentChildHandler.addPreference(chkPreferences[l]); } childrenPanel.add(chkPreferences[l]); parentToggle = null; } else { if (parentToggle != null) { parentChildHandler.hide(); } JPanel parentPanel = new JPanel(); parentPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 1, 1)); parentPanel.setOpaque(false); parentToggle = new JButton(expandImage); JLabel previewLabel = new JLabel(); previewLabel.setForeground(new Color(0, 128, 0)); previewLabel.setFont(previewLabel.getFont().deriveFont(Font.ITALIC)); parentChildHandler = new ParentChildHandler(parentToggle, previewLabel); parentChildHandler.addPreference(chkPreferences[l]); handlers.add(parentChildHandler); parentToggle.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0)); parentPanel.add(parentToggle); parentPanel.add(chkPreferences[l]); parentPanel.add(previewLabel); pnlPreferences.add(parentPanel, c.xyw(4, r, 3)); childrenPanel = null; r += 2; } chkPreferences[l].addActionListener(new CheckBoxClickHandler(l, parentChildHandler)); } }
From source file:org.processmining.analysis.performance.dottedchart.ui.MetricsPanel.java
/** * Displays the performance metrics of each pattern on the east side of the * plug-in window./*from w w w . j av a 2 s . c om*/ * * @param sortedArray * int[] */ public void displayPerformanceMetrics() { String type = dcPanel.getTimeOption(); ArrayList<DescriptiveStatistics> aList = dcModel.getTimeStatistics(); ArrayList<String> aTitles = dcModel.getDescriptiveStatisticsTitles(); ArrayList<String> sortedTitleList = dcModel.getSortedKeySetList(); this.removeAll(); this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); // add time option menu this.add(Box.createRigidArea(new Dimension(5, 10))); JPanel menuPanel = new JPanel(new BorderLayout()); menuPanel.setPreferredSize(new Dimension(160, 45)); menuPanel.setMaximumSize(new Dimension(180, 45)); timeSortLabel.setAlignmentX(LEFT_ALIGNMENT); menuPanel.add(timeSortLabel, BorderLayout.NORTH); timeBox.setMaximumSize(new Dimension(160, 20)); timeBox.setAlignmentX(LEFT_ALIGNMENT); menuPanel.add(Box.createRigidArea(new Dimension(5, 0))); menuPanel.add(timeBox, BorderLayout.CENTER); this.add(menuPanel); this.add(Box.createRigidArea(new Dimension(5, 10))); // for each frequency get the set of patterns that have that frequency // (run from high frequency to low) int size = 0; for (int i = 0; i < aList.size(); i++) { try { String key; DescriptiveStatistics currentDS = null; if (i != 0) key = sortedTitleList.get(i - 1); else { key = aTitles.get(0); currentDS = aList.get(i); } if (i > 0 && dcModel.getTypeHashMap().equals(DottedChartPanel.ST_INST) && !dcModel.getInstanceTypeToKeep().contains(key)) continue; size++; if (i > 0) { for (int j = 1; j < aTitles.size(); j++) { if (aTitles.get(j).equals(key)) currentDS = aList.get(j); } } AbstractTableModel otm; // create labels that contains information about the pattern if (i == 0) otm = new OverallMetricTableModel(); else otm = new OneMetricTableModel(); DefaultTableCellRenderer dtcr = new DefaultTableCellRenderer(); dtcr.setBackground(new Color(235, 235, 235)); JTable table = new JTable(otm); table.setPreferredSize(new Dimension(200, 55)); table.setMaximumSize(new Dimension(200, 55)); table.getColumnModel().getColumn(0).setPreferredWidth(70); table.getColumnModel().getColumn(0).setMaxWidth(100); table.getTableHeader().setFont(new Font("SansSerif", Font.PLAIN, 12)); table.getColumnModel().getColumn(0).setCellRenderer(dtcr); table.setBorder(BorderFactory.createEtchedBorder()); // place throughput times in table if (type.equals(DottedChartPanel.TIME_ACTUAL)) { if (i == 0) { table.setValueAt(DateFormat.getInstance().format(dcModel.getLogBoundaryLeft()), 0, 1); table.setValueAt(DateFormat.getInstance().format(dcModel.getLogBoundaryRight()), 1, 1); } else { table.setValueAt(DateFormat.getInstance().format(dcModel.getStartDateofLogUniList(key)), 0, 1); table.setValueAt(DateFormat.getInstance().format(dcModel.getEndDateofLogUniList(key)), 1, 1); } table.setValueAt(formatString(currentDS.getMean() / timeDivider, 5), 2, 1); table.setValueAt(formatString(currentDS.getMin() / timeDivider, 5), 3, 1); table.setValueAt(formatString(currentDS.getMax() / timeDivider, 5), 4, 1); } else if (type.equals(DottedChartPanel.TIME_RELATIVE_TIME)) { if (i == 0) { table.setValueAt(formatDate(dcModel.getLogBoundaryLeft()), 0, 1); table.setValueAt(formatDate(dcModel.getLogBoundaryRight()), 1, 1); } else { table.setValueAt(formatDate(dcModel.getStartDateofLogUniList(key)), 0, 1); table.setValueAt(formatDate(dcModel.getEndDateofLogUniList(key)), 1, 1); } table.setValueAt(formatString(currentDS.getMean() / timeDivider, 5), 2, 1); table.setValueAt(formatString(currentDS.getMin() / timeDivider, 5), 3, 1); table.setValueAt(formatString(currentDS.getMax() / timeDivider, 5), 4, 1); } else if (type.equals(DottedChartPanel.TIME_RELATIVE_RATIO)) { if (i == 0) { table.setValueAt(formatRatio(dcModel.getLogBoundaryLeft()), 0, 1); table.setValueAt(formatRatio(dcModel.getLogBoundaryRight()), 1, 1); } else { table.setValueAt(formatRatio(dcModel.getStartDateofLogUniList(key)), 0, 1); table.setValueAt(formatRatio(dcModel.getEndDateofLogUniList(key)), 1, 1); } table.setValueAt(formatString(currentDS.getMean() / 100, 5), 2, 1); table.setValueAt(formatString(currentDS.getMin() / 100, 5), 3, 1); table.setValueAt(formatString(currentDS.getMax() / 100, 5), 4, 1); } else if (type.equals(DottedChartPanel.TIME_LOGICAL) || type.equals(DottedChartPanel.TIME_LOGICAL_RELATIVE)) { if (i == 0) { table.setValueAt(formatString(dcModel.getLogBoundaryLeft().getTime(), 5), 0, 1); table.setValueAt(formatString(dcModel.getLogBoundaryRight().getTime(), 5), 1, 1); } else { table.setValueAt(formatString((dcModel.getStartDateofLogUniList(key)).getTime(), 5), 0, 1); table.setValueAt(formatString((dcModel.getEndDateofLogUniList(key)).getTime(), 5), 1, 1); } table.setValueAt(formatString(currentDS.getMean(), 5), 2, 1); table.setValueAt(formatString(currentDS.getMin(), 5), 3, 1); table.setValueAt(formatString(currentDS.getMax(), 5), 4, 1); } JPanel tempPanel = new JPanel(new BorderLayout()); table.setAlignmentX(CENTER_ALIGNMENT); tempPanel.setPreferredSize(new Dimension(160, 98)); tempPanel.setMaximumSize(new Dimension(180, 98)); tempPanel.add(table.getTableHeader(), BorderLayout.NORTH); tempPanel.add(table, BorderLayout.CENTER); JPanel tempPanel2 = new JPanel(new BorderLayout()); JLabel patternLabel = new JLabel("Component " + key + ":"); patternLabel.setAlignmentX(LEFT_ALIGNMENT); JLabel frequencyLabel = null; if (i == 0) frequencyLabel = new JLabel("# of components: " + currentDS.getN()); else frequencyLabel = new JLabel("# of dots: " + dcModel.getNumberOfLogUnits(key)); frequencyLabel.setAlignmentX(LEFT_ALIGNMENT); frequencyLabel.setFont(new Font("SansSerif", Font.PLAIN, 12)); tempPanel2.add(patternLabel, BorderLayout.NORTH); tempPanel2.add(frequencyLabel, BorderLayout.CENTER); tempPanel2.add(tempPanel, BorderLayout.SOUTH); this.add(tempPanel2); this.add(Box.createRigidArea(new Dimension(5, 10))); } catch (NullPointerException ex) { // can occur when patternMap does not contain a pattern with // this frequency size--; } } // make sure the pattern performance information is displayed properly this.setPreferredSize(new Dimension(200, 140 * (size + 1))); this.revalidate(); this.repaint(); }
From source file:org.prom5.analysis.performance.dottedchart.ui.MetricsPanel.java
/** * Displays the performance metrics of each pattern on the east side of the * plug-in window./* w w w . j a va 2 s . c o m*/ * @param sortedArray int[] */ public void displayPerformanceMetrics() { String type = dcPanel.getTimeOption(); ArrayList<DescriptiveStatistics> aList = dcModel.getTimeStatistics(); ArrayList<String> aTitles = dcModel.getDescriptiveStatisticsTitles(); ArrayList<String> sortedTitleList = dcModel.getSortedKeySetList(); this.removeAll(); this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); //add time option menu this.add(Box.createRigidArea(new Dimension(5, 10))); JPanel menuPanel = new JPanel(new BorderLayout()); menuPanel.setPreferredSize(new Dimension(160, 45)); menuPanel.setMaximumSize(new Dimension(180, 45)); timeSortLabel.setAlignmentX(LEFT_ALIGNMENT); menuPanel.add(timeSortLabel, BorderLayout.NORTH); timeBox.setMaximumSize(new Dimension(160, 20)); timeBox.setAlignmentX(LEFT_ALIGNMENT); menuPanel.add(Box.createRigidArea(new Dimension(5, 0))); menuPanel.add(timeBox, BorderLayout.CENTER); this.add(menuPanel); this.add(Box.createRigidArea(new Dimension(5, 10))); //for each frequency get the set of patterns that have that frequency //(run from high frequency to low) int size = 0; for (int i = 0; i < aList.size(); i++) { try { String key; DescriptiveStatistics currentDS = null; if (i != 0) key = sortedTitleList.get(i - 1); else { key = aTitles.get(0); currentDS = aList.get(i); } if (i > 0 && dcModel.getTypeHashMap().equals(DottedChartPanel.ST_INST) && !dcModel.getInstanceTypeToKeep().contains(key)) continue; size++; if (i > 0) { for (int j = 1; j < aTitles.size(); j++) { if (aTitles.get(j).equals(key)) currentDS = aList.get(j); } } AbstractTableModel otm; //create labels that contains information about the pattern if (i == 0) otm = new OverallMetricTableModel(); else otm = new OneMetricTableModel(); DefaultTableCellRenderer dtcr = new DefaultTableCellRenderer(); dtcr.setBackground(new Color(235, 235, 235)); JTable table = new JTable(otm); table.setPreferredSize(new Dimension(200, 55)); table.setMaximumSize(new Dimension(200, 55)); table.getColumnModel().getColumn(0).setPreferredWidth(70); table.getColumnModel().getColumn(0).setMaxWidth(100); table.getTableHeader().setFont(new Font("SansSerif", Font.PLAIN, 12)); table.getColumnModel().getColumn(0).setCellRenderer(dtcr); table.setBorder(BorderFactory.createEtchedBorder()); //place throughput times in table if (type.equals(DottedChartPanel.TIME_ACTUAL)) { if (i == 0) { table.setValueAt(DateFormat.getInstance().format(dcModel.getLogBoundaryLeft()), 0, 1); table.setValueAt(DateFormat.getInstance().format(dcModel.getLogBoundaryRight()), 1, 1); } else { table.setValueAt(DateFormat.getInstance().format(dcModel.getStartDateofLogUniList(key)), 0, 1); table.setValueAt(DateFormat.getInstance().format(dcModel.getEndDateofLogUniList(key)), 1, 1); } table.setValueAt(formatString(currentDS.getMean() / timeDivider, 5), 2, 1); table.setValueAt(formatString(currentDS.getMin() / timeDivider, 5), 3, 1); table.setValueAt(formatString(currentDS.getMax() / timeDivider, 5), 4, 1); } else if (type.equals(DottedChartPanel.TIME_RELATIVE_TIME)) { if (i == 0) { table.setValueAt(formatDate(dcModel.getLogBoundaryLeft()), 0, 1); table.setValueAt(formatDate(dcModel.getLogBoundaryRight()), 1, 1); } else { table.setValueAt(formatDate(dcModel.getStartDateofLogUniList(key)), 0, 1); table.setValueAt(formatDate(dcModel.getEndDateofLogUniList(key)), 1, 1); } table.setValueAt(formatString(currentDS.getMean() / timeDivider, 5), 2, 1); table.setValueAt(formatString(currentDS.getMin() / timeDivider, 5), 3, 1); table.setValueAt(formatString(currentDS.getMax() / timeDivider, 5), 4, 1); } else if (type.equals(DottedChartPanel.TIME_RELATIVE_RATIO)) { if (i == 0) { table.setValueAt(formatRatio(dcModel.getLogBoundaryLeft()), 0, 1); table.setValueAt(formatRatio(dcModel.getLogBoundaryRight()), 1, 1); } else { table.setValueAt(formatRatio(dcModel.getStartDateofLogUniList(key)), 0, 1); table.setValueAt(formatRatio(dcModel.getEndDateofLogUniList(key)), 1, 1); } table.setValueAt(formatString(currentDS.getMean() / 100, 5), 2, 1); table.setValueAt(formatString(currentDS.getMin() / 100, 5), 3, 1); table.setValueAt(formatString(currentDS.getMax() / 100, 5), 4, 1); } else if (type.equals(DottedChartPanel.TIME_LOGICAL) || type.equals(DottedChartPanel.TIME_LOGICAL_RELATIVE)) { if (i == 0) { table.setValueAt(formatString(dcModel.getLogBoundaryLeft().getTime(), 5), 0, 1); table.setValueAt(formatString(dcModel.getLogBoundaryRight().getTime(), 5), 1, 1); } else { table.setValueAt(formatString((dcModel.getStartDateofLogUniList(key)).getTime(), 5), 0, 1); table.setValueAt(formatString((dcModel.getEndDateofLogUniList(key)).getTime(), 5), 1, 1); } table.setValueAt(formatString(currentDS.getMean(), 5), 2, 1); table.setValueAt(formatString(currentDS.getMin(), 5), 3, 1); table.setValueAt(formatString(currentDS.getMax(), 5), 4, 1); } JPanel tempPanel = new JPanel(new BorderLayout()); table.setAlignmentX(CENTER_ALIGNMENT); tempPanel.setPreferredSize(new Dimension(160, 98)); tempPanel.setMaximumSize(new Dimension(180, 98)); tempPanel.add(table.getTableHeader(), BorderLayout.NORTH); tempPanel.add(table, BorderLayout.CENTER); JPanel tempPanel2 = new JPanel(new BorderLayout()); JLabel patternLabel = new JLabel("Component " + key + ":"); patternLabel.setAlignmentX(LEFT_ALIGNMENT); JLabel frequencyLabel = null; if (i == 0) frequencyLabel = new JLabel("# of components: " + currentDS.getN()); else frequencyLabel = new JLabel("# of dots: " + dcModel.getNumberOfLogUnits(key)); frequencyLabel.setAlignmentX(LEFT_ALIGNMENT); frequencyLabel.setFont(new Font("SansSerif", Font.PLAIN, 12)); tempPanel2.add(patternLabel, BorderLayout.NORTH); tempPanel2.add(frequencyLabel, BorderLayout.CENTER); tempPanel2.add(tempPanel, BorderLayout.SOUTH); this.add(tempPanel2); this.add(Box.createRigidArea(new Dimension(5, 10))); } catch (NullPointerException ex) { //can occur when patternMap does not contain a pattern with this frequency size--; } } //make sure the pattern performance information is displayed properly this.setPreferredSize(new Dimension(200, 140 * (size + 1))); this.revalidate(); this.repaint(); }
From source file:org.proteomecommons.tranche.modules.advancedsearch.AdvancedSearchPanel.java
public AdvancedSearchPanel(AdvancedGUI main) { this.main = main; this.setBackground(Color.WHITE); this.setBorder(Styles.BORDER_NONE); // Set the layout for the outer container this.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); // Set the layout for the inner container scrollablePanel.setLayout(new GridBagLayout()); scrollablePanel.setBackground(Color.WHITE); // Aids correct word wrap this.setSize(RECOMMENDED_DIMENSION); // Key words text {/*from w w w. j a v a2s .c o m*/ JLabel l = new JLabel("Keywords:"); l.setFont(Styles.FONT_11PT_BOLD); gbc.gridwidth = 1; gbc.anchor = gbc.FIRST_LINE_START; gbc.weightx = 0; gbc.weighty = 0; gbc.fill = gbc.NONE; gbc.insets = new Insets(MARGIN * 2, MARGIN, 0, 0); gbc.gridx = 0; // <-- Cell gbc.gridy = rowPtr; // <-- Row scrollablePanel.add(l, gbc); keywordText = new JTextField(); gbc.gridwidth = gbc.REMAINDER; gbc.anchor = gbc.FIRST_LINE_START; gbc.weightx = 1.0; gbc.weighty = 0; gbc.fill = gbc.HORIZONTAL; gbc.insets = new Insets(MARGIN * 2 - (5), MARGIN, 0, MARGIN); gbc.gridx = 1; // <-- Cell gbc.gridy = rowPtr; // <-- Row scrollablePanel.add(keywordText, gbc); rowPtr++; } // Journal drop down { JLabel l = new JLabel("Journal:"); l.setFont(Styles.FONT_11PT); gbc.gridwidth = 1; gbc.anchor = gbc.FIRST_LINE_START; gbc.weightx = 0; gbc.weighty = 0; gbc.fill = gbc.NONE; gbc.insets = new Insets(MARGIN, MARGIN, 0, 0); gbc.gridx = 0; // <-- Cell gbc.gridy = rowPtr; // <-- Row scrollablePanel.add(l, gbc); journalDropDown = new JComboBox(journalOptions); journalDropDown.setSelectedIndex(0); journalDropDown.setBackground(Color.WHITE); gbc.gridwidth = gbc.REMAINDER; gbc.anchor = gbc.FIRST_LINE_START; gbc.weightx = 1.0; gbc.weighty = 0; gbc.fill = gbc.HORIZONTAL; gbc.insets = new Insets(MARGIN - (5), MARGIN, 0, MARGIN); gbc.gridx = 1; // <-- Cell gbc.gridy = rowPtr; // <-- Row scrollablePanel.add(journalDropDown, gbc); rowPtr++; } // Research/Institute text { JLabel l = new JLabel("Researcher/Institute:"); l.setFont(Styles.FONT_11PT); gbc.gridwidth = 1; gbc.anchor = gbc.FIRST_LINE_START; gbc.weightx = 0; gbc.weighty = 0; gbc.fill = gbc.NONE; gbc.insets = new Insets(MARGIN, MARGIN, 0, 0); gbc.gridx = 0; // <-- Cell gbc.gridy = rowPtr; // <-- Row scrollablePanel.add(l, gbc); researcherText = new JTextField(); gbc.gridwidth = gbc.REMAINDER; gbc.anchor = gbc.FIRST_LINE_START; gbc.weightx = 1.0; gbc.weighty = 0; gbc.fill = gbc.HORIZONTAL; gbc.insets = new Insets(MARGIN - (5), MARGIN, 0, MARGIN); gbc.gridx = 1; // <-- Cell gbc.gridy = rowPtr; // <-- Row scrollablePanel.add(researcherText, gbc); rowPtr++; } // Organism text { JLabel l = new JLabel("Organism:"); l.setFont(Styles.FONT_11PT); gbc.gridwidth = 1; gbc.anchor = gbc.FIRST_LINE_START; gbc.weightx = 0; gbc.weighty = 0; gbc.fill = gbc.NONE; gbc.insets = new Insets(MARGIN, MARGIN, 0, 0); gbc.gridx = 0; // <-- Cell gbc.gridy = rowPtr; // <-- Row scrollablePanel.add(l, gbc); organismText = new JTextField(); gbc.gridwidth = gbc.REMAINDER; gbc.anchor = gbc.FIRST_LINE_START; gbc.weightx = 1.0; gbc.weighty = 0; gbc.fill = gbc.HORIZONTAL; gbc.insets = new Insets(MARGIN - (5), MARGIN, 0, MARGIN); gbc.gridx = 1; // <-- Cell gbc.gridy = rowPtr; // <-- Row scrollablePanel.add(organismText, gbc); rowPtr++; } // Ion source drop down { JLabel l = new JLabel("Ion Source:"); l.setFont(Styles.FONT_11PT); gbc.gridwidth = 1; gbc.anchor = gbc.FIRST_LINE_START; gbc.weightx = 0; gbc.weighty = 0; gbc.fill = gbc.NONE; gbc.insets = new Insets(MARGIN, MARGIN, 0, 0); gbc.gridx = 0; // <-- Cell gbc.gridy = rowPtr; // <-- Row scrollablePanel.add(l, gbc); ionSourceDropDown = new JComboBox(ionSourceOptions); ionSourceDropDown.setSelectedIndex(0); ionSourceDropDown.setBackground(Color.WHITE); gbc.gridwidth = gbc.REMAINDER; gbc.anchor = gbc.FIRST_LINE_START; gbc.weightx = 1.0; gbc.weighty = 0; gbc.fill = gbc.HORIZONTAL; gbc.insets = new Insets(MARGIN - (5), MARGIN, 0, MARGIN); gbc.gridx = 1; // <-- Cell gbc.gridy = rowPtr; // <-- Row scrollablePanel.add(ionSourceDropDown, gbc); rowPtr++; } // Instrument drop down { JLabel l = new JLabel("Instrument:"); l.setFont(Styles.FONT_11PT); gbc.gridwidth = 1; gbc.anchor = gbc.FIRST_LINE_START; gbc.weightx = 0; gbc.weighty = 0; gbc.fill = gbc.NONE; gbc.insets = new Insets(MARGIN, MARGIN, 0, 0); gbc.gridx = 0; // <-- Cell gbc.gridy = rowPtr; // <-- Row scrollablePanel.add(l, gbc); instrumentDropDown = new JComboBox(instrumentOptions); instrumentDropDown.setSelectedIndex(0); instrumentDropDown.setBackground(Color.WHITE); gbc.gridwidth = gbc.REMAINDER; gbc.anchor = gbc.FIRST_LINE_START; gbc.weightx = 1.0; gbc.weighty = 0; gbc.fill = gbc.HORIZONTAL; gbc.insets = new Insets(MARGIN - (5), MARGIN, 0, MARGIN); gbc.gridx = 1; // <-- Cell gbc.gridy = rowPtr; // <-- Row scrollablePanel.add(instrumentDropDown, gbc); rowPtr++; } // "Only return results with online data" check box { onlineResultsOnlyBox = new JCheckBox("Only return results with online data"); onlineResultsOnlyBox.setSelected(true); onlineResultsOnlyBox.setBackground(Color.WHITE); gbc.gridwidth = gbc.REMAINDER; gbc.anchor = gbc.FIRST_LINE_START; gbc.weightx = 1.0; gbc.weighty = 0; gbc.fill = gbc.HORIZONTAL; gbc.insets = new Insets(MARGIN, MARGIN, 0, MARGIN); gbc.gridx = 0; // <-- Cell gbc.gridy = rowPtr; // <-- Row scrollablePanel.add(onlineResultsOnlyBox, gbc); rowPtr++; } // Search button { searchButton = new JButton("Search"); searchButton.setFont(Styles.FONT_12PT_BOLD); gbc.gridwidth = gbc.REMAINDER; gbc.anchor = gbc.FIRST_LINE_START; gbc.weightx = 1.0; gbc.weighty = 0; gbc.fill = gbc.HORIZONTAL; gbc.insets = new Insets((MARGIN * 2), MARGIN, MARGIN, MARGIN); gbc.gridx = 0; // <-- Cell gbc.gridy = rowPtr; // <-- Row scrollablePanel.add(searchButton, gbc); rowPtr++; // Set the reset pointer so consequitive searches are layed out correctly. RESET_ROW_PTR = rowPtr; } // Create our first ephemeral component -- a vertical strut! { Component strut = Box.createVerticalStrut(1); gbc.gridwidth = gbc.REMAINDER; gbc.anchor = gbc.FIRST_LINE_START; gbc.weightx = 1.0; gbc.weighty = 1.0; gbc.fill = gbc.BOTH; gbc.insets = new Insets(0, 0, 0, 0); gbc.gridx = 0; // <-- Cell gbc.gridy = rowPtr; // <-- Row this.addEphemeralComponent(strut, gbc); } // Add scrollable panel to this GridBagConstraints scrollc = new GridBagConstraints(); scrollc.gridwidth = gbc.REMAINDER; scrollc.anchor = gbc.FIRST_LINE_START; scrollc.weightx = 1.0; scrollc.weighty = 1.0; scrollc.fill = gbc.BOTH; scrollc.insets = new Insets(0, 0, 0, 0); scrollc.gridx = 0; // <-- Cell scrollc.gridy = 0; // <-- Row this.add(new JScrollPane(scrollablePanel), scrollc); // Listeners searchButton.addActionListener(this); keywordText.addActionListener(this); researcherText.addActionListener(this); organismText.addActionListener(this); }