public JScrollPane generateScrollPane() { JScrollPane newScroll = new JScrollPane(); JList list = new JList(listModel); list.setFont( new Font("monospaced", Font.PLAIN, 12) ); newScroll.setViewportView(list); Dimension listSize = new Dimension(400, 150); newScroll.setSize(listSize); newScroll.setMaximumSize(listSize); newScroll.setPreferredSize(listSize); newScroll.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent e) { e.getAdjustable().setValue(e.getAdjustable().getMaximum()); } }); return newScroll; }
private JScrollBar getScrollBar() { if (popupScrollBar == null) { popupScrollBar = new JScrollBar(JScrollBar.VERTICAL); popupScrollBar.addAdjustmentListener(new AdjustmentListener() { @Override public void adjustmentValueChanged(AdjustmentEvent e) { doLayout(); repaint(); } }); popupScrollBar.setVisible(false); } return popupScrollBar; }
/** * Returns a scroll bar adjustment listener bound to the given <code>scrollPane</code> view * that updates view tool tip when its vertical scroll bar is adjusted. */ public static AdjustmentListener createAdjustmentListenerUpdatingScrollPaneViewToolTip(final JScrollPane scrollPane) { return new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent ev) { Point screenLocation = MouseInfo.getPointerInfo().getLocation(); Point point = new Point(screenLocation); Component view = scrollPane.getViewport().getView(); SwingUtilities.convertPointFromScreen(point, view); if (scrollPane.isShowing() && scrollPane.getViewport().getViewRect().contains(point)) { MouseEvent mouseEvent = new MouseEvent(view, MouseEvent.MOUSE_MOVED, System.currentTimeMillis(), 0, point.x, point.y, 0, false, MouseEvent.NOBUTTON); if (isToolTipShowing()) { ToolTipManager.sharedInstance().mouseMoved(mouseEvent); } } } }; }
protected JScrollBar getScrollBar() { if (popupScrollBar == null) { popupScrollBar = new JScrollBar(JScrollBar.VERTICAL); popupScrollBar.addAdjustmentListener(new AdjustmentListener() { @Override public void adjustmentValueChanged(AdjustmentEvent e) { doLayout(); repaint(); } }); popupScrollBar.setVisible(false); } return popupScrollBar; }
private void initComponents() { this.setPreferredSize(new Dimension(200, 100)); this.setLayout(new BorderLayout()); this.setBackground(Color.white); _vScrollBar = new JScrollBar(JScrollBar.VERTICAL); _vScrollBar.addAdjustmentListener(new AdjustmentListener() { @Override public void adjustmentValueChanged(AdjustmentEvent e) { onScrollValueChanged(e); } }); this.add(_vScrollBar, BorderLayout.EAST); //this._vScrollBar.setSize(this._vScrollBar.getWidth(), this.getHeight()); this._vScrollBar.setSize(20, this.getHeight()); this._vScrollBar.setLocation(this.getWidth() - this._vScrollBar.getWidth(), 0); }
public PathographyPanel() { model = new DefaultListModel<String>(); list = new JList<String>(model); this.setViewportView(list); this.setAutoscrolls(true); this.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent e) { if(needScroll) { e.getAdjustable().setValue(e.getAdjustable().getMaximum()); needScroll = false; } else { e.getAdjustable().setValue(e.getAdjustable().getValue()); } } }); }
public JScrollPane getJScrollPane() { if (jScrollPane == null) { jScrollPane = new JScrollPane(); JPanel LeftSourceCodePanel = new JPanel(); LeftSourceCodePanel.setLayout(new BorderLayout()); LeftSourceCodePanel.add(getJTextPaneLineNumber(), BorderLayout.WEST); LeftSourceCodePanel.add(getJTextPaneSourceView(), BorderLayout.CENTER); jScrollPane.setViewportView(LeftSourceCodePanel); jScrollPane.getVerticalScrollBar().setUnitIncrement(ConstantValue.CODE_SCROLL_SIZE); jScrollPane.getVerticalScrollBar().addAdjustmentListener( new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent e) { if(siblingSourceView != null) { siblingSourceView.changeScrollBar(changeLine()); } } } ); } return jScrollPane; }
private void addAdjustmenListenerToResultsScrollbar() { resultTableScrollPane.getVerticalScrollBar().addAdjustmentListener( new AdjustmentListener() { @Override public void adjustmentValueChanged( AdjustmentEvent e ) { if ( e.getValueIsAdjusting() ) { // The user is dragging the knob return; } JScrollBar bar = resultTableScrollPane.getVerticalScrollBar(); int max = bar.getMaximum(); int current = bar.getValue(); final int THRESHOLD = bar.getVisibleAmount() * 2; if ( current > ( max - THRESHOLD ) ) { e.getAdjustable().setValue( max ); } } } ); // resultTableScrollPane.setAutoscrolls(true); }
public ClimaticPopInitialiser(int population) { populationSize = population; panel = new Panel(); panel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); populationLabel = new Label(Integer.toString(populationSize)); panel.add(new Label("Population Size", Label.RIGHT)); panel.add(new Scrollbar(Scrollbar.HORIZONTAL, populationSize, 1, MIN_POPULATION_SIZE, MAX_POPULATION_SIZE) { { addAdjustmentListener(new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent evt) { populationSize = getValue(); populationLabel.setText(Integer.toString(getValue())); populationLabel.repaint(); } } ); } } ); panel.add(populationLabel); }
protected void initScroller() { scroller = new JScrollBar(JScrollBar.VERTICAL); scroller.setMinimum(0); scroller.setVisibleAmount(1); scroller.setMaximum(1); scroller.addAdjustmentListener(new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent e) { try { time(scroller.getValue()); } catch (IOException ex) { ex.printStackTrace(); } } }); }
public SliderPanel(final ImgData<?> imgData) { setBorder(new TitledBorder(imgData.name)); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); // add one slider per dimension beyond the first two for (int d = 2; d < imgData.imgPlus.numDimensions(); d++) { final int dimLength = (int) imgData.imgPlus.dimension(d); final JScrollBar bar = new JScrollBar(Adjustable.HORIZONTAL, 0, 1, 0, dimLength); final int dim = d; bar.addAdjustmentListener(new AdjustmentListener() { @Override public void adjustmentValueChanged(final AdjustmentEvent e) { final int value = bar.getValue(); imgData.projector.setPosition(value, dim); imgData.projector.map(); imgData.owner.repaint(); } }); add(bar); } }
public LogScrollPane(Component aView) { super(aView); final JScrollBar vscroll = getVerticalScrollBar(); vscroll.setUnitIncrement(INCREMENT); vscroll.setBlockIncrement(INCREMENT); vscroll.addAdjustmentListener(new AdjustmentListener() { @Override public void adjustmentValueChanged(AdjustmentEvent e) { e.getAdjustable().setValue(e.getAdjustable().getMaximum()); } }); setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER); setBorder(BorderFactory.createEmptyBorder()); getViewport().setOpaque(false); }
public void afterPanelsAdded() { myLeftScroll.setMinimum(0); myLeftScroll.setMaximum(myMaxColumnsLeft); myLeftScroll.addAdjustmentListener(new AdjustmentListener() { @Override public void adjustmentValueChanged(AdjustmentEvent e) { myInScrolling = true; final int scrollPosCorrected = myLeftScroll.getValue() + 1; if (myByLeft) { scrollMain(myLeftScroll.getValue(), myLeftModels); scrollOther(scrollPosCorrected, myMaxColumnsLeft, myMaxColumnsRight, myRightModels); } else { scrollMain(myLeftScroll.getValue(), myRightModels); scrollOther(scrollPosCorrected, myMaxColumnsRight, myMaxColumnsLeft, myLeftModels); } myInScrolling = false; } }); }
public ComponentLineNumberTable(JScrollPane jScrollPane, JTable table) { this.scrollPane = jScrollPane; this.table = table; this.table.getModel().addTableModelListener(new TableModelListener() { public void tableChanged(TableModelEvent tme) { ComponentLineNumberTable.this.repaint(); } }); this.table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent lse) { ComponentLineNumberTable.this.repaint(); } }); this.scrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent ae) { ComponentLineNumberTable.this.repaint(); } }); setPreferredSize(new Dimension(26, 50)); }
protected JScrollPane getScrollPane() { // Get scrollpane, if first time calling this method then add an addjustment listener // to the scroll pane if(this.getParent() instanceof JViewport) { if(scrollPane == null) { JViewport p = (JViewport)this.getParent(); scrollPane = (JScrollPane)p.getParent(); scrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener(){ @Override public void adjustmentValueChanged(AdjustmentEvent e) { //need to repaint the triangle when scroll bar moves repaint(); } }); } } return scrollPane; }
private void createSliderPanel(final Scrollbar sliderField, String label, final Label sliderLabel, final double scale) { Label listLabel = new Label(label, 0); add(listLabel, 0, 1); sliderField.setSize(100, 10); c.ipadx = 75; add(sliderField, 1, 1); c.ipadx = 0; sliderField.addAdjustmentListener(new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent e) { setSliderLabel(sliderField, sliderLabel, scale); } }); add(sliderLabel, 2, 1); setSliderLabel(sliderField, sliderLabel, scale); row++; }
private void build_log_view(){ /* * build scrolling log view based on * current screen and font size */ log_text = new JTextArea(); log_text.addMouseListener(this); log_view = new JScrollPane(log_text); log_view.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener(){ public void adjustmentValueChanged(AdjustmentEvent e){ if (tz390.log_text_added){ tz390.log_text_added = false; log_view.getVerticalScrollBar().setValue(log_view.getVerticalScrollBar().getMaximum()); } }}); log_view.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); log_view.setPreferredSize( new Dimension(log_width, log_height)); }
private void build_log_view(){ /* * build scrolling log view based on * current screen and font size */ log_text = new JTextArea(); log_text.addMouseListener(this); main_view = new JScrollPane(log_text); main_view.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener(){ public void adjustmentValueChanged(AdjustmentEvent e){ if (main_view_changed){ main_view_changed = false; main_view.getVerticalScrollBar().setValue(main_view.getVerticalScrollBar().getMaximum()); } }}); main_view.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); main_view.setPreferredSize( new Dimension(log_width, log_height)); }
public ScrollGroup() { super(); component.setViewportView(canvas); component.getVerticalScrollBar().setUnitIncrement(10); component.setBorder(null); canvas.setLayout(new MigLayout("flowy, fillx, gap 0! 0!, insets 0")); component.setInheritsPopupMenu(true); canvas.setInheritsPopupMenu(true); /* * The cursor line in GBrowserView has to be redrawn when the scroll pane is scrolled. * This is not a perfect solution, because the component is shown for a while before * the cursor line is painted (the line flickers during the scrolling). */ component.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() { @Override public void adjustmentValueChanged(AdjustmentEvent e) { if (view != null){ view.getComponent().repaint(); } } }); }
private void hookScrollBarValueChange() { scrollBar.addAdjustmentListener(new AdjustmentListener() { public void adjustmentValueChanged(final AdjustmentEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { treeTable.setTreeCellOffsetX(e.getValue()); if (!e.getValueIsAdjusting()) updateScrollBar(false); } }); } }); }
@Override protected JComponent getSwingComponent() { JScrollBar ch = new JScrollBar(JScrollBar.VERTICAL); ch.setPreferredSize(new Dimension(50, 50)); ch.setValue(50); ch.addAdjustmentListener(new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent e) { wasLWClicked = true; } }); OverlappingTestBase.shift = new Point(20, 16); return ch; }
/** * Maps {@code Scrollbar.addAdjustmentListener(AdjustmentListener)} * through queue */ public void addAdjustmentListener(final AdjustmentListener adjustmentListener) { runMapping(new MapVoidAction("addAdjustmentListener") { @Override public void map() { ((Scrollbar) getSource()).addAdjustmentListener(adjustmentListener); } }); }
/** * Maps {@code Scrollbar.removeAdjustmentListener(AdjustmentListener)} * through queue */ public void removeAdjustmentListener(final AdjustmentListener adjustmentListener) { runMapping(new MapVoidAction("removeAdjustmentListener") { @Override public void map() { ((Scrollbar) getSource()).removeAdjustmentListener(adjustmentListener); } }); }
/** * Maps {@code JScrollBar.addAdjustmentListener(AdjustmentListener)} * through queue */ public void addAdjustmentListener(final AdjustmentListener adjustmentListener) { runMapping(new MapVoidAction("addAdjustmentListener") { @Override public void map() { ((JScrollBar) getSource()).addAdjustmentListener(adjustmentListener); } }); }
/** * Maps {@code JScrollBar.removeAdjustmentListener(AdjustmentListener)} * through queue */ public void removeAdjustmentListener(final AdjustmentListener adjustmentListener) { runMapping(new MapVoidAction("removeAdjustmentListener") { @Override public void map() { ((JScrollBar) getSource()).removeAdjustmentListener(adjustmentListener); } }); }
public AWTMCList(int numberofcolumns, boolean singleselect, Component c) { this.rowTheme = new DefaultMCRowTheme(c); header = new MCListHeader(this, numberofcolumns); setBackground(rowTheme.getBackground()); eventhandler = new MCListEventHandler(this); singleselectboolean = singleselect; list = new MCListVector(); pane = new MCListScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED); setSize(1024, 1024); setLayout(null); pane.add(this); add(header); addMouseListener(eventhandler); addMouseMotionListener(eventhandler); Adjustable horizontal = pane.getHAdjustable(); horizontal.setUnitIncrement(10); Adjustable vertical = pane.getVAdjustable(); vertical.setUnitIncrement(10); vertical.addAdjustmentListener(new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent e) { header.setLocation(0, e.getValue()); } }); addKeyListener(eventhandler); }
private void setScrollBarToBottom(String course, JTabbedPane tabbedPanelBase, JBScrollPane panel) { tabbedPanelBase.addTab(course, panel); JScrollBar bar = panel.getVerticalScrollBar(); AdjustmentListener listener = event -> event.getAdjustable().setValue(event.getAdjustable().getMaximum()); bar.addAdjustmentListener(listener); bar.setValueIsAdjusting(true); bar.removeAdjustmentListener(listener); bar.setValue(bar.getMaximum()); }
/** * Adds a new adjustment listener to the list of registered listeners * for this object. * * @param listener The listener to add. */ public synchronized void addAdjustmentListener(AdjustmentListener listener) { adjustment_listeners = AWTEventMulticaster.add(adjustment_listeners, listener); enableEvents(AWTEvent.ADJUSTMENT_EVENT_MASK); }
/** * Returns an array of all the objects currently registered as FooListeners * upon this <code>Scrollbar</code>. FooListeners are registered using the * addFooListener method. * * @exception ClassCastException If listenerType doesn't specify a class or * interface that implements java.util.EventListener. */ public <T extends EventListener> T[] getListeners(Class<T> listenerType) { if (listenerType == AdjustmentListener.class) return AWTEventMulticaster.getListeners(adjustment_listeners, listenerType); return super.getListeners(listenerType); }
/** * Helper method for firing adjustment events that can have their * isAdjusting field modified. * * This is package private to avoid an accessor method. * * @param id the ID of the event * @param type the type of the event * @param value the value * @param isAdjusting if the scrollbar is adjusting or not */ void fireAdjustmentValueChanged(int id, int type, int value, boolean isAdjusting) { Object[] adjustmentListeners = listenerList.getListenerList(); AdjustmentEvent adjustmentEvent = new AdjustmentEvent(this, id, type, value, isAdjusting); for (int i = adjustmentListeners.length - 2; i >= 0; i -= 2) { if (adjustmentListeners[i] == AdjustmentListener.class) ((AdjustmentListener) adjustmentListeners[i + 1]).adjustmentValueChanged(adjustmentEvent); } }