Example usage for java.awt.event AdjustmentEvent getValue

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

Introduction

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

Prototype

public int getValue() 

Source Link

Document

Returns the current value in the adjustment event.

Usage

From source file:com.pingtel.sipviewer.SIPViewerFrame.java

@Override
public void adjustmentValueChanged(AdjustmentEvent e) {
    // we detect which vertical bar has been adjusted then
    // we make same scroll changes to the index column
    // that shows time, also scrolling in time index column
    // triggers scrolling in the respective scroll pane
    if (e.getSource().equals(m_scrollPaneVBar))
        m_scrollPaneTimeIndexVBar.setValue(e.getValue());
    else if (e.getSource().equals(m_scrollPaneVBarSecond))
        m_scrollPaneTimeIndexVBarSecond.setValue(e.getValue());
    else if (e.getSource().equals(m_scrollPaneTimeIndexVBar))
        m_scrollPaneVBar.setValue(e.getValue());
    else if (e.getSource().equals(m_scrollPaneTimeIndexVBarSecond))
        m_scrollPaneVBarSecond.setValue(e.getValue());

}

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

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

        htmlPane.setEditable(false);//from  w ww  . j  av a2  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);
    }
}

From source file:ua.com.fielden.platform.example.swing.egi.EgiExample.java

private void addTotalsFooterTo(final EntityGridInspector egi, final JPanel topPanel) {
    //   final JPanel panel = new JPanel(new MigLayout("insets 0", "[]", "[]0[]push[]"));
    //   panel.add(egi.getTableHeader(), "grow, wrap");
    //   panel.add(egi, "grow, wrap");

    final JScrollPane scrollPane = new JScrollPane(egi);
    topPanel.add(scrollPane, "grow, wrap");

    final JPanel footer = new JPanel(new MigLayout("nogrid, insets 0"));
    //   footer.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
    final List<JComponent> totalsComponents = new ArrayList<JComponent>();
    for (int i = 0; i < egi.getColumnCount(); i++) {
        final TableColumn column = egi.getColumnModel().getColumn(i);
        final JComponent totalsComponent = i % 2 == 0 ? new JTextField("totals " + i) : new JLabel();
        totalsComponent.setPreferredSize(new Dimension(column.getPreferredWidth(), 30));

        footer.add(totalsComponent, "grow");
        totalsComponents.add(totalsComponent);
    }//w  w w. j a v  a 2  s  .c o  m

    final JScrollPane footerPane = new JScrollPane(footer, JScrollPane.VERTICAL_SCROLLBAR_NEVER,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    topPanel.add(footerPane, "grow, wrap, h 40::");
    topPanel.add(scrollPane.getHorizontalScrollBar(), "grow, wrap");

    scrollPane.getHorizontalScrollBar().addAdjustmentListener(new AdjustmentListener() {
        @Override
        public void adjustmentValueChanged(final AdjustmentEvent e) {
            footerPane.getViewport().setViewPosition(new Point(e.getValue(), 0));
        }
    });

    egi.getColumnModel().addColumnModelListener(new TableColumnModelListener() {
        @Override
        public void columnAdded(final TableColumnModelEvent e) {
        }

        @Override
        public void columnMarginChanged(final ChangeEvent e) {
            final TableColumn column = egi.getTableHeader().getResizingColumn();
            if (column != null) {
                final JComponent totalsComponent = totalsComponents
                        .get(egi.convertColumnIndexToView(column.getModelIndex()));
                totalsComponent.setPreferredSize(new Dimension(column.getWidth(), totalsComponent.getHeight()));
                footer.revalidate();
            }
        }

        @Override
        public void columnMoved(final TableColumnModelEvent e) {
            final JComponent fromComponent = totalsComponents.get(e.getFromIndex());
            totalsComponents.set(e.getFromIndex(), totalsComponents.get(e.getToIndex()));
            totalsComponents.set(e.getToIndex(), fromComponent);

            footer.removeAll();
            for (int i = 0; i < egi.getColumnCount(); i++) {
                footer.add(totalsComponents.get(i), "grow, gap 0 0 0 0");
            }
            footer.revalidate();
        }

        @Override
        public void columnRemoved(final TableColumnModelEvent e) {
        }

        @Override
        public void columnSelectionChanged(final ListSelectionEvent e) {
        }
    });
    //
    //   return panel;
}