List of usage examples for javax.swing ScrollPaneConstants LOWER_RIGHT_CORNER
String LOWER_RIGHT_CORNER
To view the source code for javax.swing ScrollPaneConstants LOWER_RIGHT_CORNER.
Click Source Link
From source file:MainClass.java
public static JScrollPane createPagingScrollPaneForTable(JTable jt) { JScrollPane jsp = new JScrollPane(jt); TableModel tmodel = jt.getModel(); if (!(tmodel instanceof PagingModel)) { return jsp; }// w w w .ja v a 2 s . co m final PagingModel model = (PagingModel) tmodel; final JButton upButton = new JButton("UP"); upButton.setEnabled(false); final JButton downButton = new JButton("DOWN"); if (model.getPageCount() <= 1) { downButton.setEnabled(false); } upButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { model.pageUp(); if (model.getPageOffset() == 0) { upButton.setEnabled(false); } downButton.setEnabled(true); } }); downButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { model.pageDown(); if (model.getPageOffset() == (model.getPageCount() - 1)) { downButton.setEnabled(false); } upButton.setEnabled(true); } }); jsp.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); jsp.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); jsp.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER, upButton); jsp.setCorner(ScrollPaneConstants.LOWER_RIGHT_CORNER, downButton); return jsp; }
From source file:PagingTester.java
public static JScrollPane createPagingScrollPaneForTable(JTable jt) { JScrollPane jsp = new JScrollPane(jt); TableModel tmodel = jt.getModel(); // Don't choke if this is called on a regular table . . . if (!(tmodel instanceof PagingModel)) { return jsp; }/*w ww . j a v a 2s.c om*/ // Okay, go ahead and build the real scrollpane final PagingModel model = (PagingModel) tmodel; final JButton upButton = new JButton(new ArrowIcon(ArrowIcon.UP)); upButton.setEnabled(false); // starts off at 0, so can't go up final JButton downButton = new JButton(new ArrowIcon(ArrowIcon.DOWN)); if (model.getPageCount() <= 1) { downButton.setEnabled(false); // One page...can't scroll down } upButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { model.pageUp(); // If we hit the top of the data, disable the up button. if (model.getPageOffset() == 0) { upButton.setEnabled(false); } downButton.setEnabled(true); } }); downButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { model.pageDown(); // If we hit the bottom of the data, disable the down button. if (model.getPageOffset() == (model.getPageCount() - 1)) { downButton.setEnabled(false); } upButton.setEnabled(true); } }); // Turn on the scrollbars; otherwise we won't get our corners. jsp.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); jsp.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); // Add in the corners (page up/down). jsp.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER, upButton); jsp.setCorner(ScrollPaneConstants.LOWER_RIGHT_CORNER, downButton); return jsp; }
From source file:ca.phon.ipamap.IpaMap.java
private void init() { setLayout(new BorderLayout()); // favorites/* ww w .j av a2s. c om*/ IpaGrids favData = getFavData(); final Grid fg = favData.getGrid().get(0); favPanel = getGridPanel(fg); favPanel.setCollapsed(getSavedSectionToggle(fg.getName())); favToggleButton = getToggleButton(fg, favPanel); favToggleButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setSavedSectionToggle(fg.getName(), !getSavedSectionToggle(fg.getName())); } }); JPanel favSection = new JPanel(new VerticalLayout(0)); favSection.add(favToggleButton); favSection.add(favPanel); favContainer = favSection; // search Grid emptyGrid = (new ObjectFactory()).createGrid(); emptyGrid.setName("Search Results (0)"); emptyGrid.setRows(0); emptyGrid.setCols(0); searchPanel = getGridPanel(emptyGrid); searchToggleButton = getToggleButton(emptyGrid, searchPanel); final JButton searchButton = new JButton("Search"); searchButton.putClientProperty("JComponent.sizeVariant", "small"); searchButton.addActionListener(this::showSearchFrame); JPanel searchSection = new JPanel(new VerticalLayout(0)); searchSection.add(searchButton); searchSection.add(searchToggleButton); searchContainer = searchSection; // static content final JPanel centerPanel = new JPanel(new VerticalLayout(0)); IpaGrids grids = getGridData(); for (final Grid grid : grids.getGrid()) { final JXCollapsiblePane cp = getGridPanel(grid); cp.setCollapsed(getSavedSectionToggle(grid.getName())); JXButton toggleBtn = getToggleButton(grid, cp); toggleBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setSavedSectionToggle(grid.getName(), !getSavedSectionToggle(grid.getName())); } }); toggleButtons.add(toggleBtn); centerPanel.add(toggleBtn); centerPanel.add(cp); gridPanels.add(cp); } scrollPane = new JScrollPane(centerPanel); scrollPane.setAutoscrolls(true); scrollPane.setWheelScrollingEnabled(true); // scrollPane.setViewportView(centerPanel); add(scrollPane, BorderLayout.CENTER); // JPanel btmPanel = new JPanel(new BorderLayout()); // scalePanel.add(smallLbl, BorderLayout.WEST); // scalePanel.add(scaleSlider, BorderLayout.CENTER); // scalePanel.add(largeLbl, BorderLayout.EAST); final JButton scrollBtn = new JButton("-"); scrollBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { // popupMenu.show(scrollBtn, 0, scrollBtn.getHeight()); JPopupMenu ctxMenu = new JPopupMenu(); setupContextMenu(ctxMenu, scrollBtn); ctxMenu.show(scrollBtn, 0, scrollBtn.getHeight()); } }); // Font infoFont = new Font("Courier New", Font.PLAIN, 12); infoLabel = new JLabel(); infoLabel.setFont(infoLabel.getFont().deriveFont(Font.ITALIC)); infoLabel.setText("[]"); infoLabel.setOpaque(false); statusBar = new JXStatusBar(); statusBar.setLayout(new BorderLayout()); statusBar.add(infoLabel, BorderLayout.CENTER); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); scrollPane.setCorner(ScrollPaneConstants.LOWER_RIGHT_CORNER, scrollBtn); add(statusBar, BorderLayout.SOUTH); JPanel topPanel = new JPanel(new VerticalLayout(0)); topPanel.add(searchSection); topPanel.add(favSection); add(topPanel, BorderLayout.NORTH); }