List of usage examples for javax.swing JScrollPane getViewport
public JViewport getViewport()
JViewport
. From source file:org.stanwood.swing.AboutDialog.java
private JComponent createAuthorsTab() { JScrollPane scroll = new JScrollPane(); scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); Box box = Box.createVerticalBox(); box.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); for (Author author : authors) { box.add(new JLabel(author.getName())); JXHyperlink link = new JXHyperlink( new LinkAction(this, author.getEmail(), "mailto:" + author.getEmail())); box.add(link);/*from ww w .j a v a 2 s . c o m*/ link.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); JLabel lblDescription = new JLabel(author.getDescription()); lblDescription.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); box.add(lblDescription); } scroll.getViewport().add(box); return scroll; }
From source file:org.stanwood.swing.AboutDialog.java
private JComponent createAboutTab() { JScrollPane scroll = new JScrollPane(); scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); Box box = Box.createVerticalBox(); box.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); box.add(Box.createVerticalGlue()); if (message != null) { JXLabel lblMessage = new JXLabel(message); lblMessage.setLineWrap(true);/*from w w w. j a v a2 s. c o m*/ box.add(lblMessage); } if (appUrl != null) { JXHyperlink link = new JXHyperlink(new LinkAction(this, appUrl, appUrl)); box.add(link); } box.add(Box.createVerticalGlue()); scroll.getViewport().add(box); return scroll; }
From source file:org.ut.biolab.medsavant.client.filter.FilterHistoryPanel.java
public FilterHistoryPanel() { FilterController.getInstance().addListener(new Listener<FilterEvent>() { @Override// w w w . ja va 2s. co m public void handleEvent(final FilterEvent event) { new MedSavantWorker<Void>("FilterHistoryPanel") { @Override protected void showProgress(double fraction) { } @Override protected void showSuccess(Void result) { } @Override protected Void doInBackground() throws Exception { int numLeft = ResultController.getInstance().getFilteredVariantCount(); addFilterSet(event.getFilter(), event.getType(), numLeft); return null; } }.execute(); } }); ReferenceController.getInstance().addListener(new Listener<ReferenceEvent>() { @Override public void handleEvent(ReferenceEvent event) { if (event.getType() == ReferenceEvent.Type.CHANGED) { reset(); } } }); //this.setBackground(new Color(100,100,100)); this.setBorder(ViewUtil.getMediumBorder()); this.setMinimumSize(new Dimension(200, 300)); this.setPreferredSize(new Dimension(200, 300)); this.setName("History"); this.setLayout(new BorderLayout()); table = new JTable() { @Override public TableCellRenderer getCellRenderer(int row, int column) { if (model.getColumnClass(column).equals(JPanel.class)) { return new JPanelRenderer(); } return super.getCellRenderer(row, column); } }; model = new ProgressTableModel(); table.setModel(model); JPanel modePanel = ViewUtil.getClearPanel(); ButtonGroup group = new ButtonGroup(); JRadioButton globalButton = new JRadioButton("Global"); ViewUtil.makeSmall(globalButton); globalButton.setSelected(true); globalButton.setOpaque(false); JRadioButton relativeButton = new JRadioButton("Relative to previous change"); ViewUtil.makeSmall(relativeButton); relativeButton.setOpaque(false); globalButton.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { changeMode(Mode.GLOBAL); } }); relativeButton.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { changeMode(Mode.RELATIVE); } }); group.add(globalButton); group.add(relativeButton); modePanel.add(globalButton); modePanel.add(relativeButton); this.add(modePanel, BorderLayout.NORTH); final JScrollPane scrollPane = new JScrollPane(); scrollPane.getViewport().add(table); this.add(scrollPane, BorderLayout.CENTER); reset(); //FilterController.addFilterListener(this); }
From source file:org.ut.biolab.medsavant.client.plugin.PluginRepositoryDialog.java
public final Component getCenterPanel(List<TreeBrowserEntry> roots) { table = new TreeTable(new TreeBrowserModel(roots) { @Override// ww w .j a v a 2s . c o m public String[] getColumnNames() { return new String[] { "Name" }; } }); table.setSortable(true); table.setRespectRenderPreferredHeight(true); // configure the TreeTable table.setExpandAllAllowed(true); table.setShowTreeLines(false); table.setSortingEnabled(false); table.setRowHeight(18); table.setShowGrid(false); table.setIntercellSpacing(new Dimension(0, 0)); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); //table.expandAll(); table.expandFirstLevel(); table.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { downloadSelectedItem(true); } } }); // do not select row when expanding a row. table.setSelectRowWhenToggling(false); table.getColumnModel().getColumn(0).setPreferredWidth(200); //table.getColumnModel().getColumn(1).setPreferredWidth(300); //table.getColumnModel().getColumn(2).setPreferredWidth(50); //table.getColumnModel().getColumn(3).setPreferredWidth(100); //table.getColumnModel().getColumn(4).setPreferredWidth(50); table.getColumnModel().getColumn(0).setCellRenderer(FILE_RENDERER); // add searchable feature TableSearchable searchable = new TableSearchable(table) { @Override protected String convertElementToString(Object item) { if (item instanceof TreeBrowserEntry) { return ((TreeBrowserEntry) item).getType(); } return super.convertElementToString(item); } }; searchable.setMainIndex(0); // only search for name column JScrollPane scrollPane = new JScrollPane(table); scrollPane.getViewport().setBackground(Color.WHITE); JPanel panel = new JPanel(new BorderLayout(6, 6)); panel.add(scrollPane, BorderLayout.CENTER); panel.setPreferredSize(new Dimension(800, 500)); return panel; }
From source file:org.ut.biolab.medsavant.client.project.ProjectWizard.java
private AbstractWizardPage getPatientFieldsPage() { //setup page//from w w w .j ava2s .co m final DefaultWizardPage page = new DefaultWizardPage(PAGENAME_PATIENTS) { @Override public void setupWizardButtons() { fireButtonEvent(ButtonEvent.SHOW_BUTTON, ButtonNames.BACK); fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.BACK); fireButtonEvent(ButtonEvent.HIDE_BUTTON, ButtonNames.FINISH); fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.NEXT); } }; page.addText("Add relevant fields for patients. "); JScrollPane scrollpane = new JScrollPane(); scrollpane.setPreferredSize(new Dimension(300, 250)); scrollpane.getViewport().setBackground(Color.white); final JTable table = new JTable() { @Override public Class<?> getColumnClass(int column) { if (column == 2) { return Boolean.class; } else { return String.class; } } }; patientFormatModel = new DefaultTableModel() { @Override public boolean isCellEditable(int row, int col) { return row >= 8; } }; patientFormatModel.addColumn("Name"); patientFormatModel.addColumn("Type"); patientFormatModel.addColumn("Filterable"); patientFormatModel.addColumn("Alias"); patientFormatModel.addColumn("Description"); patientFormatModel.addRow(new Object[] { FAMILY_ID.getColumnName(), FAMILY_ID.getTypeString(), true, FAMILY_ID.getAlias(), "" }); patientFormatModel.addRow(new Object[] { HOSPITAL_ID.getColumnName(), HOSPITAL_ID.getTypeString(), true, HOSPITAL_ID.getAlias(), "" }); patientFormatModel.addRow( new Object[] { IDBIOMOM.getColumnName(), IDBIOMOM.getTypeString(), true, IDBIOMOM.getAlias(), "" }); patientFormatModel.addRow( new Object[] { IDBIODAD.getColumnName(), IDBIODAD.getTypeString(), true, IDBIODAD.getAlias(), "" }); patientFormatModel.addRow( new Object[] { GENDER.getColumnName(), GENDER.getTypeString(), true, GENDER.getAlias(), "" }); patientFormatModel.addRow( new Object[] { AFFECTED.getColumnName(), AFFECTED.getTypeString(), true, AFFECTED.getAlias(), "" }); patientFormatModel.addRow( new Object[] { DNA_IDS.getColumnName(), DNA_IDS.getTypeString(), true, DNA_IDS.getAlias(), "" }); patientFormatModel.addRow( new Object[] { BAM_URL.getColumnName(), BAM_URL.getTypeString(), true, BAM_URL.getAlias(), "" }); patientFormatModel.addRow(new Object[] { PHENOTYPES.getColumnName(), PHENOTYPES.getTypeString(), true, PHENOTYPES.getAlias(), "" }); if (modify) { for (CustomField f : customFields) { patientFormatModel.addRow(new Object[] { f.getColumnName(), f.getTypeString(), f.isFilterable(), f.getAlias(), f.getDescription() }); } } table.setModel(patientFormatModel); table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); scrollpane.getViewport().add(table); page.addComponent(scrollpane); JButton addFieldButton = new JButton("Add Field"); addFieldButton.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { patientFormatModel.addRow(new Object[5]); table.setModel(patientFormatModel); } }); page.addComponent(addFieldButton); JButton removeFieldButton = new JButton("Remove Field"); removeFieldButton.setEnabled(false); removeFieldButton.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { int row = table.getSelectedRow(); // Minus one because patient_id isn't in the table. if (row >= BasicPatientColumns.REQUIRED_PATIENT_FIELDS.length - 1) { patientFormatModel.removeRow(row); } table.setModel(patientFormatModel); } }); table.getSelectionModel().addListSelectionListener( new RemovalEnabler(BasicPatientColumns.REQUIRED_PATIENT_FIELDS.length - 1, removeFieldButton)); page.addComponent(removeFieldButton); return page; }
From source file:org.ut.biolab.medsavant.client.project.ProjectWizard.java
private AbstractWizardPage getVCFFieldsPage() { //setup page//from w w w. j a va2 s . co m final DefaultWizardPage page = new DefaultWizardPage(PAGENAME_VCF) { @Override public void setupWizardButtons() { fireButtonEvent(ButtonEvent.SHOW_BUTTON, ButtonNames.BACK); fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.BACK); fireButtonEvent(ButtonEvent.HIDE_BUTTON, ButtonNames.FINISH); fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.NEXT); } }; page.addText("Add extra fields to parse from INFO text in VCF files. "); JScrollPane scrollpane = new JScrollPane(); scrollpane.setPreferredSize(new Dimension(300, 250)); scrollpane.getViewport().setBackground(Color.white); final JTable table = new JTable() { @Override public Class<?> getColumnClass(int column) { if (column == 2) { return Boolean.class; } else { return String.class; } } }; variantFormatModel = new DefaultTableModel(); variantFormatModel.addColumn("Key"); variantFormatModel.addColumn("Type"); variantFormatModel.addColumn("Filterable"); variantFormatModel.addColumn("Alias"); variantFormatModel.addColumn("Description"); if (modify) { try { int firstRef = manager.getReferenceIDsForProject(LoginController.getSessionID(), projectID)[0]; CustomField[] fields = manager.getCustomVariantFields(LoginController.getSessionID(), projectID, firstRef, manager.getNewestUpdateID(LoginController.getSessionID(), projectID, firstRef, false)); for (CustomField f : fields) { //casing of f.getColumnName should match database. variantFormatModel.addRow(new Object[] { f.getColumnName(), f.getTypeString(), f.isFilterable(), f.getAlias(), f.getDescription() }); } } catch (Exception ex) { LOG.error("Error getting reference IDs for project.", ex); } } else { variantFormatModel .addRow(new Object[] { AA.getColumnName(), AA.getTypeString(), true, AA.getAlias(), "" }); variantFormatModel .addRow(new Object[] { AC.getColumnName(), AC.getTypeString(), true, AC.getAlias(), "" }); variantFormatModel .addRow(new Object[] { AF.getColumnName(), AF.getTypeString(), true, AF.getAlias(), "" }); variantFormatModel .addRow(new Object[] { AN.getColumnName(), AN.getTypeString(), true, AN.getAlias(), "" }); variantFormatModel .addRow(new Object[] { BQ.getColumnName(), BQ.getTypeString(), true, BQ.getAlias(), "" }); variantFormatModel.addRow( new Object[] { CIGAR.getColumnName(), CIGAR.getTypeString(), true, CIGAR.getAlias(), "" }); variantFormatModel .addRow(new Object[] { DB.getColumnName(), DB.getTypeString(), true, DB.getAlias(), "" }); variantFormatModel .addRow(new Object[] { DP.getColumnName(), DP.getTypeString(), true, DP.getAlias(), "" }); //variantFormatModel.addRow(new Object[]{END.getColumnName(), END.getTypeString(), true, END.getAlias(), ""}); variantFormatModel .addRow(new Object[] { H2.getColumnName(), H2.getTypeString(), true, H2.getAlias(), "" }); variantFormatModel .addRow(new Object[] { MQ.getColumnName(), MQ.getTypeString(), true, MQ.getAlias(), "" }); variantFormatModel .addRow(new Object[] { MQ0.getColumnName(), MQ0.getTypeString(), true, MQ0.getAlias(), "" }); variantFormatModel .addRow(new Object[] { NS.getColumnName(), NS.getTypeString(), true, NS.getAlias(), "" }); variantFormatModel .addRow(new Object[] { SB.getColumnName(), SB.getTypeString(), true, SB.getAlias(), "" }); variantFormatModel.addRow(new Object[] { SOMATIC.getColumnName(), SOMATIC.getTypeString(), true, SOMATIC.getAlias(), "" }); variantFormatModel.addRow(new Object[] { VALIDATED.getColumnName(), VALIDATED.getTypeString(), true, VALIDATED.getAlias(), "" }); variantFormatModel .addRow(new Object[] { JANNOVAR_EFFECT.getColumnName(), JANNOVAR_EFFECT.getTypeString(), JANNOVAR_EFFECT.isFilterable(), JANNOVAR_EFFECT.getAlias(), "" }); variantFormatModel .addRow(new Object[] { JANNOVAR_SYMBOL.getColumnName(), JANNOVAR_SYMBOL.getTypeString(), JANNOVAR_SYMBOL.isFilterable(), JANNOVAR_SYMBOL.getAlias(), "" }); variantFormatModel.addRow(new Object[] { FORMAT.getColumnName(), FORMAT.getTypeString(), FORMAT.isFilterable(), FORMAT.getAlias(), "" }); variantFormatModel.addRow(new Object[] { SAMPLE_INFO.getColumnName(), SAMPLE_INFO.getTypeString(), SAMPLE_INFO.isFilterable(), SAMPLE_INFO.getAlias(), "" }); } table.setModel(variantFormatModel); table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); scrollpane.getViewport().add(table); page.addComponent(scrollpane); table.addKeyListener(new KeyListener() { @Override public void keyTyped(KeyEvent e) { variantFieldsChanged = true; } @Override public void keyPressed(KeyEvent e) { variantFieldsChanged = true; } @Override public void keyReleased(KeyEvent e) { variantFieldsChanged = true; } }); JButton addFieldButton = new JButton("Add Field"); addFieldButton.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { variantFormatModel.addRow(new Object[2]); table.setModel(variantFormatModel); variantFieldsChanged = true; } }); page.addComponent(addFieldButton); JButton removeFieldButton = new JButton("Remove Field"); removeFieldButton.setEnabled(false); removeFieldButton.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { int row = table.getSelectedRow(); if (row >= 0) { variantFormatModel.removeRow(row); table.setModel(variantFormatModel); variantFieldsChanged = true; } } }); table.getSelectionModel().addListSelectionListener(new RemovalEnabler(0, removeFieldButton)); page.addComponent(removeFieldButton); return page; }
From source file:org.ut.biolab.medsavant.client.project.ProjectWizard.java
private AbstractWizardPage getReferencePage() throws SQLException, RemoteException { //setup page/* ww w . j a v a2s. c om*/ final DefaultWizardPage page = new DefaultWizardPage(PAGENAME_REF) { @Override public void setupWizardButtons() { fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.BACK); fireButtonEvent(ButtonEvent.HIDE_BUTTON, ButtonNames.FINISH); fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.NEXT); } }; page.addText("Choose reference genome(s) to add to this project, along\n" + "with corresponding annotations. Annotations will be\n" + "applied to all variants added to these tables."); //setup list JScrollPane scrollpane = new JScrollPane(); scrollpane.setPreferredSize(new Dimension(300, 220)); scrollpane.getViewport().setBackground(Color.white); final JPanel p = new JPanel(); p.setBackground(Color.white); p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); refreshReferencePanel(p); scrollpane.getViewport().add(p); page.addComponent(scrollpane); JButton addRefButton = new JButton("New Reference"); addRefButton.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { try { new NewReferenceDialog().setVisible(true); refreshReferencePanel(p); } catch (Exception ex) { ClientMiscUtils.reportError("Unable to retrieve references and annotations: %s", ex); } } }); page.addComponent(addRefButton); return page; }
From source file:pipeline.GUI_utils.ListOfPointsView.java
private static JViewport getTableViewPort(JTable table) { Container parent = SwingUtilities.getUnwrappedParent(table); if (parent instanceof JViewport) { JViewport port = (JViewport) parent; Container gp = port.getParent(); if (gp instanceof JScrollPane) { JScrollPane scrollPane = (JScrollPane) gp; // Make certain we are the viewPort's view and not, for // example, the rowHeaderView of the scrollPane - // an implementor of fixed columns might do this. JViewport viewPort = scrollPane.getViewport(); if (viewPort == null || SwingUtilities.getUnwrappedView(viewPort) != table) { return null; }//from w w w. j av a 2 s .c o m return viewPort; } } return null; }
From source file:savant.agp.HTTPBrowser.java
public HTTPBrowser(URL rootURL) throws IOException { host = rootURL.getHost();/*from ww w. ja v a2 s. co m*/ int p = rootURL.getPort(); port = p != -1 ? p : rootURL.getDefaultPort(); rootDir = new File(rootURL.getPath()); curDir = rootDir; setLayout(new BorderLayout()); addressLabel = new JLabel(); add(addressLabel, BorderLayout.NORTH); add(getToolBar(), BorderLayout.SOUTH); table = new JTable(); updateDirectory(); table.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { if (evt.getClickCount() == 2) { String f = ((HTTPTableModel) table.getModel()).getEntry(table.rowAtPoint(evt.getPoint())); if (f.equals("..")) { // Going up a directory. curDir = curDir.getParentFile(); updateDirectory(); } else if (!f.contains(".")) { if (f.startsWith("/")) { curDir = new File(f); } else { curDir = new File(curDir, f); } updateDirectory(); } else { openIndexAs(table.rowAtPoint(evt.getPoint()), OpenAsOption.TRACK); } } } }); JScrollPane scrollPane = new JScrollPane(table); scrollPane.getViewport().setBackground(Color.WHITE); scrollPane.setPreferredSize(new Dimension(800, 500)); add(scrollPane, BorderLayout.CENTER); this.setPreferredSize(new Dimension(800, 500)); }
From source file:savant.plugin.builtin.SAFEBrowser.java
public final Component getCenterPanel(List<TreeBrowserEntry> roots) { table = new TreeTable(new TreeBrowserModel(roots) { @Override/*from w w w.ja va 2s .c om*/ public String[] getColumnNames() { return new String[] { "Name", "Description" }; } }); table.setSortable(false); table.setRespectRenderPreferredHeight(true); // configure the TreeTable table.setExpandAllAllowed(true); table.setShowTreeLines(false); table.setSortingEnabled(false); table.setRowHeight(18); table.setShowGrid(false); table.setIntercellSpacing(new Dimension(0, 0)); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.expandFirstLevel(); table.addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { actOnSelectedItem(true); } } @Override public void mousePressed(MouseEvent e) { } @Override public void mouseReleased(MouseEvent e) { } @Override public void mouseEntered(MouseEvent e) { } @Override public void mouseExited(MouseEvent e) { } }); // do not select row when expanding a row. table.setSelectRowWhenToggling(false); table.getColumnModel().getColumn(0).setPreferredWidth(200); //table.getColumnModel().getColumn(1).setPreferredWidth(400); //table.getColumnModel().getColumn(2).setPreferredWidth(100); //table.getColumnModel().getColumn(3).setPreferredWidth(100); //table.getColumnModel().getColumn(4).setPreferredWidth(50); table.getColumnModel().getColumn(0).setCellRenderer(FILE_RENDERER); // add searchable feature TableSearchable searchable = new TableSearchable(table) { @Override protected String convertElementToString(Object item) { if (item instanceof TreeBrowserEntry) { return ((TreeBrowserEntry) item).getType(); } return super.convertElementToString(item); } }; searchable.setMainIndex(0); // only search for name column JScrollPane scrollPane = new JScrollPane(table); scrollPane.getViewport().setBackground(Color.WHITE); JPanel panel = new JPanel(new BorderLayout(6, 6)); panel.add(scrollPane, BorderLayout.CENTER); panel.setPreferredSize(new Dimension(800, 500)); return panel; }