Example usage for java.awt.event AdjustmentEvent UNIT_INCREMENT

List of usage examples for java.awt.event AdjustmentEvent UNIT_INCREMENT

Introduction

In this page you can find the example usage for java.awt.event AdjustmentEvent UNIT_INCREMENT.

Prototype

int UNIT_INCREMENT

To view the source code for java.awt.event AdjustmentEvent UNIT_INCREMENT.

Click Source Link

Document

The unit increment adjustment type.

Usage

From source file:Main.java

private static void dumpInfo(AdjustmentEvent e) {
    System.out.println("Value: " + e.getValue());
    String type = null;/*  w  ww  . j  a v  a 2s  . c  o m*/
    switch (e.getAdjustmentType()) {
    case AdjustmentEvent.TRACK:
        type = "Track";
        break;
    case AdjustmentEvent.BLOCK_DECREMENT:
        type = "Block Decrement";
        break;
    case AdjustmentEvent.BLOCK_INCREMENT:
        type = "Block Increment";
        break;
    case AdjustmentEvent.UNIT_DECREMENT:
        type = "Unit Decrement";
        break;
    case AdjustmentEvent.UNIT_INCREMENT:
        type = "Unit Increment";
        break;
    }
    System.out.println("Type: " + type);
}

From source file:Main.java

private static void dumpInfo(AdjustmentEvent e) {
    System.out.println("\tValue: " + e.getValue());
    String type = null;/*from w  w w. j a  v a2s.co  m*/
    switch (e.getAdjustmentType()) {
    case AdjustmentEvent.TRACK:
        type = "Track";
        break;
    case AdjustmentEvent.BLOCK_DECREMENT:
        type = "Block Decrement";
        break;
    case AdjustmentEvent.BLOCK_INCREMENT:
        type = "Block Increment";
        break;
    case AdjustmentEvent.UNIT_DECREMENT:
        type = "Unit Decrement";
        break;
    case AdjustmentEvent.UNIT_INCREMENT:
        type = "Unit Increment";
        break;
    }
    System.out.println("\tType: " + type);
}

From source file:Main.java

public void adjustmentValueChanged(AdjustmentEvent evt) {
    Adjustable source = evt.getAdjustable();
    if (evt.getValueIsAdjusting()) {
        return;//from  ww  w .  ja va 2  s.c  o  m
    }
    int orient = source.getOrientation();
    if (orient == Adjustable.HORIZONTAL) {
        System.out.println("from horizontal scrollbar");
    } else {
        System.out.println("from vertical scrollbar");
    }
    int type = evt.getAdjustmentType();
    switch (type) {
    case AdjustmentEvent.UNIT_INCREMENT:
        System.out.println("Scrollbar was increased by one unit");
        break;
    case AdjustmentEvent.UNIT_DECREMENT:
        System.out.println("Scrollbar was decreased by one unit");
        break;
    case AdjustmentEvent.BLOCK_INCREMENT:
        System.out.println("Scrollbar was increased by one block");
        break;
    case AdjustmentEvent.BLOCK_DECREMENT:
        System.out.println("Scrollbar was decreased by one block");
        break;
    case AdjustmentEvent.TRACK:
        System.out.println("The knob on the scrollbar was dragged");
        break;
    }
    int value = evt.getValue();
}

From source file:brainleg.app.intellij.ui.EForm.java

private void configureHtmlPane() {
    if (htmlPane == null) {
        htmlPane = new JEditorPane();

        htmlPane.setEditable(false);/*www  . j  a  va2  s  .c  om*/

        HTMLEditorKit kit = new HTMLEditorKit();
        htmlPane.setEditorKit(kit);

        JScrollPane scrollPane = new JBScrollPane(htmlPane);

        scrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() {
            public void adjustmentValueChanged(AdjustmentEvent e) {
                Adjustable source = e.getAdjustable();

                // check if user is currently dragging the scrollbar's knob
                if (e.getValueIsAdjusting()) {
                    return;
                }

                int orient = source.getOrientation();
                if (orient == Adjustable.HORIZONTAL) {
                    return; //we are not interested in horizontal scroll
                }

                // get the type of adjustment which caused the value changed event
                int type = e.getAdjustmentType();
                switch (type) {
                case AdjustmentEvent.UNIT_INCREMENT:
                    //                            System.out.println("increased by one unit");
                    break;

                case AdjustmentEvent.UNIT_DECREMENT:
                    //                            System.out.println("decreased by one unit");
                    break;

                case AdjustmentEvent.BLOCK_INCREMENT:
                    //                            System.out.println("increased by one block");
                    break;

                case AdjustmentEvent.BLOCK_DECREMENT:
                    //                            System.out.println("decreased by one block");
                    break;

                case AdjustmentEvent.TRACK:
                    //                            System.out.println("knob on the scrollbar was dragged");
                    break;

                }

                // get the current value in the adjustment event
                int value = e.getValue();
                //                    System.out.println("Current Value: " + value);
                if (value > 200) {
                    //this is about click middle mouse flip - i.e. about 15% of vertical space (approx)
                    markExceptionAsDontShowNotificationFor();
                }
            }
        });

        StyleSheet styleSheet = kit.getStyleSheet();
        CssUtil.addStyles(styleSheet);

        configureNewHtmlDocument();

        htmlPane.addHyperlinkListener(new HyperlinkListener() {
            public void hyperlinkUpdate(HyperlinkEvent e) {
                if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                    try {
                        URL url = e.getURL();
                        if (url != null) {
                            BrowserUtil.launchBrowser(url.toString());
                        }
                    } catch (Throwable t) {
                        t.printStackTrace();
                    }
                }
            }
        });
        solutionPanel.add(scrollPane);
    }
}