List of usage examples for java.awt Adjustable getOrientation
int getOrientation();
From source file:Main.java
public void adjustmentValueChanged(AdjustmentEvent evt) { Adjustable source = evt.getAdjustable(); if (evt.getValueIsAdjusting()) { return;//from w ww . j a v a 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);/* w w w. j av a 2 s . c o m*/ 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); } }