java类java.awt.event.AdjustmentListener的实例源码

Cart.java 文件源码 项目:PointOfSale 阅读 33 收藏 0 点赞 0 评论 0
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;
}
JScrollPopupMenu.java 文件源码 项目:Net2Plan 阅读 25 收藏 0 点赞 0 评论 0
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;
}
SwingTools.java 文件源码 项目:SweetHome3D 阅读 25 收藏 0 点赞 0 评论 0
/**
 * 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);
                }
            }
        }
    };
}
JScrollC2PopupMenu.java 文件源码 项目:jailer 阅读 28 收藏 0 点赞 0 评论 0
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;
}
JScrollPopupMenu.java 文件源码 项目:jailer 阅读 19 收藏 0 点赞 0 评论 0
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;
}
SymbolControl.java 文件源码 项目:MeteoInfoLib 阅读 22 收藏 0 点赞 0 评论 0
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);
}
JScrollPopupMenu.java 文件源码 项目:AppWoksUtils 阅读 25 收藏 0 点赞 0 评论 0
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;
}
PathographyPanel.java 文件源码 项目:ScreenBasedSimulator 阅读 23 收藏 0 点赞 0 评论 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());
                }
            }
        }); 
    }
JPanCMCodeView.java 文件源码 项目:ATTIC-osit 阅读 19 收藏 0 点赞 0 评论 0
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;
}
AttackOverview_NB.java 文件源码 项目:WS-Attacker 阅读 19 收藏 0 点赞 0 评论 0
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);
}
ClimaticPopInitialiser.java 文件源码 项目:Impro-Visor 阅读 21 收藏 0 点赞 0 评论 0
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);
}
AmuView.java 文件源码 项目:amumag 阅读 23 收藏 0 点赞 0 评论 0
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();
            }
        }
    });
}
ImgPanel.java 文件源码 项目:imglib2-tests 阅读 23 收藏 0 点赞 0 评论 0
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);
    }
}
LogViewer.java 文件源码 项目:magarena 阅读 29 收藏 0 点赞 0 评论 0
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);

        }
ChangesFragmentedDiffPanel.java 文件源码 项目:tools-idea 阅读 28 收藏 0 点赞 0 评论 0
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;
    }
  });
}
ComponentLineNumberTable.java 文件源码 项目:SyncRunner-Pub 阅读 23 收藏 0 点赞 0 评论 0
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));
}
SimpleTextPaneResizeable.java 文件源码 项目:wandora 阅读 25 收藏 0 点赞 0 评论 0
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;
   }
JScrollPopupMenu.java 文件源码 项目:com.opendoorlogistics 阅读 24 收藏 0 点赞 0 评论 0
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;
}
HSB_Picker.java 文件源码 项目:GDSC 阅读 23 收藏 0 点赞 0 评论 0
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++;
}
z390.java 文件源码 项目:z390 阅读 22 收藏 0 点赞 0 评论 0
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));
}
gz390.java 文件源码 项目:z390 阅读 18 收藏 0 点赞 0 评论 0
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));
}
ScrollGroup.java 文件源码 项目:chipster 阅读 24 收藏 0 点赞 0 评论 0
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();
            }
        }
    });
}
JTreeTablePanel.java 文件源码 项目:incubator-netbeans 阅读 28 收藏 0 点赞 0 评论 0
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);
                }
            });
        }
    });
}
JScrollBarInGlassPaneOverlapping.java 文件源码 项目:openjdk-jdk10 阅读 21 收藏 0 点赞 0 评论 0
@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;
}
JScrollBarOverlapping.java 文件源码 项目:openjdk-jdk10 阅读 24 收藏 0 点赞 0 评论 0
@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;
}
ScrollbarOperator.java 文件源码 项目:openjdk-jdk10 阅读 23 收藏 0 点赞 0 评论 0
/**
 * 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);
        }
    });
}
ScrollbarOperator.java 文件源码 项目:openjdk-jdk10 阅读 26 收藏 0 点赞 0 评论 0
/**
 * 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);
        }
    });
}
JScrollBarOperator.java 文件源码 项目:openjdk-jdk10 阅读 22 收藏 0 点赞 0 评论 0
/**
 * 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);
        }
    });
}
JScrollBarOperator.java 文件源码 项目:openjdk-jdk10 阅读 21 收藏 0 点赞 0 评论 0
/**
 * 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);
        }
    });
}
AWTMCList.java 文件源码 项目:myster 阅读 22 收藏 0 点赞 0 评论 0
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);
}


问题


面经


文章

微信
公众号

扫码关注公众号