java.awt.ScrollPane Java Examples

The following examples show how to use java.awt.ScrollPane. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ScrollPaneWheelScroller.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void handleWheelScrolling(ScrollPane sp, MouseWheelEvent e) {
    if (log.isLoggable(PlatformLogger.Level.FINER)) {
        log.finer("x = " + e.getX() + ", y = " + e.getY() + ", src is " + e.getSource());
    }
    int increment = 0;

    if (sp != null && e.getScrollAmount() != 0) {
        Adjustable adj = getAdjustableToScroll(sp);
        if (adj != null) {
            increment = getIncrementFromAdjustable(adj, e);
            if (log.isLoggable(PlatformLogger.Level.FINER)) {
                log.finer("increment from adjustable(" + adj.getClass() + ") : " + increment);
            }
            scrollAdjustable(adj, increment);
        }
    }
}
 
Example #2
Source File: ScrollPanePreferredSize.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) {
    final Dimension expected = new Dimension(300, 300);
    final Frame frame = new Frame();
    final ScrollPane sp = new ScrollPane();
    sp.setSize(expected);
    frame.add(sp);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    sleep();
    final Dimension size = frame.getSize();
    if (size.width < expected.width || size.height < expected.height) {
        throw new RuntimeException(
                "Expected size: >= " + expected + ", actual size: " + size);
    }
    frame.dispose();
}
 
Example #3
Source File: ScrollPanePreferredSize.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) {
    final Dimension expected = new Dimension(300, 300);
    final Frame frame = new Frame();
    final ScrollPane sp = new ScrollPane();
    sp.setSize(expected);
    frame.add(sp);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    sleep();
    final Dimension size = frame.getSize();
    if (size.width < expected.width || size.height < expected.height) {
        throw new RuntimeException(
                "Expected size: >= " + expected + ", actual size: " + size);
    }
    frame.dispose();
}
 
Example #4
Source File: ScrollPaneWheelScroller.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void handleWheelScrolling(ScrollPane sp, MouseWheelEvent e) {
    if (log.isLoggable(PlatformLogger.Level.FINER)) {
        log.finer("x = " + e.getX() + ", y = " + e.getY() + ", src is " + e.getSource());
    }
    int increment = 0;

    if (sp != null && e.getScrollAmount() != 0) {
        Adjustable adj = getAdjustableToScroll(sp);
        if (adj != null) {
            increment = getIncrementFromAdjustable(adj, e);
            if (log.isLoggable(PlatformLogger.Level.FINER)) {
                log.finer("increment from adjustable(" + adj.getClass() + ") : " + increment);
            }
            scrollAdjustable(adj, increment);
        }
    }
}
 
Example #5
Source File: ScrollPaneWheelScroller.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void handleWheelScrolling(ScrollPane sp, MouseWheelEvent e) {
    if (log.isLoggable(PlatformLogger.Level.FINER)) {
        log.finer("x = " + e.getX() + ", y = " + e.getY() + ", src is " + e.getSource());
    }
    int increment = 0;

    if (sp != null && e.getScrollAmount() != 0) {
        Adjustable adj = getAdjustableToScroll(sp);
        if (adj != null) {
            increment = getIncrementFromAdjustable(adj, e);
            if (log.isLoggable(PlatformLogger.Level.FINER)) {
                log.finer("increment from adjustable(" + adj.getClass() + ") : " + increment);
            }
            scrollAdjustable(adj, increment);
        }
    }
}
 
Example #6
Source File: ScrollPanePreferredSize.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) {
    final Dimension expected = new Dimension(300, 300);
    final Frame frame = new Frame();
    final ScrollPane sp = new ScrollPane();
    sp.setSize(expected);
    frame.add(sp);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    sleep();
    final Dimension size = frame.getSize();
    if (size.width < expected.width || size.height < expected.height) {
        throw new RuntimeException(
                "Expected size: >= " + expected + ", actual size: " + size);
    }
    frame.dispose();
}
 
Example #7
Source File: ScrollPanePreferredSize.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) {
    final Dimension expected = new Dimension(300, 300);
    final Frame frame = new Frame();
    final ScrollPane sp = new ScrollPane();
    sp.setSize(expected);
    frame.add(sp);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    sleep();
    final Dimension size = frame.getSize();
    if (size.width < expected.width || size.height < expected.height) {
        throw new RuntimeException(
                "Expected size: >= " + expected + ", actual size: " + size);
    }
    frame.dispose();
}
 
Example #8
Source File: MidiCommunication.java    From jmg with GNU General Public License v2.0 6 votes vote down vote up
private void fillFrame(Frame f, List dataList, MidiDevice.Info[] info) {
    try {
        f.setSize(340, 200);
        f.setLocation(Toolkit.getDefaultToolkit().getScreenSize().width / 2 - 170, 
                      Toolkit.getDefaultToolkit().getScreenSize().height / 2 - 100);
        String[] data = new String[info.length];
        data[0] = "" + info[0];
        data[1] = "" + info[1];
        for(int i=2; i< info.length; i++) {
            data[i] = MidiSystem.getMidiDevice(info[i]).toString();
        }
        for(int i=0; i< info.length; i++) {
            dataList.add(data[i]);
        }
        ScrollPane scrollPane = new ScrollPane();
        scrollPane.add(dataList);
        f.add(scrollPane);
    } catch (Exception e) {
        System.out.println (e);
        System.exit (0);
    }
    
}
 
Example #9
Source File: ScrollPanePreferredSize.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) {
    final Dimension expected = new Dimension(300, 300);
    final Frame frame = new Frame();
    final ScrollPane sp = new ScrollPane();
    sp.setSize(expected);
    frame.add(sp);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    sleep();
    final Dimension size = frame.getSize();
    if (size.width < expected.width || size.height < expected.height) {
        throw new RuntimeException(
                "Expected size: >= " + expected + ", actual size: " + size);
    }
    frame.dispose();
}
 
Example #10
Source File: ScrollPaneWheelScroller.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public static void handleWheelScrolling(ScrollPane sp, MouseWheelEvent e) {
    if (log.isLoggable(PlatformLogger.Level.FINER)) {
        log.finer("x = " + e.getX() + ", y = " + e.getY() + ", src is " + e.getSource());
    }
    int increment = 0;

    if (sp != null && e.getScrollAmount() != 0) {
        Adjustable adj = getAdjustableToScroll(sp);
        if (adj != null) {
            increment = getIncrementFromAdjustable(adj, e);
            if (log.isLoggable(PlatformLogger.Level.FINER)) {
                log.finer("increment from adjustable(" + adj.getClass() + ") : " + increment);
            }
            scrollAdjustable(adj, increment);
        }
    }
}
 
Example #11
Source File: ScrollPanePreferredSize.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) {
    final Dimension expected = new Dimension(300, 300);
    final Frame frame = new Frame();
    final ScrollPane sp = new ScrollPane();
    sp.setSize(expected);
    frame.add(sp);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    sleep();
    final Dimension size = frame.getSize();
    if (size.width < expected.width || size.height < expected.height) {
        throw new RuntimeException(
                "Expected size: >= " + expected + ", actual size: " + size);
    }
    frame.dispose();
}
 
Example #12
Source File: ScrollPanePreferredSize.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) {
    final Dimension expected = new Dimension(300, 300);
    final Frame frame = new Frame();
    final ScrollPane sp = new ScrollPane();
    sp.setSize(expected);
    frame.add(sp);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    sleep();
    final Dimension size = frame.getSize();
    if (size.width < expected.width || size.height < expected.height) {
        throw new RuntimeException(
                "Expected size: >= " + expected + ", actual size: " + size);
    }
    frame.dispose();
}
 
Example #13
Source File: ScrollPaneWheelScroller.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void handleWheelScrolling(ScrollPane sp, MouseWheelEvent e) {
    if (log.isLoggable(PlatformLogger.Level.FINER)) {
        log.finer("x = " + e.getX() + ", y = " + e.getY() + ", src is " + e.getSource());
    }
    int increment = 0;

    if (sp != null && e.getScrollAmount() != 0) {
        Adjustable adj = getAdjustableToScroll(sp);
        if (adj != null) {
            increment = getIncrementFromAdjustable(adj, e);
            if (log.isLoggable(PlatformLogger.Level.FINER)) {
                log.finer("increment from adjustable(" + adj.getClass() + ") : " + increment);
            }
            scrollAdjustable(adj, increment);
        }
    }
}
 
Example #14
Source File: ScrollPaneWheelScroller.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public static void handleWheelScrolling(ScrollPane sp, MouseWheelEvent e) {
    if (log.isLoggable(PlatformLogger.Level.FINER)) {
        log.finer("x = " + e.getX() + ", y = " + e.getY() + ", src is " + e.getSource());
    }
    int increment = 0;

    if (sp != null && e.getScrollAmount() != 0) {
        Adjustable adj = getAdjustableToScroll(sp);
        if (adj != null) {
            increment = getIncrementFromAdjustable(adj, e);
            if (log.isLoggable(PlatformLogger.Level.FINER)) {
                log.finer("increment from adjustable(" + adj.getClass() + ") : " + increment);
            }
            scrollAdjustable(adj, increment);
        }
    }
}
 
Example #15
Source File: ScrollPanePreferredSize.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) {
    final Dimension expected = new Dimension(300, 300);
    final Frame frame = new Frame();
    final ScrollPane sp = new ScrollPane();
    sp.setSize(expected);
    frame.add(sp);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    sleep();
    final Dimension size = frame.getSize();
    if (size.width < expected.width || size.height < expected.height) {
        throw new RuntimeException(
                "Expected size: >= " + expected + ", actual size: " + size);
    }
    frame.dispose();
}
 
Example #16
Source File: ScrollPanePreferredSize.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) {
    final Dimension expected = new Dimension(300, 300);
    final Frame frame = new Frame();
    final ScrollPane sp = new ScrollPane();
    sp.setSize(expected);
    frame.add(sp);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    sleep();
    final Dimension size = frame.getSize();
    if (size.width < expected.width || size.height < expected.height) {
        throw new RuntimeException(
                "Expected size: >= " + expected + ", actual size: " + size);
    }
    frame.dispose();
}
 
Example #17
Source File: ScrollPaneWheelScroller.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void handleWheelScrolling(ScrollPane sp, MouseWheelEvent e) {
    if (log.isLoggable(PlatformLogger.Level.FINER)) {
        log.finer("x = " + e.getX() + ", y = " + e.getY() + ", src is " + e.getSource());
    }
    int increment = 0;

    if (sp != null && e.getScrollAmount() != 0) {
        Adjustable adj = getAdjustableToScroll(sp);
        if (adj != null) {
            increment = getIncrementFromAdjustable(adj, e);
            if (log.isLoggable(PlatformLogger.Level.FINER)) {
                log.finer("increment from adjustable(" + adj.getClass() + ") : " + increment);
            }
            scrollAdjustable(adj, increment);
        }
    }
}
 
Example #18
Source File: ScrollPaneWheelScroller.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public static void handleWheelScrolling(ScrollPane sp, MouseWheelEvent e) {
    if (log.isLoggable(PlatformLogger.Level.FINER)) {
        log.finer("x = " + e.getX() + ", y = " + e.getY() + ", src is " + e.getSource());
    }
    int increment = 0;

    if (sp != null && e.getScrollAmount() != 0) {
        Adjustable adj = getAdjustableToScroll(sp);
        if (adj != null) {
            increment = getIncrementFromAdjustable(adj, e);
            if (log.isLoggable(PlatformLogger.Level.FINER)) {
                log.finer("increment from adjustable(" + adj.getClass() + ") : " + increment);
            }
            scrollAdjustable(adj, increment);
        }
    }
}
 
Example #19
Source File: VncClient.java    From cloudstack with Apache License 2.0 6 votes vote down vote up
private Frame createVncClientMainWindow(BufferedImageCanvas canvas, String title) {
    // Create AWT windows
    final Frame frame = new Frame(title + " - VNCle");

    // Use scrolling pane to support screens, which are larger than ours
    ScrollPane scroller = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED);
    scroller.add(canvas);
    scroller.setSize(screen.getFramebufferWidth(), screen.getFramebufferHeight());

    frame.add(scroller);
    frame.pack();
    frame.setVisible(true);

    frame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent evt) {
            frame.setVisible(false);
            shutdown();
        }
    });

    return frame;
}
 
Example #20
Source File: VncClient.java    From cosmic with Apache License 2.0 6 votes vote down vote up
private Frame createVncClientMainWindow(final BufferedImageCanvas canvas, final String title) {
    // Create AWT windows
    final Frame frame = new Frame(title + " - VNCle");

    // Use scrolling pane to support screens, which are larger than ours
    final ScrollPane scroller = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED);
    scroller.add(canvas);
    scroller.setSize(this.screen.getFramebufferWidth(), this.screen.getFramebufferHeight());

    frame.add(scroller);
    frame.pack();
    frame.setVisible(true);

    frame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(final WindowEvent evt) {
            frame.setVisible(false);
            shutdown();
        }
    });

    return frame;
}
 
Example #21
Source File: ScrollPanePreferredSize.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) {
    final Dimension expected = new Dimension(300, 300);
    final Frame frame = new Frame();
    final ScrollPane sp = new ScrollPane();
    sp.setSize(expected);
    frame.add(sp);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    sleep();
    final Dimension size = frame.getSize();
    if (size.width < expected.width || size.height < expected.height) {
        throw new RuntimeException(
                "Expected size: >= " + expected + ", actual size: " + size);
    }
    frame.dispose();
}
 
Example #22
Source File: ScrollPaneWheelScroller.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void handleWheelScrolling(ScrollPane sp, MouseWheelEvent e) {
    if (log.isLoggable(PlatformLogger.Level.FINER)) {
        log.finer("x = " + e.getX() + ", y = " + e.getY() + ", src is " + e.getSource());
    }
    int increment = 0;

    if (sp != null && e.getScrollAmount() != 0) {
        Adjustable adj = getAdjustableToScroll(sp);
        if (adj != null) {
            increment = getIncrementFromAdjustable(adj, e);
            if (log.isLoggable(PlatformLogger.Level.FINER)) {
                log.finer("increment from adjustable(" + adj.getClass() + ") : " + increment);
            }
            scrollAdjustable(adj, increment);
        }
    }
}
 
Example #23
Source File: ScrollPaneOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps {@code ScrollPane.getScrollPosition()} through queue
 */
public Point getScrollPosition() {
    return (runMapping(new MapAction<Point>("getScrollPosition") {
        @Override
        public Point map() {
            return ((ScrollPane) getSource()).getScrollPosition();
        }
    }));
}
 
Example #24
Source File: arffTransferNodePanel.java    From ETL_Unicorn with Apache License 2.0 5 votes vote down vote up
public arffTransferNodePanel(final arffTransferNodeRun thisRun){
setLayout(null);
scrollPane = new ScrollPane();
add(scrollPane);
panel= new Panel();
panel.setLayout(null);
panel.setBackground(Color.white);
JButton button= new JButton("Finish");
button.setBounds(0, 0, 100, 30);
button.addActionListener(new ActionListener(){
          public void actionPerformed(ActionEvent e){
          	System.out.println(e.getSource());
              	close=true;
              	thisRun.value=1;
              	//���isConfiged���д�������Ϊ����һ������ִ�е��жϹؼ��֣�һ�������óɹ��Ž��и�ֵ��20190622                	
              	//this.isConfiged= true;
          }
      });   
panel.add(button);
JButton readfile= new JButton("Write File");
readfile.setBounds(0, 35, 100, 65);
readfile.addActionListener(new ActionListener(){
	public void actionPerformed(ActionEvent arg0) {
		 filedialog=new FileDialog(new Frame(),"filechoose",FileDialog.LOAD);
		 filedialog.setVisible(true);
		 thisRun.filepath=filedialog.getDirectory()+filedialog.getFile();
	     System.out.println(thisRun.filepath);
		}
	});
panel.add(readfile);
scrollPane.add(panel);
close= false;
}
 
Example #25
Source File: ScrollPaneOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps {@code ScrollPane.getVScrollbarWidth()} through queue
 */
public int getVScrollbarWidth() {
    return (runMapping(new MapIntegerAction("getVScrollbarWidth") {
        @Override
        public int map() {
            return ((ScrollPane) getSource()).getVScrollbarWidth();
        }
    }));
}
 
Example #26
Source File: ScrollPaneOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps {@code ScrollPane.setScrollPosition(int, int)} through queue
 */
public void setScrollPosition(final int i, final int i1) {
    runMapping(new MapVoidAction("setScrollPosition") {
        @Override
        public void map() {
            ((ScrollPane) getSource()).setScrollPosition(i, i1);
        }
    });
}
 
Example #27
Source File: ScrollPaneOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps {@code ScrollPane.paramString()} through queue
 */
public String paramString() {
    return (runMapping(new MapAction<String>("paramString") {
        @Override
        public String map() {
            return ((ScrollPane) getSource()).paramString();
        }
    }));
}
 
Example #28
Source File: ScrollPaneOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps {@code ScrollPane.setScrollPosition(Point)} through queue
 */
public void setScrollPosition(final Point point) {
    runMapping(new MapVoidAction("setScrollPosition") {
        @Override
        public void map() {
            ((ScrollPane) getSource()).setScrollPosition(point);
        }
    });
}
 
Example #29
Source File: ScrollPaneOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps {@code ScrollPane.getHScrollbarHeight()} through queue
 */
public int getHScrollbarHeight() {
    return (runMapping(new MapIntegerAction("getHScrollbarHeight") {
        @Override
        public int map() {
            return ((ScrollPane) getSource()).getHScrollbarHeight();
        }
    }));
}
 
Example #30
Source File: ScrollPaneWheelScroller.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static Adjustable getAdjustableToScroll(ScrollPane sp) {
    int policy = sp.getScrollbarDisplayPolicy();

    // if policy is display always or never, use vert
    if (policy == ScrollPane.SCROLLBARS_ALWAYS ||
        policy == ScrollPane.SCROLLBARS_NEVER) {
        if (log.isLoggable(PlatformLogger.Level.FINER)) {
            log.finer("using vertical scrolling due to scrollbar policy");
        }
        return sp.getVAdjustable();

    }
    else {

        Insets ins = sp.getInsets();
        int vertScrollWidth = sp.getVScrollbarWidth();

        if (log.isLoggable(PlatformLogger.Level.FINER)) {
            log.finer("insets: l = " + ins.left + ", r = " + ins.right +
             ", t = " + ins.top + ", b = " + ins.bottom);
            log.finer("vertScrollWidth = " + vertScrollWidth);
        }

        // Check if scrollbar is showing by examining insets of the
        // ScrollPane
        if (ins.right >= vertScrollWidth) {
            if (log.isLoggable(PlatformLogger.Level.FINER)) {
                log.finer("using vertical scrolling because scrollbar is present");
            }
            return sp.getVAdjustable();
        }
        else {
            int horizScrollHeight = sp.getHScrollbarHeight();
            if (ins.bottom >= horizScrollHeight) {
                if (log.isLoggable(PlatformLogger.Level.FINER)) {
                    log.finer("using horiz scrolling because scrollbar is present");
                }
                return sp.getHAdjustable();
            }
            else {
                if (log.isLoggable(PlatformLogger.Level.FINER)) {
                    log.finer("using NO scrollbar becsause neither is present");
                }
                return null;
            }
        }
    }
}