List of usage examples for javax.swing JScrollPane getViewport
public JViewport getViewport()
JViewport
. From source file:my.jabbr.app.ftpclient.ui.install.ProductLicenseInstallationPanel.java
private void initComponents() { try {//from ww w .j a v a 2 s. c om String licenseStr = FileUtils.readFileToString(new File(ConfigManager.GPL_LICENSE_FILE)); licenseText = new JTextArea(licenseStr); licenseText.setColumns(20); licenseText.setRows(15); licenseText.setBorder(BorderFactory.createLineBorder(UIAccessories.BORDER_GRAY)); licenseText.setBackground(UIAccessories.WHITE); licenseText.setEditable(false); JScrollPane scrollPane = new JScrollPane(licenseText); scrollPane.setBorder(null); scrollPane.setOpaque(false); scrollPane.getViewport().setOpaque(false); scrollPane.getViewport().setBorder(null); scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); setLayout(new BorderLayout(20, 20)); add(createTransparentFillerPanel(), BorderLayout.NORTH); add(scrollPane, BorderLayout.CENTER); } catch (IOException e) { e.printStackTrace(); } this.setOpaque(false); }
From source file:StocksTable2.java
public StocksTable2() { super("Stocks Table"); setSize(600, 300);/*ww w.j av a 2s. c o m*/ m_data = new StockTableData(); m_title = new JLabel(m_data.getTitle(), new ImageIcon("money.gif"), SwingConstants.LEFT); m_title.setFont(new Font("TimesRoman", Font.BOLD, 24)); m_title.setForeground(Color.black); getContentPane().add(m_title, BorderLayout.NORTH); m_table = new JTable(); m_table.setAutoCreateColumnsFromModel(false); m_table.setModel(m_data); for (int k = 0; k < StockTableData.m_columns.length; k++) { DefaultTableCellRenderer renderer = new ColoredTableCellRenderer(); renderer.setHorizontalAlignment(StockTableData.m_columns[k].m_alignment); TableColumn column = new TableColumn(k, StockTableData.m_columns[k].m_width, renderer, null); m_table.addColumn(column); } JTableHeader header = m_table.getTableHeader(); header.setUpdateTableInRealTime(false); JScrollPane ps = new JScrollPane(); ps.getViewport().add(m_table); getContentPane().add(ps, BorderLayout.CENTER); WindowListener wndCloser = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(wndCloser); setVisible(true); }
From source file:com.choicemaker.cm.modelmaker.gui.panels.HoldVsAccuracyPlotPanel.java
JPanel getPanel(JTable table, String title) { JScrollPane pane = new JScrollPane(); pane.getViewport().add(table); pane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(5, 10, 5, 5), BorderFactory.createLoweredBevelBorder())); JPanel panel = new JPanel(new BorderLayout()); panel.setBorder(BorderFactory.createTitledBorder(title)); panel.add(pane, BorderLayout.CENTER); return panel; }
From source file:Main.java
public Main() { super();//from w ww . ja v a 2 s . c o m JTree tree = new JTree(); for (int i = 0; i < tree.getRowCount(); i++) { tree.expandRow(i); } final JScrollPane pane = new JScrollPane(tree) { Dimension prefSize = new Dimension(200, 150); public Dimension getPreferredSize() { return prefSize; } }; pane.getVerticalScrollBar().addAdjustmentListener(e -> { JViewport vp = pane.getViewport(); if (vp.getView().getHeight() <= vp.getHeight() + vp.getViewPosition().y) { System.out.println("End"); } }); add(pane); }
From source file:StocksTable3.java
public StocksTable3() { super("Stocks Table"); setSize(600, 300);//from w w w . j a va 2s. c o m m_data = new StockTableData(); m_title = new JLabel(m_data.getTitle(), new ImageIcon("money.gif"), SwingConstants.LEFT); m_title.setFont(new Font("TimesRoman", Font.BOLD, 24)); m_title.setForeground(Color.black); getContentPane().add(m_title, BorderLayout.NORTH); m_table = new JTable(); m_table.setAutoCreateColumnsFromModel(false); m_table.setModel(m_data); for (int k = 0; k < StockTableData.m_columns.length; k++) { DefaultTableCellRenderer renderer = new ColoredTableCellRenderer(); renderer.setHorizontalAlignment(StockTableData.m_columns[k].m_alignment); TableColumn column = new TableColumn(k, StockTableData.m_columns[k].m_width, renderer, null); m_table.addColumn(column); } JTableHeader header = m_table.getTableHeader(); header.setUpdateTableInRealTime(false); JScrollPane ps = new JScrollPane(); ps.getViewport().add(m_table); getContentPane().add(ps, BorderLayout.CENTER); WindowListener wndCloser = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(wndCloser); setVisible(true); }
From source file:Main.java
private void addComponents() { JEditorPane editorPane = new JEditorPane(); editorPane.setContentType("text/html"); editorPane.setEditable(false);/*from w w w. j a va 2s . co m*/ editorPane.setText(TEXT); JScrollPane scrollpane = new JScrollPane(editorPane); editorPane.addHyperlinkListener(e -> { if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) { String description = e.getDescription(); if (TOP.equals(description)) { JViewport viewport = scrollpane.getViewport(); viewport.setViewPosition(new Point(0, 0)); } } }); super.add(scrollpane); }
From source file:AncestorTree.java
public AncestorTree() { super("Ancestor Tree"); setSize(400, 300);/* w w w . j av a 2 s . c om*/ DefaultMutableTreeNode top = new DefaultMutableTreeNode(new IconData(ICON_SELF, "Myself")); addAncestors(top); m_model = new DefaultTreeModel(top); m_tree = new JTree(m_model); m_tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); m_tree.setShowsRootHandles(true); m_tree.setEditable(true); m_renderer = new IconCellRenderer(); m_tree.setCellRenderer(m_renderer); m_editor = new IconCellEditor(m_tree); m_tree.setCellEditor(m_editor); m_tree.setInvokesStopCellEditing(true); m_tree.addMouseListener(new TreeExpander()); JScrollPane s = new JScrollPane(); s.getViewport().add(m_tree); getContentPane().add(s, BorderLayout.CENTER); WindowListener wndCloser = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(wndCloser); setVisible(true); }
From source file:SimpleHelp.java
public SimpleHelp(String windowName, String helpIndexFileName) { super(windowName + " Help Window"); cp = getContentPane();/*w ww .ja va 2 s .c o m*/ getAccessibleContext().setAccessibleName(windowName + " Help Window"); getAccessibleContext().setAccessibleDescription( "A window for viewing the help for " + windowName + ", which is somewhat hyperlinked."); try { URL url = new File(helpIndexFileName).toURL(); // Only create the window once. if (help == null) { // System.out.println("Creat-ing help window for " + url); help = new JEditorPane(url); // System.out.println("Done!"); help.setEditable(false); help.addHyperlinkListener(this); JScrollPane scroller = new JScrollPane(); scroller.setBorder(BorderFactory.createTitledBorder(windowName + " Help")); scroller.getViewport().add(help); cp.add(BorderLayout.CENTER, scroller); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { SimpleHelp.this.setVisible(false); SimpleHelp.this.dispose(); } }); setSize(500, 400); } else { System.out.println("Re-using help window!"); } } catch (MalformedURLException e) { System.out.println("Malformed URL: " + e); } catch (IOException e) { System.out.println("IOException: " + e); } }
From source file:com.projity.pm.graphic.chart.TimeChartPanel.java
public void configureScrollPaneHeaders(JScrollPane scrollPane, JComponent rowHeader) { viewport = scrollPane.getViewport(); if (viewport == null || viewport.getView() != this) return;/*from w ww . ja v a 2 s. c o m*/ JViewport vp = new JViewport(); vp.setView(rowHeader); vp.setPreferredSize(rowHeader.getPreferredSize()); scrollPane.setRowHeader(vp); scrollPane.setCorner(JScrollPane.UPPER_LEFT_CORNER, new ChartCorner(this)); Border border = scrollPane.getBorder(); if (border == null || border instanceof UIResource) { scrollPane.setBorder(UIManager.getBorder("Table.scrollPaneBorder")); } // left scale synchro viewport.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { updateTimeScaleComponentSize(); } }); }
From source file:es.emergya.ui.gis.popups.GenericDialog.java
protected void addList(Object[] lista, String label) { rows++;//from w w w .j a va2 s . c o m mid.add(new JLabel(i18n.getString(label), JLabel.RIGHT)); if (lista != null) { JList jlist = new JList(lista); final JScrollPane jScrollPane = new JScrollPane(jlist); jScrollPane.getViewport().setPreferredSize(new Dimension(100, 100)); mid.add(jScrollPane); } for (int i = 2; i < cols; i++) mid.add(Box.createHorizontalGlue()); }