List of usage examples for javax.swing JScrollPane setSize
public void setSize(int width, int height)
From source file:com.plugin.UI.Windows.BiblePeopleSearchResultsDialog.java
/** * Initialize.// w w w.j a va 2 s .c o m * * @param _term the _term * * @throws Exception the exception */ private void initialize(String _term) throws Exception { ArrayList<String[]> arr = new ArrayList<String[]>(); for (BiblePerson bp : Global.biblePersons) { if (isSoundexCalc(bp.getName().toUpperCase(), _term)) { String[] arrin = new String[5]; arrin[0] = String.valueOf(bp.getName_id()); arrin[1] = bp.getName(); arrin[2] = bp.getFather(); arrin[3] = bp.getMother(); arrin[4] = bp.getBible_ref(); arr.add(arrin); } } String[][] arr3 = new String[arr.size()][5]; for (int i = 0; i < arr.size(); i++) arr3[i] = arr.get(i); String columns[] = new String[] { "ID", "Name", "Father", "Mother", "Reference" }; tm = new DefaultTableModel(arr3, columns) { public boolean isCellEditable(int row, int column) { return false; } }; table = new JTable(tm); table.addMouseListener(new MouseListener() { public void mouseClicked(MouseEvent e) { int member_id = Integer.parseInt((String) tm.getValueAt(table.getSelectedRow(), 0)); BibleGenealogy.setSelectMember(member_id); if (e.getClickCount() == 2) { new BiblePersonDialog(Global._jMainFrame, member_id); } } public void mouseEntered(MouseEvent e) { // TODO Auto-generated method stub } public void mouseExited(MouseEvent e) { // TODO Auto-generated method stub } public void mousePressed(MouseEvent e) { // TODO Auto-generated method stub } public void mouseReleased(MouseEvent e) { // TODO Auto-generated method stub } }); JScrollPane jsp = new JScrollPane(table); jsp.setSize(640, 260); this.getContentPane().add(jsp); this.pack(); this.setTitle("Bible People Search Results - " + _term); this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); this.setLocationRelativeTo(null); this.setVisible(true); }
From source file:com.plugin.UI.Windows.UserSearchResultsDialog.java
/** * Initialize./* w ww.j a va 2s.c o m*/ * * @param _term the _term * * @throws Exception the exception */ private void initialize(String _term) throws Exception { ArrayList<String[]> arr = new ArrayList<String[]>(); for (ChurchMembersData mem : ChurchMemberUtils.getChurchMembers()) { if (isSoundex(mem, _term.toUpperCase())) { String[] arrin = new String[5]; arrin[0] = MemberID.getTranslatedID(mem.getMember_id(), mem.getName_english()); arrin[1] = mem.getName_english() + " (" + mem.getName_otherLang() + ")"; arrin[2] = mem.getStreet(); arrin[3] = mem.getSuburb(); arrin[4] = mem.getState(); arr.add(arrin); } } String[][] arr3 = new String[arr.size()][5]; for (int i = 0; i < arr.size(); i++) arr3[i] = arr.get(i); String columns[] = new String[] { "MemberID", "Name", "Street", "Suburb", "State" }; tm = new DefaultTableModel(arr3, columns) { public boolean isCellEditable(int row, int column) { return false; } }; table = new JTable(tm); table.addMouseListener(new MouseListener() { public void mouseClicked(MouseEvent e) { String member_id = (String) tm.getValueAt(table.getSelectedRow(), 0); ChurchMembers.setSelectMember(member_id); if (e.getClickCount() == 2) { new MemberDialog(Global.DISPLAY_CHURCH_MEMBER, MemberID.getOriginalID(member_id)); } } public void mouseEntered(MouseEvent e) { // TODO Auto-generated method stub } public void mouseExited(MouseEvent e) { // TODO Auto-generated method stub } public void mousePressed(MouseEvent e) { // TODO Auto-generated method stub } public void mouseReleased(MouseEvent e) { // TODO Auto-generated method stub } }); JScrollPane jsp = new JScrollPane(table); jsp.setSize(640, 260); this.getContentPane().add(jsp); this.pack(); this.setTitle("Church Members Search Results - " + _term); this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); this.setLocationRelativeTo(null); this.setVisible(true); }
From source file:ExpenseReport.java
public ExpenseReport() { super("Expense Report"); setSize(570, 200);/* w w w. j av a2 s . c o m*/ m_data = new ExpenseReportData(this); m_table = new JTable(); m_table.setAutoCreateColumnsFromModel(false); m_table.setModel(m_data); m_table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); for (int k = 0; k < ExpenseReportData.m_columns.length; k++) { TableCellRenderer renderer; if (k == ExpenseReportData.COL_APPROVED) renderer = new CheckCellRenderer(); else { DefaultTableCellRenderer textRenderer = new DefaultTableCellRenderer(); textRenderer.setHorizontalAlignment(ExpenseReportData.m_columns[k].m_alignment); renderer = textRenderer; } TableCellEditor editor; if (k == ExpenseReportData.COL_CATEGORY) editor = new DefaultCellEditor(new JComboBox(ExpenseReportData.CATEGORIES)); else if (k == ExpenseReportData.COL_APPROVED) editor = new DefaultCellEditor(new JCheckBox()); else editor = new DefaultCellEditor(new JTextField()); TableColumn column = new TableColumn(k, ExpenseReportData.m_columns[k].m_width, renderer, editor); m_table.addColumn(column); } JTableHeader header = m_table.getTableHeader(); header.setUpdateTableInRealTime(false); JScrollPane ps = new JScrollPane(); ps.setSize(550, 150); ps.getViewport().add(m_table); getContentPane().add(ps, BorderLayout.CENTER); JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); ImageIcon penny = new ImageIcon("penny.gif"); m_title = new JLabel("Total: $", penny, JButton.LEFT); m_title.setForeground(Color.black); m_title.setAlignmentY(0.5f); p.add(m_title); p.add(Box.createHorizontalGlue()); JButton bt = new JButton("Insert before"); bt.setMnemonic('b'); bt.setAlignmentY(0.5f); ActionListener lst = new ActionListener() { public void actionPerformed(ActionEvent e) { int row = m_table.getSelectedRow(); m_data.insert(row); m_table.tableChanged( new TableModelEvent(m_data, row, row, TableModelEvent.ALL_COLUMNS, TableModelEvent.INSERT)); m_table.repaint(); } }; bt.addActionListener(lst); p.add(bt); bt = new JButton("Insert after"); bt.setMnemonic('a'); bt.setAlignmentY(0.5f); lst = new ActionListener() { public void actionPerformed(ActionEvent e) { int row = m_table.getSelectedRow(); m_data.insert(row + 1); m_table.tableChanged(new TableModelEvent(m_data, row + 1, row + 1, TableModelEvent.ALL_COLUMNS, TableModelEvent.INSERT)); m_table.repaint(); } }; bt.addActionListener(lst); p.add(bt); bt = new JButton("Delete row"); bt.setMnemonic('d'); bt.setAlignmentY(0.5f); lst = new ActionListener() { public void actionPerformed(ActionEvent e) { int row = m_table.getSelectedRow(); if (m_data.delete(row)) { m_table.tableChanged(new TableModelEvent(m_data, row, row, TableModelEvent.ALL_COLUMNS, TableModelEvent.INSERT)); m_table.repaint(); calcTotal(); } } }; bt.addActionListener(lst); p.add(bt); getContentPane().add(p, BorderLayout.SOUTH); calcTotal(); WindowListener wndCloser = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(wndCloser); setVisible(true); }
From source file:ac.openmicrolabs.view.gui.OMLLoggerView.java
private JPanel createContentPane(final TimeSeriesCollection t, final String graphTitle, final double graphTimeRange, final String[] signals) { btmPanel.remove(reportButton);//w w w .ja va 2s.co m chanLabel = new JLabel[signals.length]; int activeSignalCount = 0; for (int i = 0; i < signals.length; i++) { chanLabel[i] = new JLabel(h.format("label", (char) ((i / PIN_COUNT) + ASCII_OFFSET) + "-0x" + String.format("%02x", (i % PIN_COUNT) + SLAVE_BITS).toUpperCase())); chanLabel[i].setHorizontalAlignment(JLabel.CENTER); if (signals[i] != null) { activeSignalCount++; } else { chanLabel[i].setEnabled(false); } } typeLabel = new JLabel[activeSignalCount]; valLabel = new JLabel[activeSignalCount]; minLabel = new JLabel[activeSignalCount]; maxLabel = new JLabel[activeSignalCount]; avgLabel = new JLabel[activeSignalCount]; int index = 0; for (int i = 0; i < signals.length; i++) { if (signals[i] != null) { typeLabel[index] = new JLabel(h.format("body", signals[i])); typeLabel[index].setHorizontalAlignment(JLabel.CENTER); index++; } } for (int i = 0; i < activeSignalCount; i++) { valLabel[i] = new JLabel(); valLabel[i].setHorizontalAlignment(JLabel.CENTER); minLabel[i] = new JLabel(); minLabel[i].setHorizontalAlignment(JLabel.CENTER); maxLabel[i] = new JLabel(); maxLabel[i].setHorizontalAlignment(JLabel.CENTER); avgLabel[i] = new JLabel(); avgLabel[i].setHorizontalAlignment(JLabel.CENTER); } // Set up main panel. JPanel mainPanel = new JPanel(); mainPanel.setLayout(null); mainPanel.setBackground(Color.white); // Create graph. snsChart = ChartFactory.createTimeSeriesChart(graphTitle, GRAPH_X_LABEL, GRAPH_Y_LABEL, t, true, true, false); final XYPlot plot = snsChart.getXYPlot(); ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true); axis.setFixedAutoRange(graphTimeRange); axis = plot.getRangeAxis(); axis.setRange(graphMinY, graphMaxY); ChartPanel snsChartPanel = new ChartPanel(snsChart); snsChartPanel.setPreferredSize(new Dimension(FRAME_WIDTH - PAD20, GRAPH_HEIGHT - PAD10)); // Set up graph panel. final JPanel graphPanel = new JPanel(); graphPanel.setSize(FRAME_WIDTH - PAD20, GRAPH_HEIGHT); graphPanel.setLocation(0, 0); graphPanel.setBackground(Color.white); graphPanel.add(snsChartPanel); // Set up results panel. final JPanel resultsPanel = createResultsPane(); // Set up scroll pane. final JScrollPane scrollPane = new JScrollPane(resultsPanel); scrollPane.setSize(FRAME_WIDTH - PAD20, FRAME_HEIGHT - BTM_HEIGHT - GRAPH_HEIGHT + PAD8); scrollPane.setLocation(PAD5, GRAPH_HEIGHT); scrollPane.setBackground(Color.white); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); // Set results panel size. resultsPanel.setPreferredSize(new Dimension(PAD40 + (signals.length * RESULTS_COL_WIDTH), FRAME_HEIGHT - BTM_HEIGHT - GRAPH_HEIGHT - PAD120)); resultsPanel.revalidate(); // Set up bottom panel. btmPanel.setLayout(null); btmPanel.setSize(FRAME_WIDTH, BTM_HEIGHT); btmPanel.setLocation(0, this.getHeight() - BTM_HEIGHT); btmPanel.setBackground(Color.white); // Instantiate bottom panel objects. footerLabel.setSize(LABEL_WIDTH, LABEL_HEIGHT); footerLabel.setLocation(LABEL_X, LABEL_Y); footerLabel.setText(""); doneButton.setIcon(new ImageIcon("img/22x22/stop.png")); doneButton.setSize(DONE_WIDTH, DONE_HEIGHT); doneButton.setLocation(FRAME_WIDTH - PAD20 - doneButton.getWidth(), PAD15); progressBar = new JProgressBar(); progressBar.setSize(FRAME_WIDTH - PAD40 - doneButton.getWidth() - footerLabel.getWidth(), PAD20); progressBar.setValue(0); progressBar.setLocation(footerLabel.getWidth() + PAD10, PAD22); // Populate bottom panel. btmPanel.add(footerLabel); btmPanel.add(progressBar); btmPanel.add(doneButton); // Populate main panel. mainPanel.add(graphPanel); mainPanel.add(scrollPane); mainPanel.add(btmPanel); return mainPanel; }
From source file:jmap2gml.ScriptGui.java
/** * Formats the window, initializes the JMap2Script object, and sets up all * the necessary events.//from ww w . j a v a 2 s. c o m */ public ScriptGui() { setTitle("jmap to gml script converter"); setDefaultCloseOperation(EXIT_ON_CLOSE); getContentPane().setLayout(new GridBagLayout()); this.addWindowListener(new WindowListener() { @Override public void windowOpened(WindowEvent we) { } @Override public void windowClosing(WindowEvent we) { saveConfig(); } @Override public void windowClosed(WindowEvent we) { } @Override public void windowIconified(WindowEvent we) { } @Override public void windowDeiconified(WindowEvent we) { } @Override public void windowActivated(WindowEvent we) { } @Override public void windowDeactivated(WindowEvent we) { } }); GridBagConstraints c = new GridBagConstraints(); setResizable(true); setIconImage((new ImageIcon("spikeup.png")).getImage()); jta = new JTextArea(38, 30); loadConfig(); JScrollPane jsp = new JScrollPane(jta); jsp.setRowHeaderView(new TextLineNumber(jta)); jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); jsp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); jsp.setSize(jsp.getWidth(), 608); // menu bar JMenuBar menubar = new JMenuBar(); // file menu JMenu file = new JMenu("File"); // load button JMenuItem load = new JMenuItem("Load jmap"); load.addActionListener(ae -> { JFileChooser fileChooser = new JFileChooser(prevDirectory); fileChooser.setFileFilter(new FileNameExtensionFilter("jmap file", "jmap", "jmap")); int returnValue = fileChooser.showOpenDialog(null); if (returnValue == JFileChooser.APPROVE_OPTION) { File selectedFile = fileChooser.getSelectedFile(); prevDirectory = selectedFile.getAbsolutePath(); jm2s = new ScriptFromJmap(selectedFile.getPath(), false); jta.setText(""); jta.append(jm2s.toString()); jta.setCaretPosition(0); writeFile.setEnabled(true); drawPanel.setItems(jta.getText().split("\n")); } }); // add load to file menu file.add(load); // button to save script to file writeFile = new JMenuItem("Write file"); writeFile.addActionListener(ae -> { if (jm2s != null) { PrintWriter out; try { File f = new File( jm2s.getFileName().substring(0, jm2s.getFileName().lastIndexOf(".jmap")) + ".gml"); out = new PrintWriter(f); out.append(jm2s.toString()); out.close(); } catch (FileNotFoundException ex) { Logger.getLogger(ScriptGui.class.getName()).log(Level.SEVERE, null, ex); } } }); writeFile.setEnabled(false); JMenuItem gmx = new JMenuItem("Export as gmx"); gmx.addActionListener(ae -> { String fn = String.format("%s.room.gmx", prevDirectory); JFileChooser fc = new JFileChooser(prevDirectory); fc.setSelectedFile(new File(fn)); fc.setFileFilter(new FileNameExtensionFilter("Game Maker XML", "gmx", "gmx")); fc.showDialog(null, "Save"); File f = fc.getSelectedFile(); if (f != null) { try { GMX.itemsToGMX(drawPanel.items, new FileOutputStream(f)); } catch (FileNotFoundException ex) { Logger.getLogger(ScriptGui.class.getName()).log(Level.SEVERE, null, ex); } } }); // add to file menu file.add(writeFile); file.add(gmx); // add file menu to the menubar menubar.add(file); // Edit menu // display menu JMenu display = new JMenu("Display"); JMenuItem update = new JMenuItem("Update"); update.addActionListener(ae -> { drawPanel.setItems(jta.getText().split("\n")); }); display.add(update); JMenuItem gridToggle = new JMenuItem("Toggle Grid"); gridToggle.addActionListener(ae -> { drawPanel.toggleGrid(); }); display.add(gridToggle); JMenuItem gridOptions = new JMenuItem("Modify Grid"); gridOptions.addActionListener(ae -> { drawPanel.modifyGrid(); }); display.add(gridOptions); menubar.add(display); // sets the menubar setJMenuBar(menubar); // add the text area to the window c.gridx = 0; c.gridy = 0; add(jsp, c); // initialize the preview panel drawPanel = new Preview(this); JScrollPane scrollPane = new JScrollPane(drawPanel); // add preview panel to the window c.gridx = 1; c.gridwidth = 2; add(scrollPane, c); pack(); setMinimumSize(this.getSize()); setLocationRelativeTo(null); setVisible(true); drawPanel.setItems(jta.getText().split("\n")); }
From source file:com.sshtools.common.ui.SshToolsApplication.java
public void openChangelog(Component parent) { JPanel p = new JPanel(new GridBagLayout()); p.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); GridBagConstraints gBC = new GridBagConstraints(); gBC.anchor = GridBagConstraints.CENTER; gBC.fill = GridBagConstraints.HORIZONTAL; gBC.insets = new Insets(1, 1, 1, 1); JLabel a = new JLabel(getApplicationName()); a.setFont(a.getFont().deriveFont(24f)); UIUtil.jGridBagAdd(p, a, gBC, GridBagConstraints.REMAINDER); String changelog = ""; try {/* www. j a v a2 s. co m*/ BufferedReader br = new BufferedReader( new InputStreamReader(getClass().getResourceAsStream("/changelog"))); String line = br.readLine(); while (line != null) { changelog += line + "\n"; line = br.readLine(); } br.close(); } catch (Exception e) { changelog = "<Error opening changelog>\n"; } javax.swing.JTextArea message = new javax.swing.JTextArea(changelog); message.setEditable(false); message.setBorder(javax.swing.BorderFactory.createEmptyBorder(4, 4, 4, 4)); javax.swing.JLabel jl = new javax.swing.JLabel(); message.setFont(jl.getFont()); message.setBackground(jl.getBackground()); // MultilineLabel x = new MultilineLabel(changelog); // x.setBorder(BorderFactory.createEmptyBorder(8, 0, 8, 0)); // x.setFont(x.getFont().deriveFont(12f)); javax.swing.JScrollPane scrollPane = new javax.swing.JScrollPane(); scrollPane.getViewport().add(message); scrollPane.setSize(400, 200); scrollPane.setPreferredSize(new java.awt.Dimension(400, 200)); UIUtil.jGridBagAdd(p, scrollPane, gBC, GridBagConstraints.REMAINDER); JOptionPane.showMessageDialog(parent, p, "Change log", JOptionPane.PLAIN_MESSAGE, getApplicationLargeIcon()); }
From source file:coreferenceresolver.gui.MarkupGUI.java
public MarkupGUI() throws IOException { highlightPainters = new ArrayList<>(); for (int i = 0; i < COLORS.length; ++i) { DefaultHighlighter.DefaultHighlightPainter highlightPainter = new DefaultHighlighter.DefaultHighlightPainter( COLORS[i]);/* w w w .j a v a2 s . c o m*/ highlightPainters.add(highlightPainter); } defaulPath = FileUtils.readFileToString(new File(".\\src\\coreferenceresolver\\gui\\defaultpath")); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setLayout(new BorderLayout()); this.setSize(java.awt.Toolkit.getDefaultToolkit().getScreenSize()); JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); //create menu items JMenuItem importMenuItem = new JMenuItem("Import"); JMenuItem exportMenuItem = new JMenuItem("Export"); fileMenu.add(importMenuItem); fileMenu.add(exportMenuItem); menuBar.add(fileMenu); this.setJMenuBar(menuBar); ScrollablePanel mainPanel = new ScrollablePanel(); mainPanel.setScrollableWidth(ScrollablePanel.ScrollableSizeHint.NONE); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); //IMPORT BUTTON importMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // MarkupGUI.reviewElements.clear(); // MarkupGUI.markupReviews.clear(); JFileChooser markupFileChooser = new JFileChooser(defaulPath); markupFileChooser.setDialogTitle("Choose your markup file"); markupFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); if (markupFileChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { final JDialog d = new JDialog(); JPanel p1 = new JPanel(new GridBagLayout()); p1.add(new JLabel("Please Wait..."), new GridBagConstraints()); d.getContentPane().add(p1); d.setSize(100, 100); d.setLocationRelativeTo(null); d.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); d.setModal(true); SwingWorker<?, ?> worker = new SwingWorker<Void, Void>() { protected Void doInBackground() throws IOException, BadLocationException { readMarkupFile(markupFileChooser.getSelectedFile().getAbsolutePath()); for (int i = 0; i < markupReviews.size(); ++i) { mainPanel.add(newReviewPanel(markupReviews.get(i), i)); } return null; } protected void done() { MarkupGUI.this.revalidate(); d.dispose(); } }; worker.execute(); d.setVisible(true); } else { return; } } }); //EXPORT BUTTON: GET NEW VALUE (REF, TYPE) OF NPs exportMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser markupFileChooser = new JFileChooser(defaulPath); markupFileChooser.setDialogTitle("Choose where your markup file saved"); markupFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (markupFileChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { final JDialog d = new JDialog(); JPanel p1 = new JPanel(new GridBagLayout()); p1.add(new JLabel("Please Wait..."), new GridBagConstraints()); d.getContentPane().add(p1); d.setSize(100, 100); d.setLocationRelativeTo(null); d.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); d.setModal(true); SwingWorker<?, ?> worker = new SwingWorker<Void, Void>() { protected Void doInBackground() throws IOException { for (Review review : markupReviews) { generateNPsRef(review); } int i = 0; for (ReviewElement reviewElement : reviewElements) { int j = 0; for (Element element : reviewElement.elements) { String newType = element.typeSpinner.getValue().toString(); if (newType.equals("Object")) { markupReviews.get(i).getNounPhrases().get(j).setType(0); } else if (newType.equals("Attribute")) { markupReviews.get(i).getNounPhrases().get(j).setType(3); } else if (newType.equals("Other")) { markupReviews.get(i).getNounPhrases().get(j).setType(1); } else if (newType.equals("Candidate")) { markupReviews.get(i).getNounPhrases().get(j).setType(2); } ++j; } ++i; } initMarkupFile(markupFileChooser.getSelectedFile().getAbsolutePath() + File.separator + "markup.out.txt"); return null; } protected void done() { d.dispose(); try { Desktop.getDesktop() .open(new File(markupFileChooser.getSelectedFile().getAbsolutePath())); } catch (IOException ex) { Logger.getLogger(MarkupGUI.class.getName()).log(Level.SEVERE, null, ex); } } }; worker.execute(); d.setVisible(true); } else { return; } } }); JScrollPane scrollMainPane = new JScrollPane(mainPanel); scrollMainPane.getVerticalScrollBar().setUnitIncrement(16); scrollMainPane.setPreferredSize(new Dimension(this.getWidth(), this.getHeight())); scrollMainPane.setSize(this.getWidth(), this.getHeight()); this.setResizable(false); this.add(scrollMainPane, BorderLayout.CENTER); this.setExtendedState(JFrame.MAXIMIZED_BOTH); this.pack(); }
From source file:org.fhcrc.cpl.viewer.quant.gui.ProteinQuantSummaryFrame.java
License:asdf
/** * Initialize the GUI components//from w w w. j av a 2s.c o m */ protected void initGUI() { //Global stuff setSize(fullWidth, fullHeight); eventPropertiesTable = new QuantEvent.QuantEventPropertiesTable(); eventPropertiesTable.setVisible(true); JScrollPane eventPropsScrollPane = new JScrollPane(); eventPropsScrollPane.setViewportView(eventPropertiesTable); eventPropsScrollPane.setSize(propertiesWidth, propertiesHeight); eventPropertiesDialog = new JDialog(this, "Event Properties"); eventPropertiesDialog.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); eventPropertiesDialog.setSize(propertiesWidth, propertiesHeight); eventPropertiesDialog.setContentPane(eventPropsScrollPane); ListenerHelper helper = new ListenerHelper(this); setTitle("Protein Summary"); setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.PAGE_START; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.insets = new Insets(5, 5, 5, 5); gbc.weighty = 1; gbc.weightx = 1; try { (getOwner()).setIconImage(ImageIO.read(WorkbenchFrame.class.getResourceAsStream("icon.gif"))); } catch (Exception e) { } try { Localizer.renderSwixml("org/fhcrc/cpl/viewer/quant/gui/ProteinQuantSummaryFrame.xml", this); assert null != contentPanel; setContentPane(contentPanel); } catch (Exception x) { ApplicationContext.errorMessage("error creating dialog", x); throw new RuntimeException(x); } buttonSelectAllVisible.setEnabled(false); helper.addListener(buttonSelectAllVisible, "buttonSelectAllVisible_actionPerformed"); buttonDeselectAll.setEnabled(false); helper.addListener(buttonDeselectAll, "buttonDeselectAll_actionPerformed"); buildTurkHITsButton.setEnabled(false); helper.addListener(buildTurkHITsButton, "buttonBuildTurkHITs_actionPerformed"); loadSelectedEventsButton.setEnabled(false); helper.addListener(loadSelectedEventsButton, "buttonLoadSelected_actionPerformed"); autoAssessSelectedEventsButton.setEnabled(false); helper.addListener(autoAssessSelectedEventsButton, "buttonAutoAssess_actionPerformed"); showPropertiesButton.setEnabled(false); helper.addListener(showPropertiesButton, "buttonShowProperties_actionPerformed"); showProteinRatiosButton.setEnabled(false); helper.addListener(showProteinRatiosButton, "buttonShowProteinRatios_actionPerformed"); //summary panel summaryPanel.setBorder(BorderFactory.createLineBorder(Color.gray)); summaryPanel.setPreferredSize(new Dimension(fullWidth, summaryPanelHeight)); summaryPanel.setMinimumSize(new Dimension(200, summaryPanelHeight)); gbc.fill = GridBagConstraints.NONE; gbc.gridwidth = 1; summaryPanel.add(buttonSelectAllVisible, gbc); summaryPanel.add(buttonDeselectAll, gbc); gbc.gridwidth = GridBagConstraints.RELATIVE; summaryPanel.add(showPropertiesButton, gbc); gbc.gridwidth = GridBagConstraints.REMAINDER; summaryPanel.add(showProteinRatiosButton, gbc); gbc.gridwidth = 1; summaryPanel.add(loadSelectedEventsButton, gbc); gbc.gridwidth = GridBagConstraints.RELATIVE; summaryPanel.add(autoAssessSelectedEventsButton, gbc); gbc.gridwidth = GridBagConstraints.REMAINDER; summaryPanel.add(buildTurkHITsButton, gbc); gbc.fill = GridBagConstraints.BOTH; eventsScrollPane = new JScrollPane(); eventsScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); eventsScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); eventsPanel = new JPanel(); eventsPanel.setLayout(new GridBagLayout()); eventsTable = new QuantEventsSummaryTable(); eventsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); eventsTable.getSelectionModel().addListSelectionListener(new EventsTableListSelectionHandler()); eventsScrollPane.setViewportView(eventsTable); eventsScrollPane.setMinimumSize(new Dimension(400, 400)); gbc.insets = new Insets(0, 0, 0, 0); mainPanel.add(eventsScrollPane, gbc); logRatioHistogramPanel = new PanelWithLogRatioHistAndFields(); logRatioHistogramPanel.setBorder(BorderFactory.createTitledBorder("Log Ratios")); logRatioHistogramPanel.setPreferredSize(new Dimension(width - 10, 300)); gbc.fill = GridBagConstraints.BOTH; gbc.weighty = 100; gbc.gridwidth = GridBagConstraints.REMAINDER; add(logRatioHistogramPanel, gbc); //status message messageLabel = new JLabel(); messageLabel.setBackground(Color.WHITE); messageLabel.setFont(Font.decode("verdana plain 12")); messageLabel.setText(" "); statusPanel = new JPanel(); gbc.weighty = 1; statusPanel.setPreferredSize(new Dimension(width - 10, 50)); statusPanel.add(messageLabel, gbc); add(statusPanel, gbc); //per-protein event summary table; disembodied //todo: move this into its own class? it's getting kind of complicated proteinRatiosTable = new JTable(); proteinRatiosTable.setVisible(true); ListSelectionModel proteinTableSelectionModel = proteinRatiosTable.getSelectionModel(); proteinTableSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); proteinTableSelectionModel.addListSelectionListener(new ProteinTableListSelectionHandler()); JScrollPane proteinRatiosScrollPane = new JScrollPane(); proteinRatiosScrollPane.setViewportView(proteinRatiosTable); proteinRatiosScrollPane.setPreferredSize(new Dimension(proteinDialogWidth, proteinDialogHeight - PROTEINTABLE_HISTPANEL_HEIGHT - PROTEINTABLE_SCATTERPLOTPANEL_HEIGHT - 70)); proteinRatiosDialog = new JDialog(this, "Protein Ratios"); proteinRatiosDialog.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); proteinRatiosDialog.setSize(proteinDialogWidth, proteinDialogHeight); JPanel proteinRatiosContentPanel = new JPanel(); gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.BOTH; proteinRatiosContentPanel.add(proteinRatiosScrollPane, gbc); proteinRatiosDialog.setContentPane(proteinRatiosContentPanel); perProteinLogRatioHistogramPanel = new PanelWithLogRatioHistAndFields(); perProteinLogRatioHistogramPanel.addRangeUpdateListener(new ProteinTableLogRatioHistogramListener()); perProteinLogRatioHistogramPanel.setBorder(BorderFactory.createTitledBorder("Log Ratios")); perProteinLogRatioHistogramPanel .setPreferredSize(new Dimension(proteinDialogWidth - 10, PROTEINTABLE_HISTPANEL_HEIGHT)); gbc.fill = GridBagConstraints.BOTH; gbc.gridwidth = GridBagConstraints.REMAINDER; proteinRatiosDialog.add(perProteinLogRatioHistogramPanel, gbc); perProteinPeptideLogRatioPanel = new JPanel(); perProteinPeptideLogRatioPanel.setBorder(BorderFactory.createTitledBorder("By Peptide")); perProteinPeptideLogRatioPanel .setPreferredSize(new Dimension(proteinDialogWidth - 10, PROTEINTABLE_SCATTERPLOTPANEL_HEIGHT)); proteinRatiosDialog.add(perProteinPeptideLogRatioPanel, gbc); }
From source file:org.fhcrc.cpl.viewer.quant.gui.QuantitationReviewer.java
/** * Initialize all GUI components and display the UI *///from www . ja va2s.c om protected void initGUI() { settingsCLM = new ProteinQuantChartsCLM(false); setTitle("Qurate"); try { setIconImage(ImageIO.read(WorkbenchFrame.class.getResourceAsStream("icon.gif"))); } catch (Exception e) { } try { Localizer.renderSwixml("org/fhcrc/cpl/viewer/quant/gui/QuantitationReviewer.xml", this); assert null != contentPanel; } catch (Exception x) { ApplicationContext.errorMessage("error creating dialog", x); throw new RuntimeException(x); } //Menu openFileAction = new OpenFileAction(this); createChartsAction = new CreateChartsAction(); filterPepXMLAction = new FilterPepXMLAction(this); proteinSummaryAction = new ProteinSummaryAction(this); try { JMenuBar jmenu = (JMenuBar) Localizer.getSwingEngine(this) .render("org/fhcrc/cpl/viewer/quant/gui/QuantitationReviewerMenu.xml"); for (int i = 0; i < jmenu.getMenuCount(); i++) jmenu.getMenu(i).getPopupMenu().setLightWeightPopupEnabled(false); this.setJMenuBar(jmenu); } catch (Exception x) { ApplicationContext.errorMessage(TextProvider.getText("ERROR_LOADING_MENUS"), x); throw new RuntimeException(x); } //Global stuff setSize(fullWidth, fullHeight); setContentPane(contentPanel); ListenerHelper helper = new ListenerHelper(this); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.PAGE_START; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.insets = new Insets(5, 5, 5, 5); gbc.weighty = 1; gbc.weightx = 1; leftPanel.setLayout(new GridBagLayout()); leftPanel.setBorder(BorderFactory.createLineBorder(Color.gray)); //Properties panel stuff propertiesTable = new QuantEvent.QuantEventPropertiesTable(); propertiesScrollPane = new JScrollPane(); propertiesScrollPane.setViewportView(propertiesTable); propertiesScrollPane.setMinimumSize(new Dimension(propertiesWidth, propertiesHeight)); //event summary table; disembodied eventSummaryTable = new QuantEventsSummaryTable(); eventSummaryTable.setVisible(true); ListSelectionModel tableSelectionModel = eventSummaryTable.getSelectionModel(); tableSelectionModel.addListSelectionListener(new EventSummaryTableListSelectionHandler()); JScrollPane eventSummaryScrollPane = new JScrollPane(); eventSummaryScrollPane.setViewportView(eventSummaryTable); eventSummaryScrollPane.setSize(propertiesWidth, propertiesHeight); eventSummaryFrame = new Frame("All Events"); eventSummaryFrame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent event) { eventSummaryFrame.setVisible(false); } }); eventSummaryFrame.setSize(950, 450); eventSummaryFrame.add(eventSummaryScrollPane); //fields related to navigation navigationPanel = new JPanel(); backButton = new JButton("<"); backButton.setToolTipText("Previous Event"); backButton.setMaximumSize(new Dimension(50, 30)); backButton.setEnabled(false); forwardButton = new JButton(">"); forwardButton.setToolTipText("Next Event"); forwardButton.setMaximumSize(new Dimension(50, 30)); forwardButton.setEnabled(false); showEventSummaryButton = new JButton("Show All"); showEventSummaryButton.setToolTipText("Show all events in a table"); showEventSummaryButton.setEnabled(false); helper.addListener(backButton, "buttonBack_actionPerformed"); helper.addListener(forwardButton, "buttonForward_actionPerformed"); helper.addListener(showEventSummaryButton, "buttonShowEventSummary_actionPerformed"); gbc.fill = GridBagConstraints.NONE; gbc.gridwidth = GridBagConstraints.RELATIVE; gbc.anchor = GridBagConstraints.WEST; navigationPanel.add(backButton, gbc); gbc.gridwidth = GridBagConstraints.RELATIVE; navigationPanel.add(forwardButton, gbc); gbc.gridwidth = GridBagConstraints.REMAINDER; navigationPanel.add(showEventSummaryButton, gbc); gbc.fill = GridBagConstraints.BOTH; navigationPanel.setBorder(BorderFactory.createTitledBorder("Event")); gbc.anchor = GridBagConstraints.PAGE_START; //Fields related to curation of events curationPanel = new JPanel(); curationPanel.setLayout(new GridBagLayout()); curationPanel.setBorder(BorderFactory.createTitledBorder("Curation")); //Quantitation curation JPanel quantCurationPanel = new JPanel(); quantCurationPanel.setLayout(new GridBagLayout()); quantCurationPanel.setBorder(BorderFactory.createTitledBorder("Quantitation")); quantCurationButtonGroup = new ButtonGroup(); JRadioButton unknownRadioButton = new JRadioButton("?"); JRadioButton goodRadioButton = new JRadioButton("Good"); JRadioButton badRadioButton = new JRadioButton("Bad"); onePeakRatioRadioButton = new JRadioButton("1-Peak"); unknownRadioButton.setEnabled(false); goodRadioButton.setEnabled(false); badRadioButton.setEnabled(false); onePeakRatioRadioButton.setEnabled(false); quantCurationButtonGroup.add(unknownRadioButton); quantCurationButtonGroup.add(goodRadioButton); quantCurationButtonGroup.add(badRadioButton); quantCurationButtonGroup.add(onePeakRatioRadioButton); unknownRadioButtonModel = unknownRadioButton.getModel(); goodRadioButtonModel = goodRadioButton.getModel(); badRadioButtonModel = badRadioButton.getModel(); onePeakRadioButtonModel = onePeakRatioRadioButton.getModel(); helper.addListener(unknownRadioButton, "buttonCuration_actionPerformed"); helper.addListener(goodRadioButton, "buttonCuration_actionPerformed"); helper.addListener(badRadioButton, "buttonCuration_actionPerformed"); helper.addListener(onePeakRadioButtonModel, "buttonCuration_actionPerformed"); gbc.anchor = GridBagConstraints.WEST; quantCurationPanel.add(unknownRadioButton, gbc); quantCurationPanel.add(badRadioButton, gbc); quantCurationPanel.add(goodRadioButton, gbc); quantCurationPanel.add(onePeakRatioRadioButton, gbc); gbc.anchor = GridBagConstraints.PAGE_START; //ID curation JPanel idCurationPanel = new JPanel(); idCurationPanel.setLayout(new GridBagLayout()); idCurationPanel.setBorder(BorderFactory.createTitledBorder("ID")); idCurationButtonGroup = new ButtonGroup(); JRadioButton idUnknownRadioButton = new JRadioButton("?"); JRadioButton idGoodRadioButton = new JRadioButton("Good"); JRadioButton idBadRadioButton = new JRadioButton("Bad"); idUnknownRadioButton.setEnabled(false); idGoodRadioButton.setEnabled(false); idBadRadioButton.setEnabled(false); idCurationButtonGroup.add(idUnknownRadioButton); idCurationButtonGroup.add(idGoodRadioButton); idCurationButtonGroup.add(idBadRadioButton); idUnknownRadioButtonModel = idUnknownRadioButton.getModel(); idGoodRadioButtonModel = idGoodRadioButton.getModel(); idBadRadioButtonModel = idBadRadioButton.getModel(); helper.addListener(idUnknownRadioButton, "buttonIDCuration_actionPerformed"); helper.addListener(idGoodRadioButton, "buttonIDCuration_actionPerformed"); helper.addListener(idBadRadioButton, "buttonIDCuration_actionPerformed"); gbc.anchor = GridBagConstraints.WEST; idCurationPanel.add(idUnknownRadioButton, gbc); idCurationPanel.add(idBadRadioButton, gbc); idCurationPanel.add(idGoodRadioButton, gbc); gbc.gridwidth = GridBagConstraints.RELATIVE; curationPanel.add(quantCurationPanel, gbc); gbc.gridwidth = GridBagConstraints.REMAINDER; curationPanel.add(idCurationPanel, gbc); //curation comment commentTextField = new JTextField(); commentTextField.setToolTipText("Comment on this event"); //saves after every keypress. Would be more efficient to save when navigating away or saving to file commentTextField.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { if (quantEvents == null) return; QuantEvent quantEvent = quantEvents.get(displayedEventIndex); //save the comment, being careful about tabs and new lines quantEvent.setComment(commentTextField.getText().replace("\t", " ").replace("\n", " ")); } public void keyTyped(KeyEvent e) { } public void keyPressed(KeyEvent e) { } }); curationPanel.add(commentTextField, gbc); assessmentPanel = new JPanel(); assessmentPanel.setLayout(new GridBagLayout()); assessmentPanel.setBorder(BorderFactory.createTitledBorder("Algorithmic Assessment")); assessmentTypeTextField = new JTextField(); assessmentTypeTextField.setEditable(false); assessmentPanel.add(assessmentTypeTextField, gbc); assessmentDescTextField = new JTextField(); assessmentDescTextField.setEditable(false); assessmentPanel.add(assessmentDescTextField, gbc); //Theoretical peak distribution gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.CENTER; theoreticalPeaksPanel = new JPanel(); theoreticalPeaksPanel.setBorder(BorderFactory.createTitledBorder("Theoretical Peaks")); theoreticalPeaksPanel.setLayout(new GridBagLayout()); theoreticalPeaksPanel.setMinimumSize(new Dimension(leftPanelWidth - 10, theoreticalPeaksPanelHeight)); theoreticalPeaksPanel.setMaximumSize(new Dimension(1200, theoreticalPeaksPanelHeight)); showTheoreticalPeaks(); //Add everything to the left panel gbc.insets = new Insets(0, 5, 0, 5); gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.PAGE_START; leftPanel.addComponentListener(new LeftPanelResizeListener()); gbc.weighty = 10; gbc.fill = GridBagConstraints.VERTICAL; leftPanel.add(propertiesScrollPane, gbc); gbc.fill = GridBagConstraints.NONE; gbc.weighty = 1; gbc.anchor = GridBagConstraints.PAGE_END; gbc.fill = GridBagConstraints.HORIZONTAL; leftPanel.add(assessmentPanel, gbc); leftPanel.add(theoreticalPeaksPanel, gbc); gbc.fill = GridBagConstraints.HORIZONTAL; leftPanel.add(curationPanel, gbc); leftPanel.add(navigationPanel, gbc); gbc.fill = GridBagConstraints.BOTH; gbc.weighty = 1; gbc.anchor = GridBagConstraints.PAGE_START; //Chart display multiChartDisplay = new TabbedMultiChartDisplayPanel(); multiChartDisplay.setResizeDelayMS(0); rightPanel.addComponentListener(new RightPanelResizeListener()); rightPanel.add(multiChartDisplay, gbc); //status message messageLabel.setBackground(Color.WHITE); messageLabel.setFont(Font.decode("verdana plain 12")); messageLabel.setText(" "); setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); //paranoia. Sometimes it seems Qurate doesn't exit when you close every window addWindowStateListener(new WindowStateListener() { public void windowStateChanged(WindowEvent e) { if (e.getNewState() == WindowEvent.WINDOW_CLOSED) { dispose(); System.exit(0); } } }); }
From source file:org.apache.airavata.xbaya.ui.dialogs.monitor.MonitorWindow.java
private void init() { this.timeTextField = new XBayaTextField(); this.timeTextField.setEditable(false); XBayaLabel timeLabel = new XBayaLabel(EventDataRepository.Column.TIME.getName(), this.timeTextField); this.idTextField = new XBayaTextField(); this.idTextField.setEditable(false); XBayaLabel idLabel = new XBayaLabel(EventDataRepository.Column.ID.getName(), this.idTextField); this.statusTextField = new XBayaTextField(); this.statusTextField.setEditable(false); XBayaLabel statusLabel = new XBayaLabel(EventDataRepository.Column.STATUS.getName(), this.statusTextField); this.messageTextArea = new JEditorPane(XmlConstants.CONTENT_TYPE_HTML, ""); this.messageTextArea.setSize(500, 500); this.messageTextArea.setEditable(false); messageTextArea.setBackground(Color.WHITE); messageTextArea.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent event) { if (event.getEventType() == EventType.ACTIVATED) { URL url = event.getURL(); try { BrowserLauncher.openURL(url.toString()); } catch (Exception e) { MonitorWindow.this.xbayaGUI.getErrorWindow().error(MonitorWindow.this.dialog.getDialog(), e.getMessage(), e); }/*from w w w. j av a 2 s . c o m*/ } } }); JScrollPane pane = new JScrollPane(messageTextArea); pane.setSize(500, 500); XBayaLabel messageLabel = new XBayaLabel(EventDataRepository.Column.MESSAGE.getName(), pane); GridPanel infoPanel = new GridPanel(); infoPanel.add(timeLabel); infoPanel.add(this.timeTextField); infoPanel.add(idLabel); infoPanel.add(this.idTextField); infoPanel.add(statusLabel); infoPanel.add(this.statusTextField); infoPanel.add(messageLabel); infoPanel.add(pane); infoPanel.layout(4, 2, 3, 1); JButton okButton = new JButton("OK"); okButton.addActionListener(new AbstractAction() { public void actionPerformed(ActionEvent e) { hide(); } }); JButton copyButton = new JButton("Copy to Clipboard"); copyButton.addActionListener(new AbstractAction() { public void actionPerformed(ActionEvent e) { Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(messageText), null); } }); JPanel buttonPanel = new JPanel(); buttonPanel.add(okButton); buttonPanel.add(copyButton); this.dialog = new XBayaDialog(this.xbayaGUI, "Notification", infoPanel, buttonPanel); this.dialog.setDefaultButton(okButton); }