List of usage examples for javax.swing BorderFactory createTitledBorder
public static TitledBorder createTitledBorder(Border border)
From source file:JXTransformer.java
private JPanel createToolPanel() { JPanel panel = new JPanel(new GridLayout(1, 0)); rotationSlider = new JSlider(-180, 180, 0); rotationSlider.setLabelTable(rotationSlider.createStandardLabels(90, -180)); rotationSlider.setPaintLabels(true); rotationSlider.setPaintTicks(true); rotationSlider.setMajorTickSpacing(45); rotationSlider.addChangeListener(this); rotationSlider.setBorder(BorderFactory.createTitledBorder("Rotate")); panel.add(rotationSlider);//from w ww . j ava 2 s . co m shearingSlider = new JSlider(-10, 10, 0); shearingSlider.setLabelTable(shearingSlider.createStandardLabels(5, -10)); shearingSlider.setPaintLabels(true); shearingSlider.setPaintTicks(true); shearingSlider.setMajorTickSpacing(2); shearingSlider.addChangeListener(this); shearingSlider.setBorder(BorderFactory.createTitledBorder("Shear")); panel.add(shearingSlider); scalingSlider = new JSlider(50, 150, 100); scalingSlider.setLabelTable(scalingSlider.createStandardLabels(25, 50)); scalingSlider.setPaintLabels(true); scalingSlider.setPaintTicks(true); scalingSlider.setMajorTickSpacing(10); scalingSlider.addChangeListener(this); scalingSlider.setBorder(BorderFactory.createTitledBorder("Scale")); panel.add(scalingSlider); return panel; }
From source file:com.xilinx.kintex7.MainScreen.java
private JPanel testAndStats() { JPanel tstats = new JPanel(); tstats.setLayout(new BoxLayout(tstats, BoxLayout.Y_AXIS)); JPanel ledPanel = new JPanel(new BorderLayout()); JPanel iledPanel = new JPanel(); iledPanel.setLayout(new BoxLayout(iledPanel, BoxLayout.X_AXIS)); led_ddr3 = new JLabel("DDR3", new ImageIcon(led1), JLabel.CENTER); led_phy0 = new JLabel("10G PHY-0", new ImageIcon(led1), JLabel.CENTER); led_phy1 = new JLabel("10G PHY-1", new ImageIcon(led1), JLabel.CENTER); JPanel le1 = new JPanel(new BorderLayout()); le1.add(led_ddr3, BorderLayout.CENTER); JPanel le2 = new JPanel(new BorderLayout()); le2.add(led_phy0, BorderLayout.CENTER); JPanel le3 = new JPanel(new BorderLayout()); le3.add(led_phy1, BorderLayout.CENTER); iledPanel.add(le1);//from w w w . jav a 2s.c o m iledPanel.add(le2); iledPanel.add(le3); ledPanel.add(iledPanel, BorderLayout.CENTER); tstats.add(ledPanel); JPanel tstats1 = new JPanel(); tstats1.setLayout(new BoxLayout(tstats1, BoxLayout.Y_AXIS)); tstats1.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(""), BorderFactory.createRaisedBevelBorder())); tstats1.add(testPanelItems()); JPanel dmaInner = new JPanel(new BorderLayout()); JPanel dmaPanel = new JPanel(new BorderLayout()); dmaPanel.setBackground(new Color(130, 170, 180)); table1 = new MyTableModel(dummy_data, dmaColumnNames0); dmaStats1 = new JTable(table1); try { dmaStats1.setDefaultRenderer(Object.class, new CustomTableCellRenderer()); } catch (Exception e) { } JTableHeader dmaHeader = dmaStats1.getTableHeader(); dmaHeader.setForeground(new Color(92, 25, 25)); dmaPanel.add(dmaHeader, BorderLayout.PAGE_START); dmaPanel.add(dmaStats1, BorderLayout.CENTER); dmaInner.add(dmaPanel, BorderLayout.CENTER); tstats1.add(dmaInner); tstats.add(tstats1); JPanel trnPanel = new JPanel(new GridLayout(1, 1)); trnPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("PCIe Statistics"), BorderFactory.createRaisedBevelBorder())); JPanel trn1 = new JPanel(new FlowLayout()); trn1.add(new JLabel("Transmit (writes in Gbps): ")); trnLTX = new JTextField("0.0", 5); trnLTX.setEditable(false); trn1.add(trnLTX); trn1.add(new JLabel("Receive (reads in Gbps): ")); trnLRX = new JTextField("0.0", 5); trnLRX.setEditable(false); trn1.add(trnLRX); trnPanel.add(trn1); tstats.add(trnPanel); JPanel tstats2 = new JPanel(); tstats2.setLayout(new BoxLayout(tstats2, BoxLayout.Y_AXIS)); tstats2.add(testPanelItems1()); tstats2.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(""), BorderFactory.createRaisedBevelBorder())); JPanel dmaPanel1 = new JPanel(new BorderLayout()); table2 = new MyTableModel(dummy_data, dmaColumnNames1); dmaStats2 = new JTable(table2); try { dmaStats2.setDefaultRenderer(Object.class, new CustomTableCellRenderer()); } catch (Exception e) { } JTableHeader dmaHeader1 = dmaStats2.getTableHeader(); dmaHeader1.setForeground(new Color(92, 25, 25)); dmaPanel1.add(dmaHeader1, BorderLayout.PAGE_START); dmaPanel1.add(dmaStats2, BorderLayout.CENTER); tstats2.add(dmaPanel1); tstats.add(tstats2); JPanel tstats3 = new JPanel(new BorderLayout()); tstats3.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Message Log"), BorderFactory.createRaisedBevelBorder())); textArea = new CustomTextPane(); final JScrollPane scrollPane = new JScrollPane(textArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); // keep scrollbar at end showing latest messages scrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() { BoundedRangeModel brm = scrollPane.getVerticalScrollBar().getModel(); boolean wasAtBottom = true; @Override public void adjustmentValueChanged(AdjustmentEvent ae) { if (!brm.getValueIsAdjusting()) { if (wasAtBottom) brm.setValue(brm.getMaximum()); } else wasAtBottom = ((brm.getValue() + brm.getExtent()) == brm.getMaximum()); } }); textArea.setEditable(false); tstats3.add(scrollPane, BorderLayout.CENTER); tstats.add(tstats3); return tstats; }
From source file:davmail.ui.SettingsFrame.java
protected JPanel getOSXPanel() { JPanel osxSettingsPanel = new JPanel(new GridLayout(1, 2)); osxSettingsPanel.setBorder(BorderFactory.createTitledBorder(BundleMessage.format("UI_OSX"))); osxHideFromDockCheckBox = new JCheckBox(); osxHideFromDockCheckBox.setSelected(OSXInfoPlist.isHideFromDock()); addSettingComponent(osxSettingsPanel, BundleMessage.format("UI_OSX_HIDE_FROM_DOCK"), osxHideFromDockCheckBox, BundleMessage.format("UI_OSX_HIDE_FROM_DOCK_HELP")); updateMaximumSize(osxSettingsPanel); return osxSettingsPanel; }
From source file:lejos.pc.charting.LogChartFrame.java
/** All the setup of components, etc. What's scary is Swing is a "lightweight" GUI framework... * @throws Exception//from w ww .java 2s.co m */ private void jbInit() throws Exception { this.setJMenuBar(menuBar); this.setSize(new Dimension(819, 613)); this.setMinimumSize(new Dimension(819, 613)); this.setTitle("NXT Charting Logger"); this.setEnabled(true); // enforce minimum window size this.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { JFrame theFrame = (JFrame) e.getSource(); Dimension d1 = theFrame.getMinimumSize(); Dimension d2 = theFrame.getSize(); boolean enforce = false; if (theFrame.getWidth() < d1.getWidth()) { d2.setSize(d1.getWidth(), d2.getHeight()); enforce = true; } if (theFrame.getHeight() < d1.getHeight()) { d2.setSize(d2.getWidth(), d1.getHeight()); enforce = true; } if (enforce) theFrame.setSize(d2); } }); this.getContentPane().setLayout(gridBagLayout1); MenuActionListener menuItemActionListener = new MenuActionListener(); MenuEventListener menuListener = new MenuEventListener(); menu = new JMenu("Edit"); menu.setMnemonic(KeyEvent.VK_E); menuBar.add(menu); menuItem = new JMenuItem("Copy Chart Image", KeyEvent.VK_I); menuItem.addActionListener(menuItemActionListener); menu.add(menuItem); menuItem = new JMenuItem("Copy Data Log", KeyEvent.VK_D); menuItem.addActionListener(menuItemActionListener); menu.add(menuItem); menu = new JMenu("View"); menu.setMnemonic(KeyEvent.VK_V); menu.setActionCommand("VIEW_MENU"); menu.addMenuListener(menuListener); menuBar.add(menu); menuItem = new JMenuItem("Expand Chart", KeyEvent.VK_F); menuItem.addActionListener(menuItemActionListener); menu.add(menuItem); menuItem = new JMenuItem("Chart in New Window", KeyEvent.VK_N); menuItem.addActionListener(menuItemActionListener); menu.add(menuItem); menu = new JMenu("Help"); menu.setMnemonic(KeyEvent.VK_H); menuBar.add(menu); menuItem = new JMenuItem("Chart controls", KeyEvent.VK_C); menuItem.addActionListener(menuItemActionListener); menu.add(menuItem); menuItem = new JMenuItem("Generate sample data", KeyEvent.VK_G); menuItem.addActionListener(menuItemActionListener); menu.add(menuItem); menuItem = new JMenuItem("About", KeyEvent.VK_A); menuItem.addActionListener(menuItemActionListener); jTabbedPane1.setPreferredSize(new Dimension(621, 199)); jTabbedPane1.setMinimumSize(new Dimension(621, 199)); menu.add(menuItem); jButtonConnect.setText("Connect"); jButtonConnect.setBounds(new Rectangle(25, 65, 115, 25)); jButtonConnect.setToolTipText("Connect/disconnect toggle"); jButtonConnect.setMnemonic('C'); jButtonConnect.setSelected(true); jButtonConnect.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jButtonConnect_actionPerformed(e); } }); UIPanel.setSize(new Dimension(820, 200)); UIPanel.setLayout(null); UIPanel.setPreferredSize(new Dimension(300, 200)); UIPanel.setMinimumSize(new Dimension(300, 200)); UIPanel.setBounds(new Rectangle(0, 350, 820, 200)); UIPanel.setMaximumSize(new Dimension(300, 32767)); connectionPanel.setBounds(new Rectangle(10, 10, 175, 100)); connectionPanel.setBorder(BorderFactory.createTitledBorder("Connection")); connectionPanel.setLayout(null); connectionPanel.setFont(new Font("Tahoma", 0, 11)); jLabel1logfilename.setText("Log File:"); jLabel1logfilename.setBounds(new Rectangle(10, 125, 165, 20)); jLabel1logfilename.setHorizontalTextPosition(SwingConstants.RIGHT); jLabel1logfilename.setHorizontalAlignment(SwingConstants.LEFT); jLabel1logfilename.setToolTipText("Specify the name of your log file here"); jTextFieldNXTName.setBounds(new Rectangle(5, 40, 165, 20)); jTextFieldNXTName.setToolTipText( "The name or Address of the NXT. Leave empty and the first one found will be used."); jTextFieldNXTName.requestFocus(); jTextAreaStatus.setLineWrap(true); jTextAreaStatus.setFont(new Font("Tahoma", 0, 11)); jTextAreaStatus.setWrapStyleWord(true); jTextAreaStatus.setBackground(SystemColor.window); dataLogTextArea.setLineWrap(false); dataLogTextArea.setFont(new Font("Tahoma", 0, 11)); dataLogTextArea.setBackground(SystemColor.window); FQPathTextArea.setBounds(new Rectangle(5, 170, 185, 40)); FQPathTextArea.setLineWrap(true); FQPathTextArea.setText(getCanonicalName(new File(".", ""))); FQPathTextArea.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); FQPathTextArea.setRows(2); FQPathTextArea.setFont(new Font("Tahoma", 0, 9)); FQPathTextArea.setOpaque(false); FQPathTextArea.setEditable(false); selectFolderButton.setText("Folder..."); selectFolderButton.setBounds(new Rectangle(120, 125, 70, 20)); selectFolderButton.setMargin(new Insets(1, 1, 1, 1)); selectFolderButton.setFocusable(false); selectFolderButton.setMnemonic('F'); selectFolderButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { selectFolderButton_actionPerformed(e); } }); // domain display limits GUI chartOptionsPanel.setLayout(null); chartDomLimitsPanel.setBounds(new Rectangle(5, 35, 180, 135)); chartDomLimitsPanel.setLayout(gridLayout1); chartDomLimitsPanel.setBorder(BorderFactory.createTitledBorder("Domain Display Limiting")); domainDisplayLimitSlider.setEnabled(false); domainDisplayLimitSlider.setMaximum(MAXDOMAIN_DATAPOINT_LIMIT); domainDisplayLimitSlider.setMinimum(MINDOMAIN_LIMIT); domainDisplayLimitSlider.setValue(MAXDOMAIN_DATAPOINT_LIMIT); domainDisplayLimitSlider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { domainDisplayLimitSlider_stateChanged(e); } }); useTimeRadioButton.setText("By Time"); useTimeRadioButton.setEnabled(false); useTimeRadioButton.setMnemonic('I'); useTimeRadioButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { domainDisplayLimitRadioButton_actionPerformed(e); } }); useDataPointsRadioButton.setText("By Data Points"); ButtonGroup bg1 = new ButtonGroup(); bg1.add(useTimeRadioButton); bg1.add(useDataPointsRadioButton); useDataPointsRadioButton.setSelected(true); useDataPointsRadioButton.setEnabled(false); useDataPointsRadioButton.setMnemonic('P'); useDataPointsRadioButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { domainDisplayLimitRadioButton_actionPerformed(e); } }); datasetLimitEnableCheckBox.setText("Enable"); datasetLimitEnableCheckBox.setRolloverEnabled(true); datasetLimitEnableCheckBox.setMnemonic('A'); datasetLimitEnableCheckBox.setToolTipText("Enable Domain Clipping"); datasetLimitEnableCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { datasetLimitEnableCheckBox_actionPerformed(e); } }); domainLimitLabel.setText(String.format("%1$,d datapoints", MAXDOMAIN_DATAPOINT_LIMIT).toString()); domainLimitLabel.setEnabled(false); gridLayout1.setRows(5); gridLayout1.setColumns(1); jLabel1.setText("Chart Title:"); jLabel1.setBounds(new Rectangle(200, 10, 85, 20)); jLabel1.setPreferredSize(new Dimension(115, 14)); jLabel2.setText("Range Axis 1 Label:"); jLabel2.setBounds(new Rectangle(200, 35, 115, 20)); jLabel2.setSize(new Dimension(115, 20)); jLabel3.setText("Range Axis 2 Label:"); jLabel3.setBounds(new Rectangle(200, 60, 115, 20)); jLabel3.setSize(new Dimension(115, 20)); jLabel4.setText("Range Axis 3 Label:"); jLabel4.setBounds(new Rectangle(200, 85, 115, 20)); jLabel4.setSize(new Dimension(115, 20)); jLabel6.setText("Range Axis 4 Label:"); jLabel6.setBounds(new Rectangle(200, 110, 115, 20)); jLabel6.setSize(new Dimension(115, 20)); titleLabelChangeNotifier notifier = new titleLabelChangeNotifier(); chartTitleTextField.setBounds(new Rectangle(315, 10, 290, 20)); chartTitleTextField.getDocument().addDocumentListener(notifier); axis1LabelTextField.setBounds(new Rectangle(315, 35, 290, 20)); axis1LabelTextField.getDocument().addDocumentListener(notifier); axis2LabelTextField.setBounds(new Rectangle(315, 60, 290, 20)); axis2LabelTextField.getDocument().addDocumentListener(notifier); axis3LabelTextField.setBounds(new Rectangle(315, 85, 290, 20)); axis3LabelTextField.getDocument().addDocumentListener(notifier); axis4LabelTextField.setBounds(new Rectangle(315, 110, 290, 20)); showCommentsCheckBox.setText("Show Comment Markers"); showCommentsCheckBox.setBounds(new Rectangle(200, 140, 185, 25)); showCommentsCheckBox.setToolTipText("Show/Hide any comment markers on the chart"); showCommentsCheckBox.setRolloverEnabled(true); showCommentsCheckBox.setSelected(true); showCommentsCheckBox.setMnemonic('M'); showCommentsCheckBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { customChartPanel.setCommentsVisible(e.getStateChange() == ItemEvent.SELECTED); } }); scrollDomainCheckBox.setText("Scroll Domain"); scrollDomainCheckBox.setBounds(new Rectangle(10, 5, 175, 20)); scrollDomainCheckBox.setSize(new Dimension(175, 25)); scrollDomainCheckBox.setSelected(true); scrollDomainCheckBox.setMnemonic('O'); scrollDomainCheckBox.setToolTipText("Checked to scroll domain as new data is received"); scrollDomainCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scrollDomainCheckBox_actionPerformed(e); } }); axis4LabelTextField.getDocument().addDocumentListener(notifier); logFileTextField.setBounds(new Rectangle(10, 145, 180, 20)); logFileTextField.setText("NXTData.txt"); logFileTextField.setPreferredSize(new Dimension(180, 20)); logFileTextField.setToolTipText("File name. Leave empty to not log to file."); statusScrollPane.setOpaque(false); dataLogScrollPane.setOpaque(false); customChartPanel.setMinimumSize(new Dimension(400, 300)); customChartPanel.setPreferredSize(new Dimension(812, 400)); jLabel5.setText("NXT Name/Address:"); jLabel5.setBounds(new Rectangle(5, 20, 160, 20)); jLabel5.setToolTipText(jTextFieldNXTName.getToolTipText()); jLabel5.setHorizontalTextPosition(SwingConstants.RIGHT); jLabel5.setHorizontalAlignment(SwingConstants.LEFT); connectionPanel.add(jTextFieldNXTName, null); connectionPanel.add(jButtonConnect, null); connectionPanel.add(jLabel5, null); dataLogScrollPane.setViewportView(dataLogTextArea); jTabbedPane1.addTab("Data Log", dataLogScrollPane); statusScrollPane.setViewportView(jTextAreaStatus); jTabbedPane1.addTab("Status", statusScrollPane); jTabbedPane1.addTab("Chart", chartOptionsPanel); chartDomLimitsPanel.add(datasetLimitEnableCheckBox, null); chartDomLimitsPanel.add(useDataPointsRadioButton, null); chartDomLimitsPanel.add(useTimeRadioButton, null); chartDomLimitsPanel.add(domainDisplayLimitSlider, null); chartDomLimitsPanel.add(domainLimitLabel, null); chartOptionsPanel.add(scrollDomainCheckBox, null); chartOptionsPanel.add(showCommentsCheckBox, null); chartOptionsPanel.add(axis4LabelTextField, null); chartOptionsPanel.add(axis3LabelTextField, null); chartOptionsPanel.add(axis2LabelTextField, null); chartOptionsPanel.add(axis1LabelTextField, null); chartOptionsPanel.add(chartTitleTextField, null); chartOptionsPanel.add(jLabel6, null); chartOptionsPanel.add(jLabel4, null); chartOptionsPanel.add(jLabel3, null); chartOptionsPanel.add(jLabel2, null); chartOptionsPanel.add(jLabel1, null); chartOptionsPanel.add(chartDomLimitsPanel, null); tglbtnpauseplay = new JToggleButton(""); tglbtnpauseplay.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (lpm == null) return; boolean doPause = false; if (e.getStateChange() == ItemEvent.SELECTED) { doPause = true; } lpm.setReaderPaused(doPause); } }); // tglbtnpauseplay.addChangeListener(new ChangeListener() { // public void stateChanged(ChangeEvent e) { // System.out.println(e.toString()); // //lpm.setReaderPaused(doPause) // } // }); tglbtnpauseplay .setSelectedIcon(new ImageIcon(LogChartFrame.class.getResource("/lejos/pc/charting/play.png"))); tglbtnpauseplay.setIcon(new ImageIcon(LogChartFrame.class.getResource("/lejos/pc/charting/pause.png"))); tglbtnpauseplay.setBounds(571, 135, 30, 30); chartOptionsPanel.add(tglbtnpauseplay); jTabbedPane1.setToolTipTextAt(0, "The tab-delimited log of the data sent from the NXT"); jTabbedPane1.setToolTipTextAt(1, "Status output"); jTabbedPane1.setToolTipTextAt(2, "Chart options"); jTabbedPane1.setMnemonicAt(0, KeyEvent.VK_D); jTabbedPane1.setMnemonicAt(1, KeyEvent.VK_S); jTabbedPane1.setMnemonicAt(2, KeyEvent.VK_T); this.getContentPane().add(customChartPanel, new GridBagConstraints(0, 0, 2, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); this.getContentPane().add(UIPanel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), -107, 0)); this.getContentPane().add(jTabbedPane1, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); UIPanel.add(connectionPanel, null); UIPanel.add(selectFolderButton, null); UIPanel.add(logFileTextField, null); UIPanel.add(jLabel1logfilename, null); UIPanel.add(FQPathTextArea, null); ActionListener taskPerformer = new ActionListener() { public void actionPerformed(ActionEvent evt) { String theData = null; for (;;) { theData = LogChartFrame.this.logDataQueue.poll(); if (theData == null) break; try { dataLogTextArea.getDocument().insertString(dataLogTextArea.getDocument().getLength(), theData, null); } catch (BadLocationException e) { System.out.print( "BadLocationException in datalog textarea updater thread:" + e.toString() + "\n"); } } } }; this.updateLogTextAreaTimer = new Timer(1000, taskPerformer); this.updateLogTextAreaTimer.start(); }
From source file:kr.ac.kaist.swrc.jhannanum.demo.GUIDemo.java
/** * Returns a panel for the input and output text areas. * /*from www . j av a2 s . c om*/ * @return a panel for the input and output text areas */ private JComponent createPaneCenter() { splitPaneBottom = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); JPanel panel = new JPanel(new GridLayout(1, 1)); panel.setBorder(BorderFactory.createTitledBorder("Input Text")); inputTextArea = new JTextArea(); JScrollPane scroll = new JScrollPane(); scroll.setViewportView(inputTextArea); panel.add(scroll); splitPaneBottom.setLeftComponent(panel); panel = new JPanel(new GridLayout(1, 1)); panel.setBorder(BorderFactory.createTitledBorder("Result")); outputTextArea = new JTextArea(); scroll = new JScrollPane(); scroll.setViewportView(outputTextArea); panel.add(scroll); splitPaneBottom.setRightComponent(panel); splitPaneBottom.setOneTouchExpandable(true); return splitPaneBottom; }
From source file:simulation.AureoZauleckAnsLab2.java
public static void DisplayTable(ArrayList<ArrayList> all, ArrayList percentages, String title) { JFrame frame = new JFrame(); //frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTable table = new JTable(); table.setModel(new DefaultTableModel((int) (all.size() + 2), 2)); table.setValueAt("VALUE LABELS", 0, 0); table.setValueAt("PERCENTAGE", 0, 1); table.setValueAt("TOTAL = 100%", (int) (all.size() + 1), 1); for (int i = 0; i < all.size(); i++) { table.setValueAt(all.get(i).get(0), i + 1, 0); table.setValueAt(new DecimalFormat("#.##").format(percentages.get(i)), i + 1, 1); }//from www. j a va 2 s . c om JScrollPane scrollPane = new JScrollPane(table); scrollPane.setBorder(BorderFactory.createTitledBorder(title)); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 150); frame.setVisible(true); }
From source file:org.fhcrc.cpl.viewer.quant.gui.QuantitationReviewer.java
/** * Update lots of UI components after a change of quantitation event *///from ww w. j a va2 s .c o m protected void updateUIAfterChange(boolean shouldUpdateTable) { QuantEvent quantEvent = quantEvents.get(displayedEventIndex); if (displayedEventIndex > 0) backButton.setEnabled(true); else backButton.setEnabled(false); if (displayedEventIndex < quantEvents.size() - 1) forwardButton.setEnabled(true); else forwardButton.setEnabled(false); showEventSummaryButton.setEnabled(true); onePeakRatioRadioButton.setText("" + Rounder.round(quantEvent.getRatioOnePeak(), 2)); Enumeration<AbstractButton> quantButtons = quantCurationButtonGroup.getElements(); while (quantButtons.hasMoreElements()) quantButtons.nextElement().setEnabled(true); Enumeration<AbstractButton> idButtons = idCurationButtonGroup.getElements(); while (idButtons.hasMoreElements()) idButtons.nextElement().setEnabled(true); navigationPanel.setBorder(BorderFactory .createTitledBorder("Event " + (displayedEventIndex + 1) + " / " + quantEvents.size())); ButtonModel buttonModelToSelect = null; switch (quantEvent.getQuantCurationStatus()) { case QuantEvent.CURATION_STATUS_UNKNOWN: buttonModelToSelect = unknownRadioButtonModel; break; case QuantEvent.CURATION_STATUS_GOOD: buttonModelToSelect = goodRadioButtonModel; break; case QuantEvent.CURATION_STATUS_BAD: buttonModelToSelect = badRadioButtonModel; break; case QuantEvent.CURATION_STATUS_RATIO_ONEPEAK: buttonModelToSelect = onePeakRadioButtonModel; break; } quantCurationButtonGroup.setSelected(buttonModelToSelect, true); switch (quantEvent.getIdCurationStatus()) { case QuantEvent.CURATION_STATUS_UNKNOWN: buttonModelToSelect = idUnknownRadioButtonModel; break; case QuantEvent.CURATION_STATUS_GOOD: buttonModelToSelect = idGoodRadioButtonModel; break; case QuantEvent.CURATION_STATUS_BAD: buttonModelToSelect = idBadRadioButtonModel; break; } idCurationButtonGroup.setSelected(buttonModelToSelect, true); multiChartDisplay.setPreferredSize(new Dimension(rightPanel.getWidth(), rightPanel.getHeight())); multiChartDisplay.updateUI(); commentTextField.setText(quantEvent.getComment() != null ? quantEvent.getComment() : ""); commentTextField.setToolTipText( quantEvent.getComment() != null ? quantEvent.getComment() : "Comment on this event"); //dhmay danger of infinite loop here if (shouldUpdateTable) eventSummaryTable.getSelectionModel().setSelectionInterval(displayedEventIndex, displayedEventIndex); QuantEventAssessor.QuantEventAssessment assessment = quantEvent.getAlgorithmicAssessment(); if (assessment == null) { assessmentTypeTextField.setText(""); assessmentDescTextField.setText(""); assessmentTypeTextField.setBackground(Color.LIGHT_GRAY); } else { assessmentTypeTextField.setText(QuantEventAssessor.flagReasonDescriptions[assessment.getStatus()]); assessmentDescTextField.setText(assessment.getExplanation()); Color bgColor = assessmentPanel.getBackground(); switch (assessment.getStatus()) { case QuantEventAssessor.FLAG_REASON_UNEVALUATED: bgColor = Color.YELLOW; break; case QuantEventAssessor.FLAG_REASON_OK: bgColor = Color.GREEN; break; default: bgColor = Color.RED; break; } assessmentTypeTextField.setBackground(bgColor); } assessmentDescTextField.setToolTipText(assessmentDescTextField.getText()); showTheoreticalPeaks(); }
From source file:gda.gui.BatonPanel.java
private JPanel getPnlMessages() { if (pnlMessages == null) { pnlMessages = new JPanel(); BorderLayout pnlMessagesLayout = new BorderLayout(); pnlMessages.setLayout(pnlMessagesLayout); pnlMessages.setBorder(BorderFactory.createTitledBorder("Messages")); pnlMessages.setPreferredSize(new java.awt.Dimension(17, 431)); // pnlMessages.setPreferredSize(new java.awt.Dimension(333, 389)); pnlMessages.add(getMessageSendPnl(), BorderLayout.NORTH); pnlMessages.add(getLogScrollPane(), BorderLayout.CENTER); pnlMessages.setVisible(false);/* w w w. j av a 2 s . c o m*/ } return pnlMessages; }
From source file:simulation.AureoZauleckAnsLab2.java
public static void DisplayTables(double k, ArrayList<Double> cl, ArrayList<Double> cl2, ArrayList<Double> tlcl, ArrayList<Double> tucl, ArrayList<Double> midList, ArrayList<ArrayList<Double>> freq, ArrayList<Double> freqPercent, ArrayList<Double> cfs, ArrayList<Double> cps, String title) { JFrame frame = new JFrame(); //frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTable table = new JTable(); table.setModel(new DefaultTableModel((int) (k + 2), 7)); table.setValueAt("CLASS LIMITS", 0, 0); table.setValueAt("TRUE CLASS LIMITS", 0, 1); table.setValueAt("MIDPOINTS", 0, 2); table.setValueAt("FREQUENCY", 0, 3); table.setValueAt("%", 0, 4); table.setValueAt("CF", 0, 5); table.setValueAt("C%", 0, 6); table.setValueAt("n = " + N, (int) (k + 1), 3); table.setValueAt("TOTAL = 100%", (int) (k + 1), 4); for (int i = 0; i < k; i++) { table.setValueAt(cl.get(i) + " - " + cl2.get(i), i + 1, 0); table.setValueAt(tlcl.get(i) + " - " + tucl.get(i), i + 1, 1); table.setValueAt(midList.get(i), i + 1, 2); table.setValueAt(freq.get(i).size(), i + 1, 3); table.setValueAt(new DecimalFormat("#.##").format(freqPercent.get(i)), i + 1, 4); table.setValueAt(cfs.get(i), i + 1, 5); table.setValueAt(new DecimalFormat("#.##").format(cps.get(i)), i + 1, 6); }/*from w w w . j a va2 s.c o m*/ JScrollPane scrollPane = new JScrollPane(table); scrollPane.setBorder(BorderFactory.createTitledBorder(title)); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 150); frame.setVisible(true); Scanner sc = new Scanner(System.in); int type = 0, testT = 0; String typeTest = ""; do { System.out.println(); System.out.println("COLLAPSE CLASS LIMITS?"); System.out.println("[1] COLLAPSE LOWER CLASS LIMIT"); System.out.println("[2] COLLAPSE UPPPER CLASS LIMIT"); System.out.println("[3] COLLAPSE BOTH"); System.out.println("[4] DON'T COLLAPSE"); System.out.println(); System.out.println("Please pick a number from the choices above."); typeTest = sc.next(); if (IsNumber(typeTest)) { testT = Convert(typeTest); } else { do { System.out.println("Please enter a number only."); typeTest = sc.next(); } while (!IsNumber(typeTest)); testT = Convert(typeTest); } type = testT; } while (type < 1 || type > 4); if (type == 1) { JFrame frame2 = new JFrame(); //frame2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTable table2 = new JTable(); table2.setModel(new DefaultTableModel((int) (k + 2), 7)); table2.setValueAt("CLASS LIMITS", 0, 0); table2.setValueAt("TRUE CLASS LIMITS", 0, 1); table2.setValueAt("MIDPOINTS", 0, 2); table2.setValueAt("FREQUENCY", 0, 3); table2.setValueAt("%", 0, 4); table2.setValueAt("CF", 0, 5); table2.setValueAt("C%", 0, 6); table2.setValueAt("n = " + N, (int) (k + 1), 3); table2.setValueAt("TOTAL = 100%", (int) (k + 1), 4); for (int i = 0; i < k; i++) { table2.setValueAt(cl.get(i) + " - " + cl2.get(i), i + 1, 0); table2.setValueAt(tlcl.get(i) + " - " + tucl.get(i), i + 1, 1); table2.setValueAt(midList.get(i), i + 1, 2); table2.setValueAt(freq.get(i).size(), i + 1, 3); table2.setValueAt(new DecimalFormat("#.##").format(freqPercent.get(i)), i + 1, 4); table2.setValueAt(cfs.get(i), i + 1, 5); table2.setValueAt(new DecimalFormat("#.##").format(cps.get(i)), i + 1, 6); } table2.setValueAt("below " + cl2.get(0), 1, 0); table2.setValueAt(" - ", 1, 1); table2.setValueAt(" - ", 1, 2); JScrollPane scrollPane2 = new JScrollPane(table2); scrollPane2.setBorder(BorderFactory.createTitledBorder(title)); frame2.add(scrollPane2, BorderLayout.CENTER); frame2.setSize(300, 150); frame2.setVisible(true); } else if (type == 2) { JFrame frame3 = new JFrame(); //frame3.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTable table3 = new JTable(); table3.setModel(new DefaultTableModel((int) (k + 2), 7)); table3.setValueAt("CLASS LIMITS", 0, 0); table3.setValueAt("TRUE CLASS LIMITS", 0, 1); table3.setValueAt("MIDPOINTS", 0, 2); table3.setValueAt("FREQUENCY", 0, 3); table3.setValueAt("%", 0, 4); table3.setValueAt("CF", 0, 5); table3.setValueAt("C%", 0, 6); table3.setValueAt("n = " + N, (int) (k + 1), 3); table3.setValueAt("TOTAL = 100%", (int) (k + 1), 4); int a = (int) k; for (int i = 0; i < k; i++) { table3.setValueAt(cl.get(i) + " - " + cl2.get(i), i + 1, 0); table3.setValueAt(tlcl.get(i) + " - " + tucl.get(i), i + 1, 1); table3.setValueAt(midList.get(i), i + 1, 2); table3.setValueAt(freq.get(i).size(), i + 1, 3); table3.setValueAt(new DecimalFormat("#.##").format(freqPercent.get(i)), i + 1, 4); table3.setValueAt(cfs.get(i), i + 1, 5); table3.setValueAt(new DecimalFormat("#.##").format(cps.get(i)), i + 1, 6); } table3.setValueAt(cl.get(a - 1) + " above", a, 0); table3.setValueAt(" - ", a, 1); table3.setValueAt(" - ", a, 2); JScrollPane scrollPane3 = new JScrollPane(table3); scrollPane3.setBorder(BorderFactory.createTitledBorder(title)); frame3.add(scrollPane3, BorderLayout.CENTER); frame3.setSize(300, 150); frame3.setVisible(true); } else if (type == 3) { JFrame frame4 = new JFrame(); //frame4.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTable table4 = new JTable(); table4.setModel(new DefaultTableModel((int) (k + 2), 7)); table4.setValueAt("CLASS LIMITS", 0, 0); table4.setValueAt("TRUE CLASS LIMITS", 0, 1); table4.setValueAt("MIDPOINTS", 0, 2); table4.setValueAt("FREQUENCY", 0, 3); table4.setValueAt("%", 0, 4); table4.setValueAt("CF", 0, 5); table4.setValueAt("C%", 0, 6); table4.setValueAt("n = " + N, (int) (k + 1), 3); table4.setValueAt("TOTAL = 100%", (int) (k + 1), 4); int a = (int) k; for (int i = 0; i < k; i++) { table4.setValueAt(cl.get(i) + " - " + cl2.get(i), i + 1, 0); table4.setValueAt(tlcl.get(i) + " - " + tucl.get(i), i + 1, 1); table4.setValueAt(midList.get(i), i + 1, 2); table4.setValueAt(freq.get(i).size(), i + 1, 3); table4.setValueAt(new DecimalFormat("#.##").format(freqPercent.get(i)), i + 1, 4); table4.setValueAt(cfs.get(i), i + 1, 5); table4.setValueAt(new DecimalFormat("#.##").format(cps.get(i)), i + 1, 6); } table4.setValueAt("below " + cl2.get(0), 1, 0); table4.setValueAt(cl.get(a - 1) + " above", a, 0); table4.setValueAt(" - ", 1, 1); table4.setValueAt(" - ", 1, 2); table4.setValueAt(" - ", a, 1); table4.setValueAt(" - ", a, 2); JScrollPane scrollPane4 = new JScrollPane(table4); scrollPane4.setBorder(BorderFactory.createTitledBorder(title)); frame4.add(scrollPane4, BorderLayout.CENTER); frame4.setSize(300, 150); frame4.setVisible(true); } else { } }
From source file:davmail.ui.SettingsFrame.java
protected JPanel getLoggingSettingsPanel() { JPanel loggingLevelPanel = new JPanel(); JPanel leftLoggingPanel = new JPanel(new GridLayout(2, 2)); JPanel rightLoggingPanel = new JPanel(new GridLayout(2, 2)); loggingLevelPanel.add(leftLoggingPanel); loggingLevelPanel.add(rightLoggingPanel); rootLoggingLevelField = new JComboBox(LOG_LEVELS); davmailLoggingLevelField = new JComboBox(LOG_LEVELS); httpclientLoggingLevelField = new JComboBox(LOG_LEVELS); wireLoggingLevelField = new JComboBox(LOG_LEVELS); logFilePathField = new JTextField(Settings.getProperty("davmail.logFilePath"), 15); logFileSizeField = new JTextField(Settings.getProperty("davmail.logFileSize"), 15); rootLoggingLevelField.setSelectedItem(Settings.getLoggingLevel("rootLogger")); davmailLoggingLevelField.setSelectedItem(Settings.getLoggingLevel("davmail")); httpclientLoggingLevelField.setSelectedItem(Settings.getLoggingLevel("org.apache.commons.httpclient")); wireLoggingLevelField.setSelectedItem(Settings.getLoggingLevel("httpclient.wire")); addSettingComponent(leftLoggingPanel, BundleMessage.format("UI_LOG_DEFAULT"), rootLoggingLevelField); addSettingComponent(leftLoggingPanel, BundleMessage.format("UI_LOG_DAVMAIL"), davmailLoggingLevelField); addSettingComponent(rightLoggingPanel, BundleMessage.format("UI_LOG_HTTPCLIENT"), httpclientLoggingLevelField); addSettingComponent(rightLoggingPanel, BundleMessage.format("UI_LOG_WIRE"), wireLoggingLevelField); JPanel logFilePathPanel = new JPanel(new GridLayout(2, 2)); addSettingComponent(logFilePathPanel, BundleMessage.format("UI_LOG_FILE_PATH"), logFilePathField); addSettingComponent(logFilePathPanel, BundleMessage.format("UI_LOG_FILE_SIZE"), logFileSizeField); JButton defaultButton = new JButton(BundleMessage.format("UI_BUTTON_DEFAULT")); defaultButton.setToolTipText(BundleMessage.format("UI_BUTTON_DEFAULT_HELP")); defaultButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { rootLoggingLevelField.setSelectedItem(Level.WARN); davmailLoggingLevelField.setSelectedItem(Level.DEBUG); httpclientLoggingLevelField.setSelectedItem(Level.WARN); wireLoggingLevelField.setSelectedItem(Level.WARN); }/* w w w . jav a 2 s. com*/ }); JPanel loggingPanel = new JPanel(); loggingPanel.setLayout(new BoxLayout(loggingPanel, BoxLayout.Y_AXIS)); loggingPanel.setBorder(BorderFactory.createTitledBorder(BundleMessage.format("UI_LOGGING_LEVELS"))); loggingPanel.add(logFilePathPanel); loggingPanel.add(loggingLevelPanel); loggingPanel.add(defaultButton); updateMaximumSize(loggingPanel); return loggingPanel; }