Java Examples for javax.swing.JScrollBar

The following java examples will help you to understand the usage of javax.swing.JScrollBar. These source code samples are taken from different open source projects.

Example 1
Project: QuaquaOld-master  File: QuaquaLionScrollBarTrackBorder.java View source code
public void paintBorder(Component c, Graphics gr, int x, int y, int width, int height) {
    JScrollBar sb = (JScrollBar) c;
    Container parent = sb.getParent();
    JScrollPane sp = (parent instanceof JScrollPane) ? (JScrollPane) parent : null;
    Dimension ps = sb.getUI().getPreferredSize(sb);
    Graphics2D g = (Graphics2D) gr;
    Object oldHints = QuaquaUtilities.beginGraphics(g);
    // Draw filled gradient track if not in scroll pane
    if (sb.getOrientation() == SwingConstants.HORIZONTAL) {
        height = Math.min(ps.height, height);
        g.setColor(topColor);
        g.drawLine(x, y, x + width - 1, y);
        g.setColor(bottomColor);
        g.drawLine(x, y + height - 2, x + width - 1, y + height - 2);
        int tx = x + 1;
        int ty = y + 1;
        int tw = width - 2;
        int th = height - 2;
        g.setPaint(new LinearGradientPaint(tx, ty, tx, ty + th - 1, gradientFractions, gradientColors));
        g.fillRect(tx, ty, tw, th);
    } else {
        width = Math.min(ps.width, width);
        g.setColor(topColor);
        g.drawLine(x, y, x, y + height - 1);
        g.setColor(bottomColor);
        g.drawLine(x + width - 2, y, x + width - 2, y + height - 1);
        int tx = x + 1;
        int ty = y + 1;
        int tw = width - 2;
        int th = height - 2;
        g.setPaint(new LinearGradientPaint(tx, ty, tx + width - 1, ty, gradientFractions, gradientColors));
        g.fillRect(tx, ty, tw, th);
    }
    // Draw round rect track
    if (false && sp != null) {
        if (sb.getValueIsAdjusting()) {
            if (sb.getOrientation() == SwingConstants.HORIZONTAL) {
                height = Math.min(ps.height, height);
                int tx = x + 2;
                int ty = y + 2;
                int tw = width - 4;
                int th = height - 4;
                g.setPaint(new LinearGradientPaint(tx, ty, tx, ty + th - 1, rrectGradientFractions, rrectGradientColors));
                g.fillRoundRect(tx, ty, tw, th, th, th);
                g.setColor(rrectColor);
                g.drawRoundRect(tx, ty, tw, th - 1, th - 1, th - 1);
            } else {
                width = Math.min(ps.width, width);
                int tx = x + 2;
                int ty = y + 2;
                int tw = width - 4;
                int th = height - 4;
                g.setPaint(new LinearGradientPaint(tx, ty, tx + width - 1, ty, rrectGradientFractions, rrectGradientColors));
                g.fillRoundRect(tx, ty, tw, th, tw, tw);
                g.setColor(rrectColor);
                g.drawRoundRect(tx, ty, tw - 1, th, tw - 1, tw - 1);
            }
        }
    }
    if (false && sp != null && sp.getViewport().getView() != null) {
        Color bg = sp.getViewport().getView().getBackground();
        g.setPaint(PaintableColor.getPaint(bg, sp.getViewport().getView()));
        g.fillRect(x, y, width, height);
    }
    QuaquaUtilities.endGraphics(g, oldHints);
}
Example 2
Project: assertj-swing-master  File: Formatting_format_Test.java View source code
@Test
public void should_Format_JScrollBar() {
    JScrollBar scrollBar = scrollBar().withBlockIncrement(10).withMinimum(0).withMaximum(60).withName("scrollBar").withOrientation(VERTICAL).withValue(20).createNew();
    assertThat(formatted(scrollBar)).contains("javax.swing.JScrollBar").contains("name='scrollBar'").contains("value=20").contains("blockIncrement=10").contains("minimum=0").contains("maximum=60").contains("enabled=true").contains("visible=true").contains("showing=false");
}
Example 3
Project: MCFreedomLauncher-master  File: ConsoleTab.java View source code
public void print(final String line) {
    if (!SwingUtilities.isEventDispatchThread()) {
        SwingUtilities.invokeLater(new Runnable() {

            public void run() {
                ConsoleTab.this.print(line);
            }
        });
        return;
    }
    Document document = this.console.getDocument();
    JScrollBar scrollBar = getVerticalScrollBar();
    boolean shouldScroll = false;
    if (getViewport().getView() == this.console) {
        shouldScroll = scrollBar.getValue() + scrollBar.getSize().getHeight() + MONOSPACED.getSize() * 4 > scrollBar.getMaximum();
    }
    try {
        document.insertString(document.getLength(), line, null);
    } catch (BadLocationException localBadLocationException) {
    }
    if (shouldScroll)
        scrollBar.setValue(2147483647);
}
Example 4
Project: navigps-master  File: LineScrollBarUI.java View source code
/**
     *
     * @param g
     * @param c
     * @param trackBounds
     */
@Override
protected void paintTrack(Graphics g, JComponent c, Rectangle trackBounds) {
    //super.paintTrack(g, c, trackBounds);
    Graphics2D g2 = (Graphics2D) g;
    //g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g.translate(trackBounds.x, trackBounds.y);
    boolean leftToRight = c.getComponentOrientation().isLeftToRight();
    if (scrollbar.getOrientation() == JScrollBar.VERTICAL) {
        if (!isFreeStanding) {
            trackBounds.width += 2;
            if (!leftToRight) {
                g2.translate(-1, 0);
            }
        }
        if (c.isEnabled()) {
            // VERTICAL
            g2.setColor(darkShadowColor);
            int halfArea = trackBounds.width / 2;
            g2.drawLine(halfArea, 3, halfArea, trackBounds.height);
            g2.setColor(shadowColor);
            for (int i = 1; i < 3; i++) {
                int delta = i * 50;
                g2.setColor(Utils.checkColor(darkShadowColor.getRed() + delta, darkShadowColor.getGreen() + delta, darkShadowColor.getBlue() + delta));
                g2.drawLine(halfArea + i, 3 - i, halfArea + i, trackBounds.height - i);
            }
        } else {
        //MetalUtils.drawDisabledBorder(g, 0, 0, trackBounds.width, trackBounds.height );
        }
        if (!isFreeStanding) {
            trackBounds.width -= 2;
            if (!leftToRight) {
                g2.translate(1, 0);
            }
        }
    } else {
        if (!isFreeStanding) {
            trackBounds.height += 2;
        }
        if (c.isEnabled()) {
            g2.setColor(darkShadowColor);
            int halfArea = trackBounds.height / 2;
            g2.drawLine(0, halfArea, trackBounds.width - 3, halfArea);
            g2.setColor(shadowColor);
            for (int i = 1; i < 3; i++) {
                int delta = i * 50;
                g2.setColor(Utils.checkColor(darkShadowColor.getRed() + delta, darkShadowColor.getGreen() + delta, darkShadowColor.getBlue() + delta));
                g2.drawLine(i, halfArea + i, trackBounds.width - 2, halfArea + i);
            }
        } else {
        //MetalUtils.drawDisabledBorder(g, 0, 0, trackBounds.width, trackBounds.height );
        }
        if (!isFreeStanding) {
            trackBounds.height -= 2;
        }
    }
    g2.translate(-trackBounds.x, -trackBounds.y);
}
Example 5
Project: openjdk-master  File: LWTextAreaPeer.java View source code
@Override
public Dimension getMinimumSize(final int rows, final int columns) {
    final Dimension size = super.getMinimumSize(rows, columns);
    synchronized (getDelegateLock()) {
        // JScrollPane insets
        final Insets pi = getDelegate().getInsets();
        size.width += pi.left + pi.right;
        size.height += pi.top + pi.bottom;
        // Take scrollbars into account.
        final int vsbPolicy = getDelegate().getVerticalScrollBarPolicy();
        if (vsbPolicy == ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS) {
            final JScrollBar vbar = getDelegate().getVerticalScrollBar();
            size.width += vbar != null ? vbar.getMinimumSize().width : 0;
        }
        final int hsbPolicy = getDelegate().getHorizontalScrollBarPolicy();
        if (hsbPolicy == ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS) {
            final JScrollBar hbar = getDelegate().getHorizontalScrollBar();
            size.height += hbar != null ? hbar.getMinimumSize().height : 0;
        }
    }
    return size;
}
Example 6
Project: fest-swing-1.x-master  File: Formatting_format_Test.java View source code
@Test
public void should_format_JScrollBar() {
    JScrollBar scrollBar = scrollBar().withBlockIncrement(10).withMinimum(0).withMaximum(60).withName("scrollBar").withOrientation(VERTICAL).withValue(20).createNew();
    assertThat(formatted(scrollBar)).contains("javax.swing.JScrollBar").contains("name='scrollBar'").contains("value=20").contains("blockIncrement=10").contains("minimum=0").contains("maximum=60").contains("enabled=true").contains("visible=true").contains("showing=false");
}
Example 7
Project: violetumleditor-master  File: DragGraphBehavior.java View source code
@Override
public void onMousePressed(MouseEvent event) {
    if (event.getClickCount() > 1) {
        return;
    }
    if (event.getButton() != MouseEvent.BUTTON1) {
        return;
    }
    if (!KeyModifierUtil.isCtrl(event)) {
        return;
    }
    IEditorPart editorPart = this.workspace.getEditorPart();
    double zoom = editorPart.getZoomFactor();
    final Point2D mousePointOnGraph = new Point2D.Double(event.getX() / zoom, event.getY() / zoom);
    if (!isMouseOnNode(mousePointOnGraph) && !isMouseOnEdge(mousePointOnGraph)) {
        WorkspacePanel workspacePanel = this.workspace.getAWTComponent();
        JScrollPane scrollableEditorPart = workspacePanel.getScrollableEditorPart();
        JScrollBar verticalScrollBar = scrollableEditorPart.getVerticalScrollBar();
        JScrollBar horizontalScrollBar = scrollableEditorPart.getHorizontalScrollBar();
        this.isReadyForDragging = true;
        this.initialMousePoint = event.getLocationOnScreen();
        this.initialHorizontalScrollBarValue = horizontalScrollBar.getValue();
        this.initialVerticalScrollBarValue = verticalScrollBar.getValue();
        this.initialCursor = scrollableEditorPart.getCursor();
        scrollableEditorPart.setCursor(this.dragCursor);
    }
}
Example 8
Project: damp.ekeko.snippets-master  File: ScrollPaletteLayout.java View source code
/**
     * Lays out the container argument using this border layout. 
     * @param   target   the container in which to do the layout.
     */
public void layoutContainer(Container target) {
    if (viewport != null && incButton != null && decButton != null) {
        // getPreferredSize();
        Dimension extentSize = viewport.getExtentSize();
        Dimension viewSize = viewport.getViewSize();
        Point viewPosition = viewport.getViewPosition();
        switch(orientation) {
            case JScrollBar.HORIZONTAL:
                boolean state;
                ButtonModel model;
                // increasing button
                model = decButton.getModel();
                state = viewPosition.x > 0 ? true : false;
                model.setEnabled(state);
                if (!model.isRollover())
                    decButton.setVisible(state);
                // decreasing button
                model = incButton.getModel();
                state = viewPosition.x + extentSize.width < viewSize.width ? true : false;
                model.setEnabled(state);
                if (!model.isRollover())
                    incButton.setVisible(state);
                break;
            case JScrollBar.VERTICAL:
                // PENDING(david)
                break;
        }
    }
    super.layoutContainer(target);
}
Example 9
Project: DataCleaner-master  File: DCTablePanel.java View source code
@Override
public Dimension getPreferredSize() {
    if (_scrollPane == null) {
        return super.getPreferredSize();
    }
    final Dimension tableSize = _table.getPreferredSize();
    final Dimension headerSize = _table.getTableHeader().getPreferredSize();
    final Dimension d = new Dimension();
    d.width = Math.max(tableSize.width, headerSize.width);
    d.height = headerSize.height + (_table.getRowHeight() * _table.getRowCount());
    final Insets insets = getInsets();
    d.height = d.height + insets.top + insets.bottom;
    final JScrollBar scrollBar = _scrollPane.getHorizontalScrollBar();
    final int scrollbarHeight = scrollBar.getHeight();
    d.height = d.height + scrollbarHeight;
    return d;
}
Example 10
Project: dipGame-master  File: WhiteTextArea.java View source code
public void append(String s, Color color, Boolean bold) {
    try {
        StyledDocument doc = (StyledDocument) text.getDocument();
        Style style = doc.addStyle("name", null);
        StyleConstants.setForeground(style, color);
        StyleConstants.setBold(style, bold);
        doc.insertString(doc.getLength(), s, style);
        // Determine whether the scrollbar is currently at the very bottom
        // position.
        JScrollBar vbar = scrollpane.getVerticalScrollBar();
        boolean autoScroll = ((vbar.getValue() + vbar.getVisibleAmount()) == vbar.getMaximum());
        // now scroll if we were already at the bottom.
        if (autoScroll) {
            text.setCaretPosition(text.getDocument().getLength());
        }
    } catch (BadLocationException exc) {
        exc.printStackTrace();
    }
}
Example 11
Project: fb-contrib-master  File: ICA_Sample.java View source code
public void fpICA() {
    JOptionPane.showMessageDialog(null, "hi", "there", JOptionPane.ERROR_MESSAGE);
    Border b = BorderFactory.createBevelBorder(BevelBorder.RAISED);
    b = BorderFactory.createEtchedBorder(EtchedBorder.RAISED, Color.RED, Color.BLUE);
    new Thread().setPriority(Thread.MAX_PRIORITY);
    JScrollBar sb = new JScrollBar(Adjustable.HORIZONTAL, 0, 10, 0, 100);
}
Example 12
Project: gtitool-master  File: TinyScrollPaneUI.java View source code
/**
   * Installs some default values for the given scrollpane. The free standing
   * property is disabled here.
   * 
   * @param mainColor The reference of the scrollpane to install its default
   *          values.
   */
public void installUI(JComponent c) {
    super.installUI(c);
    // Note: It never happened before Java 1.5 that scrollbar is null
    JScrollBar sb = scrollpane.getHorizontalScrollBar();
    if (sb != null) {
        sb.putClientProperty(MetalScrollBarUI.FREE_STANDING_PROP, Boolean.FALSE);
    }
    sb = scrollpane.getVerticalScrollBar();
    if (sb != null) {
        sb.putClientProperty(MetalScrollBarUI.FREE_STANDING_PROP, Boolean.FALSE);
    }
}
Example 13
Project: iranAdempiere-master  File: TinyScrollPaneUI.java View source code
/**
   * Installs some default values for the given scrollpane.
   * The free standing property is disabled here.
   *
   * @param mainColor The reference of the scrollpane to install its default values.
   */
public void installUI(JComponent c) {
    super.installUI(c);
    // Note: It never happened before Java 1.5 that scrollbar is null
    JScrollBar sb = scrollpane.getHorizontalScrollBar();
    if (sb != null) {
        sb.putClientProperty(MetalScrollBarUI.FREE_STANDING_PROP, Boolean.FALSE);
    }
    sb = scrollpane.getVerticalScrollBar();
    if (sb != null) {
        sb.putClientProperty(MetalScrollBarUI.FREE_STANDING_PROP, Boolean.FALSE);
    }
}
Example 14
Project: QuiltPlayer-master  File: WikiComponent.java View source code
public JPanel create(Album album) {
    WikipediaService ws = new WikipediaService();
    JEditorPane pane = null;
    try {
        pane = new JEditorPane(ws.getWikiContentForPageName(album.getArtist().getArtistName().getName()));
        pane.setForeground(ColorConstantsDark.PLAYLIST_LYRICS_COLOR);
        pane.setBackground(ColorConstantsDark.ARTISTS_PANEL_BACKGROUND);
    } catch (MalformedURLException e) {
        e.printStackTrace();
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    wikiScroller = new QScrollPane(pane, ScrollDirection.VERTICAL);
    wikiScroller.setVerticalScrollBar(new QScrollBar(JScrollBar.VERTICAL));
    wikiScroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    wikiScroller.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    wikiScroller.setBorder(BorderFactory.createEmptyBorder());
    wikiScroller.setWheelScrollingEnabled(true);
    wikiScroller.getVerticalScrollBar().setUnitIncrement(VERTICAL_UNIT_INCRENET);
    mainPanel.add(wikiScroller, "w 100%");
    return mainPanel;
}
Example 15
Project: seaglass-master  File: ScrollBarButtonsTogetherState.java View source code
/**
     * {@inheritDoc}
     */
public boolean isInState(JComponent c) {
    while (c != null && !(c instanceof JScrollBar)) {
        c = (JComponent) c.getParent();
    }
    if (c != null) {
        Object clientProperty = c.getClientProperty("SeaGlass.Override.ScrollBarButtonsTogether");
        if (clientProperty != null && clientProperty instanceof Boolean) {
            return (Boolean) clientProperty;
        }
    }
    return UIManager.getBoolean("SeaGlass.ScrollBarButtonsTogether");
}
Example 16
Project: tizzit-master  File: TinyScrollPaneUI.java View source code
/**
   * Installs some default values for the given scrollpane.
   * The free standing property is disabled here.
   *
   * @param mainColor The reference of the scrollpane to install its default values.
   */
public void installUI(JComponent c) {
    super.installUI(c);
    // Note: It never happened before Java 1.5 that scrollbar is null
    JScrollBar sb = scrollpane.getHorizontalScrollBar();
    if (sb != null) {
        sb.putClientProperty(MetalScrollBarUI.FREE_STANDING_PROP, Boolean.FALSE);
    }
    sb = scrollpane.getVerticalScrollBar();
    if (sb != null) {
        sb.putClientProperty(MetalScrollBarUI.FREE_STANDING_PROP, Boolean.FALSE);
    }
}
Example 17
Project: dataTracker-master  File: MyComboBox.java View source code
private void adjustScrollBar() {
    if (getItemCount() == 0) {
        return;
    }
    Object comp = getUI().getAccessibleChild(this, 0);
    if (!(comp instanceof JPopupMenu)) {
        return;
    }
    JPopupMenu popup = (JPopupMenu) comp;
    JScrollPane scrollPane = (JScrollPane) popup.getComponent(0);
    scrollPane.setHorizontalScrollBar(new JScrollBar(JScrollBar.HORIZONTAL));
    scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
}
Example 18
Project: freehep-ncolor-pdf-master  File: ScrollTest.java View source code
public static void main(String[] args) {
    JFrame frame = new JFrame();
    JPanel jcomponent = new TestPanel();
    jcomponent.setLayout(new BoxLayout(jcomponent, BoxLayout.X_AXIS));
    JScrollPane scroll = new JScrollPane(jcomponent);
    frame.setContentPane(scroll);
    scroll.setPreferredSize(new Dimension(300, 50));
    // Make a long row of buttons.
    int xmax = 32;
    for (int x = 0; x < xmax; x++) {
        JPanel button = new TestSubPanel("Test:" + x);
        jcomponent.add(button);
    }
    // Make the frame visible.
    frame.pack();
    frame.setVisible(true);
    // Reset the scroll bar to the middle of the row.
    JScrollBar bar = scroll.getHorizontalScrollBar();
    int max = bar.getMaximum();
    int min = bar.getMinimum();
    bar.setValue((max + min) / 2);
    ExportFileType epsOut = new EPSExportFileType();
    try {
        File file;
        FileOutputStream fos;
        System.out.println("\nPrinting image...\n");
        file = new File("ScrollTest.eps");
        fos = new FileOutputStream(file);
        epsOut.exportToFile(fos, scroll, frame, new Properties(), null);
        fos.close();
        System.out.println();
        System.out.println("An image of the frame should have been ");
        System.out.println("produced (ScrollTest.eps).  If this image ");
        System.out.println("is not correct, then check the clipping");
        System.out.println("rectangles in the graphics code.");
        System.out.println();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Example 19
Project: freehep-vectorgraphics-master  File: ScrollTest.java View source code
public static void main(String[] args) {
    JFrame frame = new JFrame();
    JPanel jcomponent = new TestPanel();
    jcomponent.setLayout(new BoxLayout(jcomponent, BoxLayout.X_AXIS));
    JScrollPane scroll = new JScrollPane(jcomponent);
    frame.setContentPane(scroll);
    scroll.setPreferredSize(new Dimension(300, 50));
    // Make a long row of buttons.
    int xmax = 32;
    for (int x = 0; x < xmax; x++) {
        JPanel button = new TestSubPanel("Test:" + x);
        jcomponent.add(button);
    }
    // Make the frame visible.
    frame.pack();
    frame.setVisible(true);
    // Reset the scroll bar to the middle of the row.
    JScrollBar bar = scroll.getHorizontalScrollBar();
    int max = bar.getMaximum();
    int min = bar.getMinimum();
    bar.setValue((max + min) / 2);
    ExportFileType epsOut = new EPSExportFileType();
    try {
        File file;
        FileOutputStream fos;
        System.out.println("\nPrinting image...\n");
        file = new File("ScrollTest.eps");
        fos = new FileOutputStream(file);
        epsOut.exportToFile(fos, scroll, frame, new Properties(), null);
        fos.close();
        System.out.println();
        System.out.println("An image of the frame should have been ");
        System.out.println("produced (ScrollTest.eps).  If this image ");
        System.out.println("is not correct, then check the clipping");
        System.out.println("rectangles in the graphics code.");
        System.out.println();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Example 20
Project: jazzautomation_source-master  File: ProgressTailer.java View source code
private void populateTextAreaFromQueue() {
    StringBuilder sb = new StringBuilder(queue.size());
    for (String line : queue) {
        sb.append(line).append('\n');
    }
    String text = sb.toString();
    text = StringUtils.removeEnd(text, "\n");
    outputTextArea.setText(text);
    JScrollBar verticalScrollBar = outputScrollPane.getVerticalScrollBar();
    BoundedRangeModel model = verticalScrollBar.getModel();
    int maximum = model.getMaximum();
    model.setValue(maximum);
}
Example 21
Project: jDip-master  File: XJSVGScroller.java View source code
public void mouseWheelMoved(MouseWheelEvent e) {
    final JScrollBar sb = (vertical.isVisible()) ? vertical : // vertical is preferred
    horizontal;
    if (sb.isVisible()) {
        if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) {
            final int amt = e.getUnitsToScroll() * sb.getUnitIncrement();
            sb.setValue(sb.getValue() + amt);
        } else if (e.getScrollType() == MouseWheelEvent.WHEEL_BLOCK_SCROLL) {
            final int amt = e.getWheelRotation() * sb.getBlockIncrement();
            sb.setValue(sb.getValue() + amt);
        }
    }
}
Example 22
Project: kahlua2-master  File: SyntaxTextAppender.java View source code
@Override
public void run() {
    JScrollBar vert = outputTerminal.scrollpane.getVerticalScrollBar();
    boolean isAtBottom = vert.getValue() + vert.getVisibleAmount() >= vert.getMaximum() - 32;
    outputTerminal.scrollDown = !vert.getValueIsAdjusting() && isAtBottom;
    try {
        Document document = outputTerminal.editorPane.getDocument();
        int startPos = document.getLength();
        Segment insertSegment = new Segment(text.toCharArray(), 0, text.length());
        ArrayList<Token> newTokens = new ArrayList<Token>();
        lexer.parse(insertSegment, 0, newTokens);
        outputTerminal.voidLexer.setNewTokens(newTokens, document.getLength());
        document.insertString(startPos, text, null);
    } catch (BadLocationException e) {
        e.printStackTrace();
    }
    latch.countDown();
}
Example 23
Project: kolmafia-master  File: StickyListener.java View source code
public void adjustmentValueChanged(AdjustmentEvent event) {
    JScrollBar bar = (JScrollBar) event.getSource();
    int value = event.getValue();
    int knob = bar.getVisibleAmount();
    int max = bar.getMaximum();
    boolean shouldBeSticky = value + knob > max - tolerance;
    if (this.currentlySticky != shouldBeSticky) {
        this.currentlySticky = shouldBeSticky;
        buffer.setSticky(this.editor, shouldBeSticky);
    }
}
Example 24
Project: pdfxtk-master  File: ButtonTreePathView.java View source code
public void setPath(TreePath path_, boolean lastIsLimit) {
    if (path_ == null)
        return;
    if (path_.equals(path))
        return;
    path = path_;
    removeAll();
    Object[] p = path.getPath();
    if (lastIsLimit)
        startDisplay = p.length - 1;
    for (int i = startDisplay; i < p.length; i++) {
        final int iterator = i;
        JButton button = Swing.newButton(p[iterator].toString(), new ActionListener() {

            int idx = iterator;

            public void actionPerformed(ActionEvent e) {
                synchronized (ButtonTreePathView.this) {
                    Object[] pOld = path.getPath();
                    Object[] pNew = new Object[idx + 1];
                    for (int j = 0; j < pNew.length; j++) pNew[j] = pOld[j];
                    path = new TreePath(pNew);
                    while (getComponentCount() > idx + 1 - startDisplay) remove(idx + 1 - startDisplay);
                }
                fireChangeEvent(new ChangeEvent(ButtonTreePathView.this));
                validate();
                repaint();
            }
        });
        button.setIcon(Resource.RIGHTARROW);
        button.setHorizontalTextPosition(button.LEADING);
        add(button);
    }
    if (getParent().getParent() instanceof JScrollPane) {
        getParent().getParent().validate();
        JScrollBar sb = ((JScrollPane) getParent().getParent()).getHorizontalScrollBar();
        sb.setValue(sb.getMaximum());
        repaint();
    } else {
        validate();
        repaint();
    }
    fireChangeEvent(new ChangeEvent(this));
}
Example 25
Project: xmlvm.svn-master  File: AccelerometerPanel.java View source code
private void addControls() {
    JLabel label;
    // X
    xAxisControl = new JScrollBar();
    setControlParameters(xAxisControl);
    xAxisControl.setLocation(20, 30);
    this.add(xAxisControl, 0);
    label = new JLabel("X");
    label.setBounds(20, 130, 20, 20);
    label.setHorizontalAlignment(SwingConstants.CENTER);
    this.add(label, 0);
    // Y
    yAxisControl = new JScrollBar();
    setControlParameters(yAxisControl);
    yAxisControl.setLocation(50, 30);
    this.add(yAxisControl, 0);
    label = new JLabel("Y");
    label.setBounds(50, 130, 20, 20);
    label.setHorizontalAlignment(SwingConstants.CENTER);
    this.add(label, 0);
    // Z
    zAxisControl = new JScrollBar();
    setControlParameters(zAxisControl);
    zAxisControl.setLocation(80, 30);
    this.add(zAxisControl, 0);
    label = new JLabel("Z");
    label.setBounds(80, 130, 20, 20);
    label.setHorizontalAlignment(SwingConstants.CENTER);
    this.add(label, 0);
}
Example 26
Project: cameracontrol-master  File: ImageFrame.java View source code
/** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
@SuppressWarnings("unchecked")
private // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
void initComponents() {
    scrollPaneJpeg = new javax.swing.JScrollPane(jpegPanel);
    bottomPanel = new javax.swing.JPanel();
    buttonsPanel = new javax.swing.JPanel();
    saveButton = new javax.swing.JButton();
    rawIcon = new javax.swing.JLabel();
    jpegIcon = new javax.swing.JLabel();
    jPanel1 = new javax.swing.JPanel();
    zoomFitButton = new javax.swing.JButton();
    zoom100Button = new javax.swing.JButton();
    zoomScrollbar = new javax.swing.JScrollBar();
    zoomValueBox = new javax.swing.JComboBox(ZOOM_VALUES);
    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    setIconImage(getImage(ICON_CAMERACONTROL));
    // NOI18N
    scrollPaneJpeg.setName("scrollpane");
    getContentPane().add(scrollPaneJpeg, java.awt.BorderLayout.CENTER);
    bottomPanel.setLayout(new javax.swing.BoxLayout(bottomPanel, javax.swing.BoxLayout.LINE_AXIS));
    buttonsPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEADING, 2, 3));
    saveButton.setFont(new java.awt.Font("Arial", 0, 10));
    // NOI18N
    saveButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/image-not-saved-16x16.png")));
    saveButton.setText("Save");
    saveButton.setMaximumSize(new java.awt.Dimension(56, 20));
    saveButton.setMinimumSize(new java.awt.Dimension(56, 20));
    saveButton.setPreferredSize(new java.awt.Dimension(56, 20));
    saveButton.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            saveButtonActionPerformed(evt);
        }
    });
    buttonsPanel.add(saveButton);
    // NOI18N
    rawIcon.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/raw.png")));
    buttonsPanel.add(rawIcon);
    // NOI18N
    jpegIcon.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/jpeg.png")));
    buttonsPanel.add(jpegIcon);
    bottomPanel.add(buttonsPanel);
    jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT, 0, 3));
    // NOI18N
    zoomFitButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/zoom-fit-best-16x16.png")));
    zoomFitButton.setMaximumSize(new java.awt.Dimension(20, 20));
    zoomFitButton.setMinimumSize(new java.awt.Dimension(20, 20));
    zoomFitButton.setPreferredSize(new java.awt.Dimension(20, 20));
    zoomFitButton.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            zoomFitButtonActionPerformed(evt);
        }
    });
    jPanel1.add(zoomFitButton);
    // NOI18N
    zoom100Button.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/zoom-original-16x16.png")));
    zoom100Button.setMaximumSize(new java.awt.Dimension(20, 20));
    zoom100Button.setMinimumSize(new java.awt.Dimension(20, 20));
    zoom100Button.setPreferredSize(new java.awt.Dimension(20, 20));
    zoom100Button.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            zoom100ButtonActionPerformed(evt);
        }
    });
    jPanel1.add(zoom100Button);
    zoomScrollbar.setMaximum(1000);
    zoomScrollbar.setMinimum(10);
    zoomScrollbar.setOrientation(javax.swing.JScrollBar.HORIZONTAL);
    zoomScrollbar.setUnitIncrement(10);
    zoomScrollbar.setValue(100);
    zoomScrollbar.setVisibleAmount(1);
    zoomScrollbar.setPreferredSize(new java.awt.Dimension(100, 20));
    zoomScrollbar.addAdjustmentListener(new java.awt.event.AdjustmentListener() {

        public void adjustmentValueChanged(java.awt.event.AdjustmentEvent evt) {
            zoomScrollbarAdjustmentValueChanged(evt);
        }
    });
    jPanel1.add(zoomScrollbar);
    zoomValueBox.setEditable(true);
    zoomValueBox.setFont(new java.awt.Font("Arial", 0, 10));
    zoomValueBox.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
    zoomValueBox.setMaximumSize(new java.awt.Dimension(75, 19));
    zoomValueBox.setMinimumSize(new java.awt.Dimension(75, 19));
    zoomValueBox.setPreferredSize(new java.awt.Dimension(75, 20));
    zoomValueBox.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            zoomValueBoxActionPerformed(evt);
        }
    });
    jPanel1.add(zoomValueBox);
    bottomPanel.add(jPanel1);
    getContentPane().add(bottomPanel, java.awt.BorderLayout.SOUTH);
    pack();
}
Example 27
Project: cs320tests-master  File: SmartRobot.java View source code
public void scrollDown(JScrollBar scrollPane) {
    int x = scrollPane.getX() + scrollPane.getWidth() / 2;
    int y = scrollPane.getY() + scrollPane.getHeight() - 4;
    Container container = scrollPane;
    while (container.getParent() != DisplayController.GetInstance() && container.getParent() != null) {
        container = container.getParent();
        x += container.getX();
        y += container.getY();
    }
    this.mouseTripleClick(x, y);
}
Example 28
Project: GitDirStat-master  File: RemovePathsActionInput.java View source code
private Dimension calculatePreferredSize(JList list, SelectionModel<TreeObject> selectionModel, JScrollPane selectedPathScrollPane) {
    ListCellRenderer cellRenderer = list.getCellRenderer();
    JScrollBar horizontalScrollBar = selectedPathScrollPane.getHorizontalScrollBar();
    Dimension hScrollBarPreferredSize = horizontalScrollBar.getPreferredSize();
    int maxWidth = 480;
    int maxHeight = 160;
    int preferredWidth = 0;
    int preferredHeight = hScrollBarPreferredSize.height;
    List<TreeObject> selection = selectionModel.getSelection();
    for (int i = 0; i < selection.size(); i++) {
        TreeObject treeObject = selection.get(i);
        Component rendererComponent = cellRenderer.getListCellRendererComponent(list, treeObject, i, false, false);
        Dimension preferredSize = rendererComponent.getPreferredSize();
        preferredWidth = Math.max(preferredWidth, (int) preferredSize.getWidth());
        preferredWidth = Math.min(preferredWidth, maxWidth);
        preferredHeight = Math.max(preferredHeight, preferredHeight + (int) preferredSize.getHeight());
        preferredHeight = Math.min(preferredHeight, maxHeight);
    }
    return new Dimension(preferredWidth, preferredHeight);
}
Example 29
Project: goos-master  File: JScrollbarDriver.java View source code
public void manipulate(JScrollBar component) {
    //don't think this is right
    Dimension minimumSize = component.getUI().getMinimumSize(component);
    BoundedRangeModel model = component.getModel();
    double min = model.getMinimum();
    double val = model.getValue();
    double extent = model.getExtent();
    double ratio = extent / (model.getMaximum() - min);
    orientation = component.getOrientation();
    if (JScrollBar.HORIZONTAL == orientation) {
        double width = component.getBounds().getWidth();
        double gripperSize = Math.max(ratio * width, minimumSize.width);
        final double midPoint = (gripperSize / 2) + (val * ratio);
        y = component.getHeight() / 2;
        x = (int) midPoint;
    } else {
        double height = component.getBounds().getHeight();
        double gripperSize = Math.max(ratio * height, minimumSize.height);
        double midPoint = (gripperSize / 2) + (val * ratio);
        x = component.getWidth() / 2;
        y = (int) midPoint;
    }
}
Example 30
Project: jdk7u-jdk-master  File: LWTextAreaPeer.java View source code
@Override
public Dimension getPreferredSize(final int rows, final int columns) {
    final Dimension size = super.getPreferredSize(rows, columns);
    synchronized (getDelegateLock()) {
        final JScrollBar vbar = getDelegate().getVerticalScrollBar();
        final JScrollBar hbar = getDelegate().getHorizontalScrollBar();
        final int scrollbarW = vbar != null ? vbar.getWidth() : 0;
        final int scrollbarH = hbar != null ? hbar.getHeight() : 0;
        return new Dimension(size.width + scrollbarW, size.height + scrollbarH);
    }
}
Example 31
Project: mct-master  File: FlatScrollBarUI.java View source code
@Override
protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) {
    Graphics2D g2 = (Graphics2D) g;
    g2.setColor(foreground);
    g2.fill(thumbBounds);
    if (c instanceof JScrollBar) {
        int orientation = ((JScrollBar) c).getOrientation();
        g2.setColor(background);
        // Center position
        int x = (thumbBounds.x) + thumbBounds.width / 2;
        int y = (thumbBounds.y) + thumbBounds.height / 2;
        int w = thumbBounds.width / 4;
        int h = thumbBounds.height / 4;
        for (int i = -2; i <= 2; i += 2) {
            switch(orientation) {
                case JScrollBar.VERTICAL:
                    g2.drawLine(x - w, y + i, x + w, y + i);
                    break;
                case JScrollBar.HORIZONTAL:
                    g2.drawLine(x + i, y - h, x + i, y + h);
                    break;
            }
        }
    }
}
Example 32
Project: openflexo-master  File: FlexoAutoScroll.java View source code
/**
	 * 
	 * @param scrollable
	 *            - a component contained in a JScrollPane
	 * @param p
	 * @param margin
	 *            - the width of your insets where to scroll (imagine a border of that width all around your component. Whenever the mouse
	 *            enters that border, it will start scrolling
	 */
public static void autoscroll(JComponent scrollable, Point p, int margin) {
    JScrollPane scroll = (JScrollPane) SwingUtilities.getAncestorOfClass(JScrollPane.class, scrollable);
    if (scroll == null) {
        if (logger.isLoggable(Level.WARNING)) {
            logger.warning("Not inside a scroll pane, cannot scroll!");
        }
        return;
    }
    Rectangle visible = scrollable.getVisibleRect();
    p.x -= visible.x;
    p.y -= visible.y;
    Rectangle inner = scrollable.getParent().getBounds();
    inner.x += margin;
    inner.y += margin;
    inner.height -= 2 * margin;
    inner.width -= 2 * margin;
    if (// Move Left
    p.x < inner.x) {
        JScrollBar bar = scroll.getHorizontalScrollBar();
        if (bar != null) {
            if (bar.getValue() > bar.getMinimum()) {
                bar.setValue(bar.getValue() - bar.getUnitIncrement(-1));
            }
        }
    } else if (// Move right
    p.x > inner.x + inner.width) {
        JScrollBar bar = scroll.getHorizontalScrollBar();
        if (bar != null) {
            if (bar.getValue() < bar.getMaximum()) {
                bar.setValue(bar.getValue() + bar.getUnitIncrement(1));
            }
        }
    }
    if (// Move up
    p.y < inner.y) {
        JScrollBar bar = scroll.getVerticalScrollBar();
        if (bar != null) {
            if (bar.getValue() > bar.getMinimum()) {
                bar.setValue(bar.getValue() - bar.getUnitIncrement(-1));
            }
        }
    } else if (// Move down
    p.y > inner.y + inner.height) {
        JScrollBar bar = scroll.getVerticalScrollBar();
        if (bar != null) {
            if (bar.getValue() < bar.getMaximum()) {
                bar.setValue(bar.getValue() + bar.getUnitIncrement(1));
            }
        }
    }
}
Example 33
Project: openjdk8-jdk-master  File: LWTextAreaPeer.java View source code
@Override
public Dimension getMinimumSize(final int rows, final int columns) {
    final Dimension size = super.getMinimumSize(rows, columns);
    synchronized (getDelegateLock()) {
        // JScrollPane insets
        final Insets pi = getDelegate().getInsets();
        size.width += pi.left + pi.right;
        size.height += pi.top + pi.bottom;
        // Take scrollbars into account.
        final int vsbPolicy = getDelegate().getVerticalScrollBarPolicy();
        if (vsbPolicy == ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS) {
            final JScrollBar vbar = getDelegate().getVerticalScrollBar();
            size.width += vbar != null ? vbar.getMinimumSize().width : 0;
        }
        final int hsbPolicy = getDelegate().getHorizontalScrollBarPolicy();
        if (hsbPolicy == ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS) {
            final JScrollBar hbar = getDelegate().getHorizontalScrollBar();
            size.height += hbar != null ? hbar.getMinimumSize().height : 0;
        }
    }
    return size;
}
Example 34
Project: smtp-sender-master  File: LogPanel.java View source code
private AdjustmentListener createAutoScrollEvent() {
    return new AdjustmentListener() {

        @Override
        public void adjustmentValueChanged(AdjustmentEvent e) {
            if (!LogPanel.this.isAutoScroll) {
                return;
            }
            JScrollBar src = (JScrollBar) e.getSource();
            src.setValue(src.getMaximum());
        }
    };
}
Example 35
Project: Thaw-master  File: LiquidScrollPaneUI.java View source code
/**
         * Called when the mouse wheel is rotated while over a
         * JScrollPane.
         *
         * @param e     MouseWheelEvent to be handled
         * @since 1.4
         */
public void mouseWheelMoved(java.awt.event.MouseWheelEvent e) {
    if (scrollpane.isWheelScrollingEnabled() && (e.getScrollAmount() != 0)) {
        JScrollBar toScroll = scrollpane.getVerticalScrollBar();
        int length = toScroll.getHeight();
        // find which scrollbar to scroll, or return if none
        if ((toScroll == null) || !toScroll.isVisible() || (e.getModifiers() == InputEvent.ALT_MASK)) {
            toScroll = scrollpane.getHorizontalScrollBar();
            if ((toScroll == null) || !toScroll.isVisible()) {
                return;
            }
            length = toScroll.getWidth();
        }
        if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) {
            int newValue = toScroll.getValue() + ((e.getWheelRotation() * length) / (toScroll.getUnitIncrement() * 2));
            toScroll.setValue(newValue);
        } else if (e.getScrollType() == MouseWheelEvent.WHEEL_BLOCK_SCROLL) {
            int newValue = toScroll.getValue() + ((e.getWheelRotation() * length) / (toScroll.getBlockIncrement() * 2));
            toScroll.setValue(newValue);
        }
    }
}
Example 36
Project: javaforce-master  File: ProjectPanel.java View source code
/**
   * This method is called from within the constructor to initialize the form.
   * WARNING: Do NOT modify this code. The content of this method is always
   * regenerated by the Form Editor.
   */
@SuppressWarnings("unchecked")
private // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
void initComponents() {
    timeScroll = new javax.swing.JScrollBar();
    tracks = new javax.swing.JPanel();
    timeLine = new javax.swing.JPanel();
    tracksScroll = new javax.swing.JScrollBar();
    addComponentListener(new java.awt.event.ComponentAdapter() {

        public void componentResized(java.awt.event.ComponentEvent evt) {
            formComponentResized(evt);
        }
    });
    timeScroll.setOrientation(javax.swing.JScrollBar.HORIZONTAL);
    timeScroll.addAdjustmentListener(new java.awt.event.AdjustmentListener() {

        public void adjustmentValueChanged(java.awt.event.AdjustmentEvent evt) {
            timeScrollAdjustmentValueChanged(evt);
        }
    });
    javax.swing.GroupLayout tracksLayout = new javax.swing.GroupLayout(tracks);
    tracks.setLayout(tracksLayout);
    tracksLayout.setHorizontalGroup(tracksLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 0, Short.MAX_VALUE));
    tracksLayout.setVerticalGroup(tracksLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 675, Short.MAX_VALUE));
    timeLine.setLayout(new java.awt.GridLayout(1, 1));
    tracksScroll.addAdjustmentListener(new java.awt.event.AdjustmentListener() {

        public void adjustmentValueChanged(java.awt.event.AdjustmentEvent evt) {
            tracksScrollAdjustmentValueChanged(evt);
        }
    });
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(timeLine, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(timeScroll, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 594, Short.MAX_VALUE).addGroup(layout.createSequentialGroup().addComponent(tracks, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(tracksScroll, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addComponent(timeLine, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(tracks, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(tracksScroll, javax.swing.GroupLayout.DEFAULT_SIZE, 675, Short.MAX_VALUE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(timeScroll, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)));
}
Example 37
Project: aetheria-master  File: SmoothScrollTimer.java View source code
public int calculateSpeed(ActionEvent evt, ColoredSwingClient cl) {
    JScrollPane elScrolling = cl.getScrollPane();
    JScrollBar vbar = (JScrollBar) elScrolling.getVerticalScrollBar();
    int distance = vbar.getMaximum() - (vbar.getValue() + vbar.getVisibleAmount());
    double speedFactor = ((double) distance) / 40;
    int theSpeed = (int) Math.round(pixelsPerFrame * speedFactor);
    if (theSpeed < 1)
        return 1;
    else
        return theSpeed;
}
Example 38
Project: ATLauncher-NextGen-master  File: LightBarScrollPane.java View source code
@Override
protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) {
    int alpha = isThumbRollover() ? SCROLL_BAR_ALPHA_ROLLOVER : SCROLL_BAR_ALPHA;
    int orientation = scrollbar.getOrientation();
    int arc = THUMB_SIZE;
    int x = thumbBounds.x + THUMB_BORDER_SIZE;
    int y = thumbBounds.y + THUMB_BORDER_SIZE;
    int width = orientation == JScrollBar.VERTICAL ? THUMB_SIZE : thumbBounds.width - (THUMB_BORDER_SIZE * 2);
    width = Math.max(width, THUMB_SIZE);
    int height = orientation == JScrollBar.VERTICAL ? thumbBounds.height - (THUMB_BORDER_SIZE * 2) : THUMB_SIZE;
    height = Math.max(height, THUMB_SIZE);
    Graphics2D graphics2D = (Graphics2D) g.create();
    graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    graphics2D.setColor(new Color(THUMB_COLOR.getRed(), THUMB_COLOR.getGreen(), THUMB_COLOR.getBlue(), alpha));
    graphics2D.fillRoundRect(x, y, width, height, arc, arc);
    graphics2D.dispose();
}
Example 39
Project: BAI-master  File: PConsole.java View source code
public void run() {
    try {
        int scrollBarPos = scrollPane.getVerticalScrollBar().getValue();
        switch(format) {
            default:
                textPane.setText(output);
                break;
            case HTML:
                textPane.setText("<html>" + output + "</html>");
                break;
        }
        if (cbAutoScroll.isSelected()) {
            JScrollBar scrollBar = scrollPane.getVerticalScrollBar();
            scrollBar.setValue(scrollBar.getMaximum());
        } else {
            JScrollBar scrollBar = scrollPane.getVerticalScrollBar();
            scrollBar.setValue(scrollBarPos);
        }
    } catch (Exception e) {
    }
    outputUpdateWaiting = false;
}
Example 40
Project: chatty-master  File: ModerationLog.java View source code
private void printLine(JTextArea text, String line) {
    try {
        Document doc = text.getDocument();
        String linebreak = doc.getLength() > 0 ? "\n" : "";
        doc.insertString(doc.getLength(), linebreak + line, null);
        JScrollBar bar = scroll.getVerticalScrollBar();
        boolean scrollDown = bar.getValue() > bar.getMaximum() - bar.getVisibleAmount() - 4;
        if (scrollDown) {
            scrollDown();
        }
        clearSomeChat(doc);
    } catch (BadLocationException e) {
        e.printStackTrace();
    }
}
Example 41
Project: com.opendoorlogistics-master  File: JScrollPopupMenu.java View source code
@Override
public void mouseWheelMoved(MouseWheelEvent event) {
    JScrollBar scrollBar = getScrollBar();
    int amount = (event.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) ? event.getUnitsToScroll() * scrollBar.getUnitIncrement() : (event.getWheelRotation() < 0 ? -1 : 1) * scrollBar.getBlockIncrement();
    scrollBar.setValue(scrollBar.getValue() + amount);
    event.consume();
}
Example 42
Project: Desktop-master  File: GlassPaneNodeSelector.java View source code
//A basic implementation of redispatching events.
private Component findMapComponent(MouseEvent e) {
    final Component glassPane = e.getComponent();
    final Point glassPanePoint = e.getPoint();
    final Container container = SwingUtilities.getRootPane(glassPane).getContentPane();
    Point containerPoint = SwingUtilities.convertPoint(glassPane, glassPanePoint, container);
    Component component = SwingUtilities.getDeepestComponentAt(container, containerPoint.x, containerPoint.y);
    if (component instanceof MainView || component instanceof MapView || component instanceof JScrollBar) {
        return component;
    }
    return SwingUtilities.getAncestorOfClass(MapView.class, component);
}
Example 43
Project: Docear-master  File: GlassPaneNodeSelector.java View source code
//A basic implementation of redispatching events.
private Component findMapComponent(MouseEvent e) {
    final Component glassPane = e.getComponent();
    final Point glassPanePoint = e.getPoint();
    final Container container = SwingUtilities.getRootPane(glassPane).getContentPane();
    Point containerPoint = SwingUtilities.convertPoint(glassPane, glassPanePoint, container);
    Component component = SwingUtilities.getDeepestComponentAt(container, containerPoint.x, containerPoint.y);
    if (component instanceof MainView || component instanceof MapView || component instanceof JScrollBar) {
        return component;
    }
    return SwingUtilities.getAncestorOfClass(MapView.class, component);
}
Example 44
Project: FTNTLaunch-master  File: SmartScroller.java View source code
/*
	 * Analyze every adjustment event to determine when the viewport
	 * needs to be repositioned.
	 */
private void checkScrollBar(AdjustmentEvent e) {
    // The scroll bar listModel contains information needed to determine
    // whether the viewport should be repositioned or not.
    JScrollBar scrollBar = (JScrollBar) e.getSource();
    BoundedRangeModel listModel = scrollBar.getModel();
    int value = listModel.getValue();
    int extent = listModel.getExtent();
    int maximum = listModel.getMaximum();
    boolean valueChanged = previousValue != value;
    boolean maximumChanged = previousMaximum != maximum;
    if (valueChanged && !maximumChanged) {
        if (viewportPosition == START) {
            adjustScrollBar = value != 0;
        } else {
            adjustScrollBar = value + extent >= maximum;
        }
    }
    if (adjustScrollBar && viewportPosition == END) {
        // Scroll the viewport to the end.
        scrollBar.removeAdjustmentListener(this);
        value = maximum - extent;
        scrollBar.setValue(value);
        scrollBar.addAdjustmentListener(this);
    }
    if (adjustScrollBar && viewportPosition == START) {
        // Keep the viewport at the same relative viewportPosition
        scrollBar.removeAdjustmentListener(this);
        value = value + maximum - previousMaximum;
        scrollBar.setValue(value);
        scrollBar.addAdjustmentListener(this);
    }
    previousValue = value;
    previousMaximum = maximum;
}
Example 45
Project: Ganymede-master  File: serverTab.java View source code
/**
   * This method does whatever work is required to get the tab ready
   * for display.
   */
public void initialize() {
    JScrollBar vertical = contentPane.getVerticalScrollBar();
    vertical.setUnitIncrement(15);
    InputMap im = vertical.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    im.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), "negativeUnitIncrement");
    im.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), "positiveUnitIncrement");
    im.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0), "negativeBlockIncrement");
    im.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0), "positiveBlockIncrement");
    im.put(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 0), "minScroll");
    im.put(KeyStroke.getKeyStroke(KeyEvent.VK_END, 0), "maxScroll");
    cp = new containerPanel(parent.getObject(), parent.getObjectInvid(), parent.isEditable(), parent.getgclient(), parent.getWindowPanel(), parent, parent.progressBar, false, parent.isCreating, null);
    cp.setTabName(tabName);
    cp.setInfoVector(infoVector);
    cp.load();
    cp.setBorder(parent.getWindowPanel().emptyBorder10Right);
    this.infoVector = null;
    contentPane.setViewportView(cp);
}
Example 46
Project: glimpse-master  File: GlimpseVerticallyScrollableLayout.java View source code
/**
     * Returns a Runnable that, if called, will detach the layout from the scrollbar,
     * removing all of the listeners put in place by the attach call.
     *
     * If you are doing all Glimpse stuff on the Swing thread, then this function causes
     * no threading concerns.
     *
     * If you have multiple UI threads, you can generally rule out either deadlock or race
     * conditions, but not both. This function rules out deadlock, so it must leave the door
     * open to race conditions -- use at your own risk.
     *
     */
public static Runnable attachScrollableToScrollbar(final GlimpseVerticallyScrollableLayout layout, final GlimpseTargetStack stack, final JScrollBar scrollbar) {
    final Runnable layoutListener = new Runnable() {

        public void run() {
            int layoutHeight;
            int minContentHeight;
            int verticalOffset;
            layout.getLock().lock();
            try {
                layoutHeight = layout.getCurrentBounds(stack).getHeight();
                minContentHeight = layout.getMinContentHeight();
                verticalOffset = layout.getVerticalOffset();
            } finally {
                layout.getLock().unlock();
            }
            int extent = layoutHeight;
            int min = 0;
            int max = max(minContentHeight, extent);
            int value = min(verticalOffset, max - extent);
            scrollbar.setValues(value, extent, min, max);
            scrollbar.repaint();
        }
    };
    final AdjustmentListener scrollbarListener = new AdjustmentListener() {

        public void adjustmentValueChanged(AdjustmentEvent ev) {
            layout.setVerticalOffset(scrollbar.getValue());
        }
    };
    // Attach listeners
    layout.addListener(true, layoutListener);
    scrollbar.addAdjustmentListener(scrollbarListener);
    // Return a way to detach listeners later
    return new Runnable() {

        public void run() {
            layout.removeListener(layoutListener);
            scrollbar.removeAdjustmentListener(scrollbarListener);
        }
    };
}
Example 47
Project: intellij-community-master  File: ScrollSettings.java View source code
/* A heuristics that disables scrolling interpolation in diff / merge windows.
     We need to to make scrolling synchronization compatible with the interpolation first.

     NOTE: The implementation is a temporary, ad-hoc heuristics that is needed solely to
           facilitate testing of the experimental "true smooth scrolling" feature. */
static boolean isInterpolationEligibleFor(JScrollBar scrollbar) {
    Window window = (Window) scrollbar.getTopLevelAncestor();
    if (window instanceof JDialog && "Commit Changes".equals(((JDialog) window).getTitle())) {
        return false;
    }
    if (!(window instanceof RootPaneContainer)) {
        return true;
    }
    Component[] components = ((RootPaneContainer) window).getContentPane().getComponents();
    if (components.length == 1 && components[0].getClass().getName().contains("DiffWindow")) {
        return false;
    }
    if (components.length == 2 && components[0] instanceof Container) {
        Component[] subComponents = ((Container) components[0]).getComponents();
        if (subComponents.length == 1) {
            String name = subComponents[0].getClass().getName();
            if (name.contains("DiffWindow") || name.contains("MergeWindow")) {
                return false;
            }
        }
    }
    return true;
}
Example 48
Project: Jailer-master  File: JScrollC2PopupMenu.java View source code
@Override
public void mouseWheelMoved(MouseWheelEvent event) {
    JScrollBar scrollBar = getScrollBar();
    int amount = (event.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) ? event.getUnitsToScroll() * scrollBar.getUnitIncrement() : (event.getWheelRotation() < 0 ? -1 : 1) * scrollBar.getBlockIncrement();
    scrollBar.setValue(scrollBar.getValue() + amount);
    event.consume();
}
Example 49
Project: jajuk-master  File: FlowScrollPanel.java View source code
/* (non-Javadoc)
   * @see javax.swing.JComponent#getPreferredSize()
   */
@Override
public Dimension getPreferredSize() {
    if (scroller == null) {
        return super.getPreferredSize();
    }
    Insets insets = getInsets();
    int hgap = layout.getHgap();
    int vgap = layout.getVgap();
    JScrollBar vsb = scroller.getVerticalScrollBar();
    if (vsb == null) {
        vsb = scroller.createVerticalScrollBar();
    }
    int scrollerWidth = scroller.getSize().width - (insets.left + insets.right + hgap * 2) - vsb.getSize().width;
    // the -2 is a voodoo constant. I don't know why it's needed, but
    // it is. (I suspect that this routine and FlowLayout compute
    // required sizes in a subtly different way.)
    // No longer needed with Swing 1.1 (I think).
    int nmembers = getComponentCount();
    int x = 0, y = insets.top + vgap;
    int rowh = 0;
    int maxRowWidth = scrollerWidth;
    for (int i = 0; i < nmembers; i++) {
        Component m = getComponent(i);
        if (m.isVisible()) {
            Dimension d = m.getPreferredSize();
            if ((x == 0) || ((x + d.width) <= scrollerWidth)) {
                if (x > 0) {
                    x += hgap;
                }
                x += d.width;
                rowh = Math.max(rowh, d.height);
            } else {
                if (x > maxRowWidth) {
                    maxRowWidth = x + hgap;
                }
                x = d.width;
                y += vgap + rowh;
                rowh = d.height;
            }
        }
    }
    if (x > maxRowWidth) {
        maxRowWidth = x + 2 * hgap + insets.left + insets.right;
    }
    y += vgap + rowh + insets.bottom;
    return new Dimension(maxRowWidth, y);
}
Example 50
Project: JamVM-PH-master  File: MetalScrollPaneUI.java View source code
/**
   * Configures the specified component appropriate for the look and feel. 
   * This method is invoked when the ComponentUI instance is being installed 
   * as the UI delegate on the specified component. This method should 
   * completely configure the component for the look and feel, 
   * including the following:
   * 1. Install any default property values for color, fonts, borders,
   * icons, opacity, etc. on the component. Whenever possible, property
   * values initialized by the client program should not be overridden.
   * 2. Install a LayoutManager on the component if necessary.
   * 3. Create/add any required sub-components to the component.
   * 4. Create/install event listeners on the component.
   * 5. Create/install a PropertyChangeListener on the component in order
   * to detect and respond to component property changes appropriately.
   * 6. Install keyboard UI (mnemonics, traversal, etc.) on the component.
   * 7. Initialize any appropriate instance data. 
   * 
   * @param c - the component to install the ui on
   */
public void installUI(JComponent c) {
    super.installUI(c);
    JScrollBar hsb = scrollpane.getHorizontalScrollBar();
    hsb.putClientProperty(MetalScrollBarUI.FREE_STANDING_PROP, Boolean.FALSE);
    JScrollBar vsb = scrollpane.getVerticalScrollBar();
    vsb.putClientProperty(MetalScrollBarUI.FREE_STANDING_PROP, Boolean.FALSE);
}
Example 51
Project: kevoree-master  File: ButtonsTogetherScrollBarSkin.java View source code
public void installComponents(JScrollBar scrollBar) {
    // add the components to the scrollbar. order matters here - components added first, are
    // drawn last (on top).
    scrollBar.add(fThumbContainer);
    scrollBar.add(fCap);
    scrollBar.add(fIncrementButton);
    scrollBar.add(fDecrementButton);
    scrollBar.add(fTrack);
    // add the actual scroller thumb (the component that will be painted) to the scroller thumb
    // container.
    fThumbContainer.add(fThumb);
}
Example 52
Project: larkc-platform-2.5-rev1797-with-sim-master  File: TextAreaOutputStream.java View source code
//// Protected Area
//// Private Area
private boolean isScolledToBottom() {
    JScrollBar sb = scrollPane.getVerticalScrollBar();
    int currentValue = sb.getValue();
    int maxValue = sb.getMaximum();
    int extent = sb.getVisibleAmount();
    boolean isAtBottom = (currentValue >= (maxValue - extent));
    if (!isAtBottom) {
        /*System.out.println("current value: " + currentValue);
      System.out.println("max value: " + maxValue);
      System.out.println("extent: " + extent);*/
        int i = 0;
    }
    return isAtBottom;
}
Example 53
Project: magarena-master  File: MScrollBarUI.java View source code
private void doPaintCustomThumb(Graphics2D g2d, JComponent c, Rectangle r) {
    JScrollBar sb = (JScrollBar) c;
    if (!sb.isEnabled()) {
        return;
    }
    final boolean isVertical = sb.getOrientation() == JScrollBar.VERTICAL;
    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    final Color[] colors = isThumbRollover() ? ROLLOVER_COLORS : DEFAULT_COLORS;
    //
    // fill paint gradient
    //
    final Point endPoint = isVertical ? new Point(r.width + r.width / 4, 0) : new Point(0, r.height);
    final GradientPaint fillPaint = new GradientPaint(0, 0, colors[0], endPoint.x, endPoint.y, colors[1]);
    //
    // shape
    //
    final int offset1 = 3;
    final int offset2 = 9;
    final Dimension offset = isVertical ? new Dimension(offset1, offset2) : new Dimension(offset2, offset1);
    final Rectangle rect = new Rectangle(r.x + offset.width, r.y + offset.height, r.width - (offset.width * 2), r.height - (offset.height * 2));
    g2d.setPaint(fillPaint);
    g2d.fillRoundRect(rect.x, rect.y, rect.width, rect.height, 10, 10);
    g2d.setColor(colors[2]);
    g2d.drawRoundRect(rect.x, rect.y, rect.width, rect.height, 10, 10);
}
Example 54
Project: mage-master  File: MageScrollbarUI.java View source code
@Override
protected void paintTrack(Graphics g, JComponent c, Rectangle trackBounds) {
    Graphics2D g2 = (Graphics2D) g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    if (scrollbar.getOrientation() == JScrollBar.VERTICAL) {
        int width = trackBounds.width - 4 + ANTI_WIDTH;
        int height = trackBounds.height;
        g2.translate(trackBounds.x + 2, trackBounds.y);
        Rectangle2D casing = new Rectangle2D.Double(0, 0, width, height);
        g2.setColor(Color.BLACK);
        float alpha = 0.5f;
        Composite composite = g2.getComposite();
        if (composite instanceof AlphaComposite) {
            alpha *= ((AlphaComposite) composite).getAlpha();
        }
        g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
        g2.fill(casing);
        g2.setComposite(composite);
        g2.drawLine(-1, 0, -1, height);
        g2.drawLine(-2, 0, -2, height);
        g2.drawLine(width, 0, width, height);
        g2.drawLine(width + 1, 0, width + 1, height);
        RoundRectangle2D roundCasing = new RoundRectangle2D.Double(0, 2, width, height - 4, width, width);
        Area area = new Area(casing);
        area.subtract(new Area(roundCasing));
        g2.fill(area);
        g2.translate(-trackBounds.x - 2, -trackBounds.y);
    } else {
        int width = trackBounds.width;
        int height = trackBounds.height - 4 + ANTI_WIDTH;
        g2.translate(trackBounds.x, trackBounds.y + 2);
        Rectangle2D casing = new Rectangle2D.Double(0, 0, width, height);
        g2.setColor(Color.BLACK);
        float alpha = 0.5f;
        Composite composite = g2.getComposite();
        if (composite instanceof AlphaComposite) {
            alpha *= ((AlphaComposite) composite).getAlpha();
        }
        g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
        g2.fill(casing);
        g2.setComposite(composite);
        g2.drawLine(0, -1, width, -1);
        g2.drawLine(0, -2, width, -2);
        g2.drawLine(0, height, width, height);
        g2.drawLine(0, height + 1, width, height + 1);
        RoundRectangle2D roundCasing = new RoundRectangle2D.Double(2, 0, width - 4, height, height, height);
        Area area = new Area(casing);
        area.subtract(new Area(roundCasing));
        g2.fill(area);
        g2.translate(-trackBounds.x, -trackBounds.y - 2);
    }
}
Example 55
Project: MartScript-master  File: DatasetConfigAttributesTable.java View source code
public void autoscroll(Point location) {
    JScrollPane scroller = (JScrollPane) SwingUtilities.getAncestorOfClass(JScrollPane.class, this);
    if (scroller != null) {
        JScrollBar hBar = scroller.getHorizontalScrollBar();
        JScrollBar vBar = scroller.getVerticalScrollBar();
        Rectangle r = getVisibleRect();
        if (location.x <= r.x + scrollInsets.left) {
            // Need to scroll left
            hBar.setValue(hBar.getValue() - hBar.getUnitIncrement(-1));
        }
        if (location.y <= r.y + scrollInsets.top) {
            // Need to scroll up
            vBar.setValue(vBar.getValue() - vBar.getUnitIncrement(-1));
        }
        if (location.x >= r.x + r.width - scrollInsets.right) {
            // Need to scroll right
            hBar.setValue(hBar.getValue() + hBar.getUnitIncrement(1));
        }
        if (location.y >= r.y + r.height - scrollInsets.bottom) {
            // Need to scroll down
            vBar.setValue(vBar.getValue() + vBar.getUnitIncrement(1));
        }
    }
}
Example 56
Project: MediathekView-master  File: ButtonsTogetherScrollBarSkin.java View source code
public void installComponents(JScrollBar scrollBar) {
    // add the components to the scrollbar. order matters here - components added first, are
    // drawn last (on top).
    scrollBar.add(fThumbContainer);
    scrollBar.add(fCap);
    scrollBar.add(fIncrementButton);
    scrollBar.add(fDecrementButton);
    scrollBar.add(fTrack);
    // add the actual scroller thumb (the component that will be painted) to the scroller thumb
    // container.
    fThumbContainer.add(fThumb);
}
Example 57
Project: medsavant-master  File: JScrollPopupMenu.java View source code
@Override
public void mouseWheelMoved(MouseWheelEvent event) {
    JScrollBar scrollBar = getScrollBar();
    int amount = (event.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) ? event.getUnitsToScroll() * scrollBar.getUnitIncrement() : (event.getWheelRotation() < 0 ? -1 : 1) * scrollBar.getBlockIncrement();
    scrollBar.setValue(scrollBar.getValue() + amount);
    event.consume();
}
Example 58
Project: openmicroscopy-master  File: ScrollablePopupMenu.java View source code
public void mouseWheelMoved(MouseWheelEvent event) {
    JScrollBar bar = getVerticalScrollBar();
    int amount;
    if (event.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) {
        amount = event.getUnitsToScroll() * bar.getUnitIncrement();
    } else {
        if (event.getWheelRotation() < 0) {
            amount = -bar.getBlockIncrement();
        } else {
            amount = bar.getBlockIncrement();
        }
    }
    bar.setValue(bar.getValue() + amount);
    event.consume();
}
Example 59
Project: Pail-master  File: ScrollableTextArea.java View source code
private void maybeScrollToBottom() {
    JScrollBar scrollBar = scroller.getVerticalScrollBar();
    boolean scrollBarAtBottom = isScrollBarFullyExtended(scrollBar);
    if (scrollBarAtBottom) {
        EventQueue.invokeLater(new Runnable() {

            public void run() {
                EventQueue.invokeLater(new Runnable() {

                    public void run() {
                        scrollToBottom(textArea);
                    }
                });
            }
        });
    }
}
Example 60
Project: PokemonWalking-master  File: ScriptViewer.java View source code
@Override
public void actionPerformed(ActionEvent event) {
    switch(Integer.valueOf(event.getActionCommand())) {
        default:
            break;
        // Create Button
        case 0:
            {
                Trigger t = new Trigger();
                t.setTriggerID((short) 0);
                t.setName("<Untitled>");
                this.model.addElement(t);
                this.validate();
                JScrollBar vertical = scrollPane.getVerticalScrollBar();
                vertical.setValue(vertical.getMaximum() + 1);
                this.triggerList.setSelectedIndex(this.model.getSize() - 1);
                this.editor.scriptChanger.enable();
                break;
            }
        // Remove button
        case 1:
            {
                int index = this.triggerList.getSelectedIndex();
                if (index != -1 && !this.model.isEmpty())
                    this.model.remove(index);
                else if (!this.model.isEmpty()) {
                    this.model.remove(this.model.getSize() - 1);
                }
                if (this.model.isEmpty()) {
                    ScriptViewer.this.editor.scriptChanger.clear();
                    ScriptViewer.this.editor.scriptChanger.disable();
                }
                break;
            }
        case 2:
            {
                while (!this.model.isEmpty()) {
                    this.model.remove(0);
                }
                ScriptViewer.this.editor.scriptChanger.clear();
                ScriptViewer.this.editor.scriptChanger.disable();
                break;
            }
    }
    this.editor.getLevelEditorParent().properties.reloadTriggers();
    this.triggerList.validate();
}
Example 61
Project: powerpaint-master  File: SwingUtils.java View source code
public static <C extends JComponent> C shrink(C c) {
    c.putClientProperty("JComponent.sizeVariant", "mini");
    if (!(c instanceof JSlider)) {
        c.setFont(c.getFont().deriveFont(9.0f));
    }
    if (c instanceof JSpinner) {
        JComponent e = ((JSpinner) c).getEditor();
        if (e != null)
            shrink(e);
    }
    if (c instanceof JSpinner.DefaultEditor) {
        JFormattedTextField f = ((JSpinner.DefaultEditor) c).getTextField();
        if (f != null)
            shrink(f);
    }
    if (c instanceof JSpinner.DateEditor) {
        JFormattedTextField f = ((JSpinner.DateEditor) c).getTextField();
        if (f != null)
            shrink(f);
    }
    if (c instanceof JSpinner.NumberEditor) {
        JFormattedTextField f = ((JSpinner.NumberEditor) c).getTextField();
        if (f != null)
            shrink(f);
    }
    if (c instanceof JSpinner.ListEditor) {
        JFormattedTextField f = ((JSpinner.ListEditor) c).getTextField();
        if (f != null)
            shrink(f);
    }
    if (c instanceof JScrollPane) {
        JScrollBar v = ((JScrollPane) c).getVerticalScrollBar();
        if (v != null)
            shrink(v);
        JScrollBar h = ((JScrollPane) c).getHorizontalScrollBar();
        if (h != null)
            shrink(h);
    }
    for (Component c2 : c.getComponents()) {
        if (c2 instanceof JComponent)
            shrink((JComponent) c2);
    }
    return c;
}
Example 62
Project: substance-master  File: SubstanceComboPopup.java View source code
/*
	 * (non-Javadoc)
	 * 
	 * @see javax.swing.plaf.basic.BasicComboPopup#computePopupBounds(int, int,
	 * int, int)
	 */
@Override
protected Rectangle computePopupBounds(int px, int py, int pw, int ph) {
    int popupFlyoutOrientation = SubstanceCoreUtilities.getPopupFlyoutOrientation(this.comboBox);
    Insets insets = this.getInsets();
    int dx = 0;
    int dy = 0;
    switch(popupFlyoutOrientation) {
        case SwingConstants.NORTH:
            dy = -ph - (int) this.comboBox.getSize().getHeight() - insets.top - insets.bottom;
            break;
        case SwingConstants.CENTER:
            dy = -ph / 2 - (int) this.comboBox.getSize().getHeight() / 2 - insets.top / 2 - insets.bottom / 2;
            break;
        case SwingConstants.EAST:
            dx = pw + insets.left + insets.right;
            dy = -(int) this.comboBox.getSize().getHeight();
            break;
        case SwingConstants.WEST:
            dx = -pw - insets.left - insets.right;
            dy = -(int) this.comboBox.getSize().getHeight();
    }
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    Rectangle screenBounds;
    // Calculate the desktop dimensions relative to the combo box.
    GraphicsConfiguration gc = this.comboBox.getGraphicsConfiguration();
    Point p = new Point();
    SwingUtilities.convertPointFromScreen(p, this.comboBox);
    if (gc != null) {
        Insets screenInsets = toolkit.getScreenInsets(gc);
        screenBounds = gc.getBounds();
        screenBounds.width -= (screenInsets.left + screenInsets.right);
        screenBounds.height -= (screenInsets.top + screenInsets.bottom);
        screenBounds.x += (p.x + screenInsets.left);
        screenBounds.y += (p.y + screenInsets.top);
    } else {
        screenBounds = new Rectangle(p, toolkit.getScreenSize());
    }
    Rectangle rect = new Rectangle(px + dx, py + dy, pw, ph);
    if ((py + ph > screenBounds.y + screenBounds.height) && (ph < screenBounds.height)) {
        rect.y = -rect.height - insets.top - insets.bottom;
    }
    // The following has been taken from JGoodies' Looks implementation
    // for the popup prototype value
    Object popupPrototypeDisplayValue = SubstanceCoreUtilities.getComboPopupPrototypeDisplayValue(this.comboBox);
    if (popupPrototypeDisplayValue != null) {
        ListCellRenderer renderer = this.list.getCellRenderer();
        Component c = renderer.getListCellRendererComponent(this.list, popupPrototypeDisplayValue, -1, true, true);
        int npw = c.getPreferredSize().width;
        boolean hasVerticalScrollBar = this.comboBox.getItemCount() > this.comboBox.getMaximumRowCount();
        if (hasVerticalScrollBar) {
            // Add the scrollbar width.
            JScrollBar verticalBar = this.scroller.getVerticalScrollBar();
            npw += verticalBar.getPreferredSize().width;
        }
        pw = Math.max(pw, npw);
        rect.width = pw;
    }
    return rect;
}
Example 63
Project: TU-Server-master  File: MinecraftServerGui.java View source code
public void func_164247_a(final JTextArea p_164247_1_, final JScrollPane p_164247_2_, final String p_164247_3_) {
    if (!SwingUtilities.isEventDispatchThread()) {
        SwingUtilities.invokeLater(new Runnable() {

            private static final String __OBFID = "CL_00001792";

            public void run() {
                MinecraftServerGui.this.func_164247_a(p_164247_1_, p_164247_2_, p_164247_3_);
            }
        });
    } else {
        Document var4 = p_164247_1_.getDocument();
        JScrollBar var5 = p_164247_2_.getVerticalScrollBar();
        boolean var6 = false;
        if (p_164247_2_.getViewport().getView() == p_164247_1_) {
            var6 = (double) var5.getValue() + var5.getSize().getHeight() + (double) (serverGuiFont.getSize() * 4) > (double) var5.getMaximum();
        }
        try {
            var4.insertString(var4.getLength(), p_164247_3_, (AttributeSet) null);
        } catch (BadLocationException var8) {
            ;
        }
        if (var6) {
            var5.setValue(Integer.MAX_VALUE);
        }
    }
}
Example 64
Project: vassal-master  File: ScrollPane.java View source code
public void mouseWheelMoved(MouseWheelEvent e) {
    if (e.getScrollAmount() == 0)
        return;
    if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) {
        final JScrollBar bar = e.isShiftDown() ? horizontalScrollBar : verticalScrollBar;
        if (bar == null || !bar.isVisible())
            return;
        bar.setValue(bar.getValue() + e.getUnitsToScroll() * bar.getUnitIncrement());
    }
}
Example 65
Project: VirtualSlideViewer-master  File: ImageIndexControlPanel.java View source code
private JScrollBar createScrollBar(int row) {
    JScrollBar scrollBar = new JScrollBar();
    scrollBar.setMinimum(0);
    scrollBar.setVisibleAmount(1);
    scrollBar.setBlockIncrement(1);
    scrollBar.setOrientation(JScrollBar.HORIZONTAL);
    GridBagConstraints scrollBarContraints = new GridBagConstraints();
    scrollBarContraints.fill = GridBagConstraints.HORIZONTAL;
    scrollBarContraints.weightx = 1.0;
    scrollBarContraints.gridx = 1;
    scrollBarContraints.gridy = row;
    super.add(scrollBar, scrollBarContraints);
    return scrollBar;
}
Example 66
Project: Weasis-master  File: JScrollPopupMenu.java View source code
@Override
public void mouseWheelMoved(MouseWheelEvent event) {
    JScrollBar scrollBar = getScrollBar();
    int amount = (event.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) ? event.getUnitsToScroll() * scrollBar.getUnitIncrement() : (event.getWheelRotation() < 0 ? -1 : 1) * scrollBar.getBlockIncrement();
    scrollBar.setValue(scrollBar.getValue() + amount);
    event.consume();
}
Example 67
Project: WildAnimalsPlus-1.7.10-master  File: MinecraftServerGui.java View source code
public void func_164247_a(final JTextArea p_164247_1_, final JScrollPane p_164247_2_, final String p_164247_3_) {
    try {
        latch.await();
    } catch (InterruptedException e) {
    }
    if (!SwingUtilities.isEventDispatchThread()) {
        SwingUtilities.invokeLater(new Runnable() {

            private static final String __OBFID = "CL_00001792";

            public void run() {
                MinecraftServerGui.this.func_164247_a(p_164247_1_, p_164247_2_, p_164247_3_);
            }
        });
    } else {
        Document document = p_164247_1_.getDocument();
        JScrollBar jscrollbar = p_164247_2_.getVerticalScrollBar();
        boolean flag = false;
        if (p_164247_2_.getViewport().getView() == p_164247_1_) {
            flag = (double) jscrollbar.getValue() + jscrollbar.getSize().getHeight() + (double) (serverGuiFont.getSize() * 4) > (double) jscrollbar.getMaximum();
        }
        try {
            document.insertString(document.getLength(), p_164247_3_, (AttributeSet) null);
        } catch (BadLocationException badlocationexception) {
            ;
        }
        if (flag) {
            jscrollbar.setValue(Integer.MAX_VALUE);
        }
    }
}
Example 68
Project: QuantMiner-master  File: PanelResults.java View source code
/** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
private void initComponents() {
    //GEN-BEGIN:initComponents
    //rule scroll bar
    jScrollBarRegles = new javax.swing.JScrollBar();
    //save in a file
    jButtonSauver = new javax.swing.JButton();
    //rules
    jTextNumeroRegle = new javax.swing.JTextField();
    //rules
    jScrollRegles = new javax.swing.JScrollPane();
    //copy button
    jButtonCopy = new javax.swing.JButton();
    //visualize the extraction context
    jButtonVoirContexte = new javax.swing.JButton();
    //Extract the rows of a specific rule
    jButtonExtractRows = new javax.swing.JButton();
    setLayout(null);
    //text field --number of rules 
    jTextNumeroRegle.setEditable(false);
    jTextNumeroRegle.setFont(new java.awt.Font("Dialog", 1, 12));
    jTextNumeroRegle.setText("Rule n°.. / .. (total : ...)");
    add(jTextNumeroRegle);
    jTextNumeroRegle.setBounds(10, 110, 210, 20);
    //scroll bar
    jScrollBarRegles.setMaximum(0);
    jScrollBarRegles.setOrientation(javax.swing.JScrollBar.HORIZONTAL);
    jScrollBarRegles.addAdjustmentListener(new java.awt.event.AdjustmentListener() {

        public void adjustmentValueChanged(java.awt.event.AdjustmentEvent evt) {
            jScrollBarReglesAdjustmentValueChanged(evt);
        }
    });
    add(jScrollBarRegles);
    jScrollBarRegles.setBounds(220, 110, 100, 20);
    //jScrollBarRegles.setBounds(220, 110, 130, 20);
    //copy button
    jButtonCopy.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButtonCopyActionPerformed(evt);
        }
    });
    add(jButtonCopy);
    jButtonCopy.setBounds(320, 110, 20, 20);
    // jButtonCopy.setBounds(350, 110, 20, 20);
    //button --Extract rows for a specific rule
    jButtonExtractRows.setText("Extract rows");
    jButtonExtractRows.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButtonExtractActionPerformed(evt);
        }
    });
    add(jButtonExtractRows);
    jButtonExtractRows.setBounds(340, 110, 120, 20);
    //button --save in a file 
    jButtonSauver.setText("Save in a file");
    jButtonSauver.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButtonSauverActionPerformed(evt);
        }
    });
    add(jButtonSauver);
    jButtonSauver.setBounds(10, 10, 210, 26);
    //scroll panel --about resulted rules
    jScrollRegles.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    jScrollRegles.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    add(jScrollRegles);
    jScrollRegles.setBounds(10, 130, 360, 40);
    //button --Visualize the extraction context
    jButtonVoirContexte.setText("Visualize the extraction context");
    jButtonVoirContexte.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButtonVoirContexteActionPerformed(evt);
        }
    });
    add(jButtonVoirContexte);
    jButtonVoirContexte.setBounds(240, 10, 250, 26);
}
Example 69
Project: AFA2-master  File: AnalisisFeedbackPanel.java View source code
void printAnalisisMessage(String s, Color color) {
    // Atributos para la frase
    final Color c = color;
    final String text = s;
    SimpleAttributeSet attrs = new SimpleAttributeSet();
    StyleConstants.setForeground(attrs, c);
    try {
        feedback.getStyledDocument().insertString(feedback.getStyledDocument().getLength(), text + "\n", attrs);
    } catch (Exception e) {
        e.printStackTrace();
    }
    java.awt.EventQueue.invokeLater(new Thread() {

        @Override
        public void run() {
            if (getAutoScrollDown()) {
                JScrollBar bar = jScrollPane3.getVerticalScrollBar();
                bar.setValue(bar.getMaximum());
            }
        //
        }
    });
}
Example 70
Project: Android-MQTT-Websocket-Client-master  File: MQTTHist.java View source code
/**
     * This run method runs in a separate thread created by this class and
     * waits to be notified that it needs to scroll the window. If no data is being
     * written to the log then it can be scrolled up and down by the user
     * without being continuously autoscrolled to theby this thread.
     */
public void run() {
    JScrollBar jsb = scroller.getVerticalScrollBar();
    while (running) {
        try {
            synchronized (histData) {
                histData.wait();
            }
            // Take a short nap after being notified to
            // allow the swing components to revalidate themselves
            Thread.sleep(100);
        } catch (Exception e) {
        }
        // Autoscroll the text area to the bottom
        jsb.setValue(jsb.getMaximum());
    }
}
Example 71
Project: ascension-log-visualizer-new-master  File: GanttChartBuilder.java View source code
@Override
protected void addChart() {
    super.addChart();
    final int scrollCaretExtend = 20;
    int scrollableAreaIntervals = ((TurnRundownDataset) this.dataset.getUnderlyingDataset()).getDataset().size() - (this.dataset.getMaximumCategoryCount() - scrollCaretExtend);
    scrollableAreaIntervals = scrollableAreaIntervals > 20 ? scrollableAreaIntervals : 20;
    final JScrollBar scrollBar = new JScrollBar(Adjustable.VERTICAL, 0, scrollCaretExtend, 0, scrollableAreaIntervals);
    scrollBar.getModel().addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(final ChangeEvent e) {
            GanttChartBuilder.this.dataset.setFirstCategoryIndex(scrollBar.getValue());
        }
    });
    this.add(scrollBar, BorderLayout.EAST);
}
Example 72
Project: batik-master  File: SwingSVGPrettyPrint.java View source code
/**
     * @param cmp Swing component to be converted to SVG
     * @param svgGen SVGraphics2D to use to paint Swing components
     */
public static void print(JComponent cmp, SVGGraphics2D svgGen) {
    if ((cmp instanceof JComboBox) || (cmp instanceof JScrollBar)) {
        // This is a work around unresolved issue with JComboBox
        // and JScrollBar
        printHack(cmp, svgGen);
        return;
    }
    // Spawn a new Graphics2D for this component
    SVGGraphics2D g = (SVGGraphics2D) svgGen.create();
    g.setColor(cmp.getForeground());
    g.setFont(cmp.getFont());
    Element topLevelGroup = g.getTopLevelGroup();
    // If there is no area to be painted, return here
    if ((cmp.getWidth() <= 0) || (cmp.getHeight() <= 0))
        return;
    Rectangle clipRect = g.getClipBounds();
    if (clipRect == null)
        g.setClip(0, 0, cmp.getWidth(), cmp.getHeight());
    paintComponent(cmp, g);
    paintBorder(cmp, g);
    paintChildren(cmp, g);
    // Now, structure DOM tree to reflect this component's structure
    Element cmpGroup = g.getTopLevelGroup();
    cmpGroup.setAttributeNS(null, "id", svgGen.getGeneratorContext().idGenerator.generateID(cmp.getClass().getName()));
    topLevelGroup.appendChild(cmpGroup);
    svgGen.setTopLevelGroup(topLevelGroup);
}
Example 73
Project: cids-navigator-master  File: DefaultBindableScrollableComboBox.java View source code
/**
         * Calculates the placement and size of the popup portion of the combo box based on the combo box location and
         * the enclosing screen bounds. If no transformations are required, then the returned rectangle will have the
         * same values as the parameters.
         *
         * <p>In addition to the superclass behavior, this class offers to use the combo's popup prototype display value
         * to compute the popup menu width. This is an optional feature of the JGoodies Plastic L&fs implemented via
         * a client property key.</p>
         *
         * <p>If a prototype is set, the popup width is the maximum of the combobox width and the prototype based popup
         * width. For the latter the renderer is used to render the prototype. The prototype based popup width is the
         * prototype's width plus the scrollbar width - if any. The scrollbar test checks if there are more items than
         * the combo's maximum row count.</p>
         *
         * @param   px  starting x location
         * @param   py  starting y location
         * @param   pw  starting width
         * @param   ph  starting height
         *
         * @return  a rectangle which represents the placement and size of the popup
         *
         * @see     Options#COMBO_POPUP_PROTOTYPE_DISPLAY_VALUE_KEY
         * @see     JComboBox#getMaximumRowCount()
         */
@Override
protected Rectangle computePopupBounds(final int px, final int py, int pw, final int ph) {
    final Rectangle defaultBounds = super.computePopupBounds(px, py, pw, ph);
    final Object popupPrototypeDisplayValue = comboBox.getClientProperty(Options.COMBO_POPUP_PROTOTYPE_DISPLAY_VALUE_KEY);
    if (popupPrototypeDisplayValue == null) {
        return defaultBounds;
    }
    final ListCellRenderer renderer = list.getCellRenderer();
    final Component c = renderer.getListCellRendererComponent(list, popupPrototypeDisplayValue, -1, true, true);
    pw = c.getPreferredSize().width;
    final boolean hasVerticalScrollBar = comboBox.getItemCount() > comboBox.getMaximumRowCount();
    if (hasVerticalScrollBar) {
        // Add the scrollbar width.
        final JScrollBar verticalBar = scroller.getVerticalScrollBar();
        pw += verticalBar.getPreferredSize().width;
    }
    final Rectangle prototypeBasedBounds = super.computePopupBounds(px, py, pw, ph);
    return (prototypeBasedBounds.width > defaultBounds.width) ? prototypeBasedBounds : defaultBounds;
}
Example 74
Project: cismet-gui-commons-master  File: ScrollableComboBox.java View source code
/**
         * Calculates the placement and size of the popup portion of the combo box based on the combo box location and
         * the enclosing screen bounds. If no transformations are required, then the returned rectangle will have the
         * same values as the parameters.
         *
         * <p>In addition to the superclass behavior, this class offers to use the combo's popup prototype display value
         * to compute the popup menu width. This is an optional feature of the JGoodies Plastic L&fs implemented via
         * a client property key.</p>
         *
         * <p>If a prototype is set, the popup width is the maximum of the combobox width and the prototype based popup
         * width. For the latter the renderer is used to render the prototype. The prototype based popup width is the
         * prototype's width plus the scrollbar width - if any. The scrollbar test checks if there are more items than
         * the combo's maximum row count.</p>
         *
         * @param   px  starting x location
         * @param   py  starting y location
         * @param   pw  starting width
         * @param   ph  starting height
         *
         * @return  a rectangle which represents the placement and size of the popup
         *
         * @see     Options#COMBO_POPUP_PROTOTYPE_DISPLAY_VALUE_KEY
         * @see     JComboBox#getMaximumRowCount()
         */
@Override
protected Rectangle computePopupBounds(final int px, final int py, int pw, final int ph) {
    final Rectangle defaultBounds = super.computePopupBounds(px, py, pw, ph);
    final Object popupPrototypeDisplayValue = comboBox.getClientProperty(Options.COMBO_POPUP_PROTOTYPE_DISPLAY_VALUE_KEY);
    if (popupPrototypeDisplayValue == null) {
        return defaultBounds;
    }
    final ListCellRenderer renderer = list.getCellRenderer();
    final Component c = renderer.getListCellRendererComponent(list, popupPrototypeDisplayValue, -1, true, true);
    pw = c.getPreferredSize().width;
    final boolean hasVerticalScrollBar = comboBox.getItemCount() > comboBox.getMaximumRowCount();
    if (hasVerticalScrollBar) {
        // Add the scrollbar width.
        final JScrollBar verticalBar = scroller.getVerticalScrollBar();
        pw += verticalBar.getPreferredSize().width;
    }
    final Rectangle prototypeBasedBounds = super.computePopupBounds(px, py, pw, ph);
    return (prototypeBasedBounds.width > defaultBounds.width) ? prototypeBasedBounds : defaultBounds;
}
Example 75
Project: dualsub-master  File: PanelTiming.java View source code
private void initialize() {
    this.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), I18N.getHtmlText("PanelTiming.border.text"), TitledBorder.LEADING, TitledBorder.TOP, null, null));
    this.setBounds(360, 220, 305, 111);
    this.setLayout(null);
    this.setBackground(parent.getBackground());
    // Persistence
    JLabel lblPersistence = new JLabel(I18N.getHtmlText("PanelTiming.persistence.text"));
    lblPersistence.setBounds(12, 23, 100, 23);
    this.add(lblPersistence);
    // Extension
    extensionSeconds = new JTextField();
    extensionSeconds.setBounds(155, 23, 25, 20);
    extensionSeconds.setColumns(10);
    String savedSecobds = parent.getPreferences().get("seconds", parent.getProperties().getProperty("extensionSeconds"));
    if (savedSecobds != null) {
        extensionSeconds.setText(savedSecobds);
    }
    this.add(extensionSeconds);
    // Seconds
    JLabel lblSeconds = new JLabel(I18N.getHtmlText("PanelTiming.lblSeconds.text"));
    lblSeconds.setBounds(185, 23, 90, 20);
    this.add(lblSeconds);
    // Progressive
    boolean savedProgressive = Boolean.parseBoolean(parent.getPreferences().get("progressive", parent.getProperties().getProperty("progressive")));
    progressiveCheckBox = new JCheckBox(I18N.getHtmlText("PanelTiming.progressive.text"));
    progressiveCheckBox.setSelected(savedProgressive);
    progressiveCheckBox.setBounds(185, 38, 105, 23);
    progressiveCheckBox.setCursor(parent.getCursor());
    progressiveCheckBox.setBackground(parent.getBackground());
    this.add(progressiveCheckBox);
    // No
    rdbtnNo = new JRadioButton(I18N.getHtmlText("PanelTiming.rdbtnNo.text"));
    rdbtnNo.setBounds(112, 43, 50, 23);
    rdbtnNo.setCursor(parent.getCursor());
    rdbtnNo.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent arg0) {
            switchRadioButton(false);
        }
    });
    rdbtnNo.setBackground(parent.getBackground());
    this.add(rdbtnNo);
    // Yes
    rdbtnYes = new JRadioButton(I18N.getHtmlText("PanelTiming.rdbtnYes.text"));
    rdbtnYes.setBounds(112, 23, 50, 23);
    rdbtnYes.setCursor(parent.getCursor());
    rdbtnYes.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent arg0) {
            switchRadioButton(true);
        }
    });
    rdbtnYes.setBackground(parent.getBackground());
    this.add(rdbtnYes);
    ButtonGroup groupExtension = new ButtonGroup();
    groupExtension.add(rdbtnYes);
    groupExtension.add(rdbtnNo);
    boolean savedExtension = Boolean.parseBoolean(parent.getPreferences().get("persistence", parent.getProperties().getProperty("selectedPersistence")));
    if (savedExtension) {
        rdbtnYes.setSelected(true);
        switchRadioButton(true);
    } else {
        rdbtnNo.setSelected(true);
        switchRadioButton(false);
    }
    // Synchronization
    JLabel lblDesync = new JLabel(I18N.getHtmlText("PanelTiming.desync.text"));
    lblDesync.setBounds(12, 52, 160, 23);
    this.add(lblDesync);
    desyncComboBox = new JComboBox<String>();
    desyncComboBox.setCursor(parent.getCursor());
    desyncComboBox.setModel(new DefaultComboBoxModel<String>(new String[] { I18N.getHtmlText("PanelTiming.left.text"), I18N.getHtmlText("PanelTiming.right.text"), I18N.getHtmlText("PanelTiming.max.text"), I18N.getHtmlText("PanelTiming.min.text") }));
    desyncComboBox.setBounds(80, 75, 220, 20);
    String savedDesync = parent.getPreferences().get("desync", parent.getProperties().getProperty("selectedDesyncIndex"));
    if (savedDesync != null) {
        desyncComboBox.setSelectedIndex(Integer.parseInt(savedDesync));
    }
    Object comp = desyncComboBox.getUI().getAccessibleChild(this, 0);
    JPopupMenu popup = (JPopupMenu) comp;
    JScrollPane scrollPane = (JScrollPane) popup.getComponent(0);
    scrollPane.setHorizontalScrollBar(new JScrollBar(JScrollBar.HORIZONTAL));
    scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    this.add(desyncComboBox);
    // Help
    JButton buttonHelpDelay = new JButton(new ImageIcon(ClassLoader.getSystemResource("img/help.png")));
    buttonHelpDelay.setBounds(273, 16, 22, 22);
    buttonHelpDelay.setCursor(parent.getCursor());
    buttonHelpDelay.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            HelpTimingDialog helpTimingDialog = parent.getHelpTiming();
            if (helpTimingDialog == null) {
                helpTimingDialog = new HelpTimingDialog(parent, true);
            }
            helpTimingDialog.setVisible();
        }
    });
    this.add(buttonHelpDelay);
    // Borders (for debug purposes)
    if (log.isTraceEnabled()) {
        Border border = BorderFactory.createLineBorder(Color.black);
        lblPersistence.setBorder(border);
        lblDesync.setBorder(border);
        lblSeconds.setBorder(border);
        rdbtnNo.setBorderPainted(true);
        rdbtnYes.setBorderPainted(true);
        progressiveCheckBox.setBorderPainted(true);
        lblDesync.setBorder(border);
    }
}
Example 76
Project: FloreantPos-master  File: SelectionView.java View source code
private int scrollByBlock(JScrollBar scrollbar, int direction) {
    // This method is called from BasicScrollPaneUI to implement wheel
    // scrolling, and also from scrollByBlock().
    int oldValue = scrollbar.getValue();
    int blockIncrement = scrollbar.getBlockIncrement();
    int delta = blockIncrement * ((direction > 0) ? +1 : -1);
    int newValue = oldValue + delta;
    // Check for overflow.
    if (delta > 0 && newValue < oldValue) {
        newValue = scrollbar.getMaximum();
    } else if (delta < 0 && newValue > oldValue) {
        newValue = scrollbar.getMinimum();
    }
    return newValue;
}
Example 77
Project: funCKit-master  File: EditPanelScrollPane.java View source code
private void initialize(EditPanel panel, View view) {
    southScrollBar = new JScrollBar(Adjustable.HORIZONTAL);
    southScrollBar.setUnitIncrement(SCROLLBAR_UNIT_INCREMENT);
    southScrollBar.getModel().addChangeListener(new EditPanelScrollPaneHorizontalScrollbarBoundedRangeModelChangeListener(view, view.getController(), this));
    eastScrollBar = new JScrollBar(Adjustable.VERTICAL);
    eastScrollBar.setUnitIncrement(SCROLLBAR_UNIT_INCREMENT);
    eastScrollBar.getModel().addChangeListener(new EditPanelScrollPaneVerticalScrollbarBoundedRangeModelChangeListener(view, view.getController(), this));
    this.setLayout(new MigLayout("fill, insets 0"));
    add(southScrollBar, "dock south, growx");
    add(eastScrollBar, "dock east, growy");
    if (panel != null) {
        setEditPanel(panel);
    }
}
Example 78
Project: GenPlay-master  File: GenomeWidthChooser.java View source code
/**
	 * Creates the component and all the subcomponents.
	 */
private void initComponent() {
    jsbGenomeWidth = new JScrollBar(Adjustable.HORIZONTAL, validGenomeWidth, 0, windowSize, windowSize * 1000);
    jsbGenomeWidth.setBlockIncrement(windowSize);
    jsbGenomeWidth.setUnitIncrement(windowSize);
    jsbGenomeWidth.addAdjustmentListener(new AdjustmentListener() {

        @Override
        public void adjustmentValueChanged(AdjustmentEvent e) {
            jsbSigmaAdjustmentValueChanged();
        }
    });
    jftfGenomeWidth = new JFormattedTextField(NumberFormats.getPositionFormat());
    jftfGenomeWidth.setValue(validGenomeWidth);
    jftfGenomeWidth.setColumns(8);
    jftfGenomeWidth.addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            jftfSigmaPropertyChange();
        }
    });
    jftfGenomeWidth.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void changedUpdate(DocumentEvent e) {
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            jftfSigmaDocumentChange();
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            jftfSigmaDocumentChange();
        }
    });
    jlSigma = new JLabel();
    jlSigma.setVisible(showSigma);
    updateSigmaLabeText(validGenomeWidth);
    jbOk = new JButton("OK");
    jbOk.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            jbOkActionPerformed();
        }
    });
    jbCancel = new JButton("Cancel");
    jbCancel.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            jbCancelActionPerformed();
        }
    });
    // we want the size of the two buttons to be equal
    jbOk.setPreferredSize(jbCancel.getPreferredSize());
    setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.CENTER;
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 2;
    add(jsbGenomeWidth, c);
    c.fill = GridBagConstraints.NONE;
    c.gridy = 1;
    add(jftfGenomeWidth, c);
    c.gridy = 2;
    add(jlSigma, c);
    c.gridwidth = 1;
    c.gridx = 0;
    c.gridy = 3;
    add(jbOk, c);
    c.gridx = 1;
    add(jbCancel, c);
    setSize(DIALOG_DIMENSION);
    setResizable(false);
}
Example 79
Project: hestia-engine-dev-master  File: MQTTHist.java View source code
/**
     * This run method runs in a separate thread created by this class and
     * waits to be notified that it needs to scroll the window. If no data is being
     * written to the log then it can be scrolled up and down by the user
     * without being continuously autoscrolled to theby this thread.
     */
public void run() {
    JScrollBar jsb = scroller.getVerticalScrollBar();
    while (running) {
        try {
            synchronized (histData) {
                histData.wait();
            }
            // Take a short nap after being notified to
            // allow the swing components to revalidate themselves
            Thread.sleep(100);
        } catch (Exception e) {
        }
        // Autoscroll the text area to the bottom
        jsb.setValue(jsb.getMaximum());
    }
}
Example 80
Project: hfsexplorer-master  File: JTextAreaOutputStream.java View source code
/* @Override */
public void run() {
    synchronized (syncObject) {
        //textArea.append(curBuilder.toString());
        //curBuilder.setLength(0);
        updateRequested = false;
        JScrollBar sb = textAreaScroller.getVerticalScrollBar();
        sb.setValue(sb.getMaximum() - sb.getVisibleAmount());
    }
//textArea.append(s);
//textArea.append(" [Update!] ");
}
Example 81
Project: jamel-master  File: HtmlPanel.java View source code
@Override
public void run() {
    // The scroll bar listModel contains information needed to
    // determine
    // whether the viewport should be repositioned or not.
    final JScrollBar scrollBar = (JScrollBar) e.getSource();
    final BoundedRangeModel listModel = scrollBar.getModel();
    int value = listModel.getValue();
    final int extent = listModel.getExtent();
    final int maximum = listModel.getMaximum();
    final boolean valueChanged = previousValue != value;
    final boolean maximumChanged = previousMaximum != maximum;
    if (valueChanged && !maximumChanged) {
        adjustScrollBar = value + extent >= maximum;
    }
    if (adjustScrollBar) {
        // Scroll the viewport to the end.
        scrollBar.removeAdjustmentListener(HtmlPanel.this);
        value = maximum - extent;
        scrollBar.setValue(value);
        scrollBar.addAdjustmentListener(HtmlPanel.this);
    }
    previousValue = value;
    previousMaximum = maximum;
}
Example 82
Project: jradius-master  File: LogConsole.java View source code
public void appender(String category, String s) {
    SimpleAttributeSet sas = new SimpleAttributeSet();
    if (s == null)
        return;
    if (s.trim().length() == 0)
        return;
    Document doc = getDocument();
    StyleConstants.setFontFamily(sas, getFont().getFamily());
    StyleConstants.setFontSize(sas, getFont().getSize());
    StyleConstants.setBold(sas, getFont().isBold());
    StyleConstants.setItalic(sas, getFont().isItalic());
    StyleConstants.setBackground(sas, getBackground());
    if (TSPattern != null && sdf != null && !s.equalsIgnoreCase(defaultText)) {
        String ts = sdf.format(new Date());
        StyleConstants.setForeground(sas, getForeground());
        ts = ts.concat(" ");
        try {
            doc.insertString(doc.getLength(), ts, sas);
        } catch (Exception e) {
        }
    }
    if (CATEGORY_PACKETS_SENT.equalsIgnoreCase(category)) {
        StyleConstants.setForeground(sas, (clrSent == null ? getForeground() : clrSent));
    } else if (CATEGORY_PACKETS_RECV.equalsIgnoreCase(category)) {
        StyleConstants.setForeground(sas, (clrRecv == null ? getForeground() : clrRecv));
    } else if (CATEGORY_ERROR.equalsIgnoreCase(category)) {
        StyleConstants.setForeground(sas, (clrError == null ? getForeground() : clrError));
    }
    try {
        doc.insertString(doc.getLength(), s, sas);
    } catch (Exception e) {
        e.printStackTrace();
    }
    if (autoScroll) {
        try {
            int length = doc.getLength();
            console.setCaretPosition(length);
            Rectangle r = console.modelToView(length - 1);
            if (r != null)
                scrollRectToVisible(r);
        } catch (Exception e) {
            e.printStackTrace();
        }
        JScrollBar vs = container.getVerticalScrollBar();
        vs.setValue(vs.getMaximum());
    }
    console.invalidate();
    repaint();
}
Example 83
Project: kkMulticopterFlashTool-master  File: PropertyDialog.java View source code
public synchronized int defineScrollBar(int needSizeH) {
    this.needSizeH = needSizeH;
    /*
		if(!wasAddNotify){
			return 10;
		}
*/
    if (vScrollBar != null)
        remove(vScrollBar);
    int insetsH = getInsets().top + getInsets().bottom;
    int panelSize = ps.getSize().height;
    vScrollBar = new JScrollBar();
    int scrollW = vScrollBar.getPreferredSize().width;
    vScrollBar.setLocation(getSize().width + 1, 0);
    vScrollBar.setSize(scrollW, needSizeH - insetsH);
    add(vScrollBar);
    int visisbleSize = needSizeH - insetsH;
    deltaScrollbar = visisbleSize - panelSize;
    vScrollBar.setMaximum(panelSize);
    vScrollBar.setVisibleAmount(visisbleSize);
    vScrollBar.setUnitIncrement((int) Math.ceil((float) visisbleSize / 20f));
    vScrollBar.setBlockIncrement(visisbleSize / 5);
    vScrollBar.getModel().addChangeListener(new javax.swing.event.ChangeListener() {

        public void stateChanged(javax.swing.event.ChangeEvent e) {
            if (e.getSource() instanceof javax.swing.BoundedRangeModel) {
                javax.swing.BoundedRangeModel model = (javax.swing.BoundedRangeModel) e.getSource();
                int newValue = model.getValue();
                if (newValue == currScrollValue)
                    return;
                currScrollValue = newValue;
                float k = (float) currScrollValue / (float) (vScrollBar.getMaximum() - vScrollBar.getVisibleAmount()) * (float) deltaScrollbar;
                ps.setLocation(ps.getLocation().x, Math.round(k));
                invalidate();
                repaint();
            }
        }
    });
    return (scrollW + 3);
}
Example 84
Project: logisim-evolution-master  File: SmartScroller.java View source code
/*
	 * Analyze every adjustment event to determine when the viewport needs to be
	 * repositioned.
	 */
private void checkScrollBar(AdjustmentEvent e) {
    // The scroll bar listModel contains information needed to determine
    // whether the viewport should be repositioned or not.
    JScrollBar scrollBar = (JScrollBar) e.getSource();
    BoundedRangeModel listModel = scrollBar.getModel();
    int value = listModel.getValue();
    int extent = listModel.getExtent();
    int maximum = listModel.getMaximum();
    boolean valueChanged = previousValue != value;
    boolean maximumChanged = previousMaximum != maximum;
    if (valueChanged && !maximumChanged) {
        if (viewportPosition == START)
            adjustScrollBar = value != 0;
        else
            adjustScrollBar = value + extent >= maximum;
    }
    if (adjustScrollBar && viewportPosition == END) {
        // Scroll the viewport to the end.
        scrollBar.removeAdjustmentListener(this);
        value = maximum - extent;
        scrollBar.setValue(value);
        scrollBar.addAdjustmentListener(this);
    }
    if (adjustScrollBar && viewportPosition == START) {
        // Keep the viewport at the same relative viewportPosition
        scrollBar.removeAdjustmentListener(this);
        value = value + maximum - previousMaximum;
        scrollBar.setValue(value);
        scrollBar.addAdjustmentListener(this);
    }
    previousValue = value;
    previousMaximum = maximum;
}
Example 85
Project: Mace-Swinger-master  File: LightScrollPane.java View source code
@Override
protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) {
    int alpha = isThumbRollover() ? SCROLL_BAR_ALPHA_ROLLOVER : SCROLL_BAR_ALPHA;
    int orientation = scrollbar.getOrientation();
    int arc = THUMB_SIZE;
    int x = thumbBounds.x + THUMB_BORDER_SIZE;
    int y = thumbBounds.y + THUMB_BORDER_SIZE;
    int width = orientation == JScrollBar.VERTICAL ? THUMB_SIZE : thumbBounds.width - (THUMB_BORDER_SIZE * 2);
    width = Math.max(width, THUMB_SIZE);
    int height = orientation == JScrollBar.VERTICAL ? thumbBounds.height - (THUMB_BORDER_SIZE * 2) : THUMB_SIZE;
    height = Math.max(height, THUMB_SIZE);
    Graphics2D graphics2D = (Graphics2D) g.create();
    graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    graphics2D.setColor(new Color(THUMB_COLOR.getRed(), THUMB_COLOR.getGreen(), THUMB_COLOR.getBlue(), alpha));
    if (orientation == JScrollBar.VERTICAL)
        height += dh;
    graphics2D.fillRoundRect(x, y, width, height, arc, arc);
    graphics2D.dispose();
}
Example 86
Project: MinecraftAutoInstaller-master  File: UpdateDialog.java View source code
/**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
@SuppressWarnings("unchecked")
private // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
void initComponents() {
    jPanel1 = new javax.swing.JPanel();
    jLabel1 = new javax.swing.JLabel();
    jButton1 = new javax.swing.JButton();
    jLabel2 = new javax.swing.JLabel();
    jPanel2 = new javax.swing.JPanel();
    jScrollPane1 = new javax.swing.JScrollPane();
    jTextArea1 = new javax.swing.JTextArea();
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setIconImage(wicon.getImage());
    setLocation(screenSize.width / 2 - 174, screenSize.height / 2 - 90);
    jPanel1.setBackground(new java.awt.Color(255, 255, 255));
    jPanel1.setLayout(null);
    jLabel1.setFont(font.deriveFont(Font.PLAIN, 24));
    jLabel1.setForeground(new java.awt.Color(255, 255, 255));
    jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    jLabel1.setText("업��트가 있습니다!");
    jPanel1.add(jLabel1);
    jLabel1.setBounds(10, 0, 330, 40);
    jButton1.setBackground(colorCom);
    jButton1.setFont(font.deriveFont(Font.PLAIN, 14));
    jButton1.setForeground(new java.awt.Color(255, 255, 255));
    jButton1.setText("업��트");
    jButton1.setBorder(null);
    jButton1.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton1ActionPerformed(evt);
        }
    });
    jPanel1.add(jButton1);
    jButton1.setBounds(130, 120, 90, 30);
    jLabel2.setFont(font.deriveFont(Font.PLAIN, 12));
    jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
    jLabel2.setText("MAI v2.1 by ITSTAKE, itstake.tk");
    jPanel1.add(jLabel2);
    jLabel2.setBounds(120, 150, 210, 15);
    jPanel2.setBackground(colorCom);
    javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
    jPanel2.setLayout(jPanel2Layout);
    jPanel2Layout.setHorizontalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 350, Short.MAX_VALUE));
    jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 40, Short.MAX_VALUE));
    jPanel1.add(jPanel2);
    jPanel2.setBounds(0, 0, 350, 40);
    jScrollPane1.setBorder(null);
    jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    jTextArea1.setEditable(false);
    jTextArea1.setColumns(20);
    jTextArea1.setFont(font.deriveFont(Font.PLAIN, 14));
    jTextArea1.setRows(5);
    jTextArea1.setText(updateDescript);
    jTextArea1.setBorder(null);
    jScrollPane1.setViewportView(jTextArea1);
    JScrollBar vertical = jScrollPane1.getVerticalScrollBar();
    vertical.setPreferredSize(new Dimension(0, 0));
    jPanel1.add(jScrollPane1);
    jScrollPane1.setBounds(20, 60, 310, 60);
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 348, javax.swing.GroupLayout.PREFERRED_SIZE));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 180, Short.MAX_VALUE));
    pack();
}
Example 87
Project: monsiaj-master  File: CListHandler.java View source code
@Override
public void set(UIControl con, Component widget, JSONObject obj, Map styleMap) throws JSONException {
    JTable table = (JTable) widget;
    PandaCList clist = (PandaCList) widget;
    DefaultTableModel tableModel = (DefaultTableModel) table.getModel();
    TableModelListener[] listeners = tableModel.getTableModelListeners();
    int count = 0;
    if (obj.has("count")) {
        count = obj.getInt("count");
    }
    double rowattr = 0.0;
    if (obj.has("rowattr")) {
        int ra = obj.getInt("rowattr");
        switch(ra) {
            case 1:
                rowattr = 1.0;
                break;
            case 2:
                rowattr = 0.5;
                break;
            case 3:
                rowattr = 0.25;
                break;
            case 4:
                rowattr = 0.75;
                break;
            default:
                rowattr = 0.0;
                break;
        }
    }
    if (obj.has("item")) {
        JSONArray array = obj.getJSONArray("item");
        int n = array.length();
        n = n > count ? count : n;
        int rows = tableModel.getRowCount();
        int columns = tableModel.getColumnCount();
        for (TableModelListener l : listeners) {
            tableModel.removeTableModelListener(l);
        }
        if (n < rows) {
            for (int i = rows; i > n; i--) {
                tableModel.removeRow(i - 1);
            }
        } else if (n > rows) {
            Object rowData[] = new String[columns];
            for (int i = rows; i < n; i++) {
                tableModel.addRow(rowData);
            }
        }
        for (int i = 0; i < n; i++) {
            JSONObject rowObj = array.getJSONObject(i);
            for (int j = 0; j < columns; j++) {
                String key = "column" + (j + 1);
                tableModel.setValueAt(rowObj.getString(key), i, j);
            }
        }
        for (TableModelListener l : listeners) {
            tableModel.addTableModelListener(l);
        }
    }
    if (obj.has("bgcolor")) {
        JSONArray array = obj.getJSONArray("bgcolor");
        Color[] bgcolors = new Color[array.length()];
        for (int i = 0; i < array.length(); i++) {
            bgcolors[i] = SafeColorDecoder.decode(array.getString(i));
            if (bgcolors[i] == null) {
                bgcolors[i] = Color.WHITE;
            }
        }
        clist.setBGColors(bgcolors);
    }
    if (obj.has("fgcolor")) {
        JSONArray array = obj.getJSONArray("fgcolor");
        Color[] fgcolors = new Color[array.length()];
        for (int i = 0; i < array.length(); i++) {
            fgcolors[i] = SafeColorDecoder.decode(array.getString(i));
            if (fgcolors[i] == null) {
                fgcolors[i] = Color.BLACK;
            }
        }
        clist.setFGColors(fgcolors);
    }
    int row = 0;
    if (obj.has("row")) {
        row = obj.getInt("row");
        int row2;
        if (row <= 0) {
            row2 = 0;
        } else {
            row2 = row - 1;
        }
        if (row2 >= count) {
            row2 = count - 1;
        }
        if (row2 >= 0) {
            clist.changeSelection(row2, 0, false, false);
        }
    }
    if (obj.has("selectdata")) {
        JSONArray array = obj.getJSONArray("selectdata");
        int n = array.length();
        n = n > count ? count : n;
        boolean[] selection = new boolean[n];
        for (int j = 0; j < n; j++) {
            boolean selected = array.getBoolean(j);
            selection[j] = selected;
            if (clist.getMode() == PandaCList.SELECTION_MODE_MULTI && selected) {
                clist.changeSelection(j, 0, false, false);
            }
        }
        clist.setSelection(selection);
    }
    JScrollBar vScroll = getVerticalScrollBar(table);
    if (vScroll != null) {
        BoundedRangeModel model = vScroll.getModel();
        int max = model.getMaximum();
        int min = model.getMinimum();
        if (row <= 0) {
            row = 1;
        }
        if (count > 0) {
            int value = (int) (((row - 1) * 1.0 / count) * (max - min)) + min;
            if (rowattr == 1.0) {
                value += (int) ((1.0 / count) * (max - min));
            }
            value -= rowattr * model.getExtent();
            if (value < 0) {
                value = 0;
            }
            model.setValue(value);
        } else {
            model.setValue(0);
        }
    }
    this.setCommonAttribute(widget, obj, styleMap);
    widget.setVisible(false);
    widget.setVisible(true);
    clist.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
}
Example 88
Project: MPS-master  File: FoldingButton.java View source code
void activate(int x, int y) {
    EditorCell cell = getCell();
    if (cell instanceof EditorCell_Collection) {
        EditorCell_Collection collection = (EditorCell_Collection) cell;
        if (CellTraversalUtil.getFoldedParent(collection) != null) {
            return;
        }
        if (collection.isCollapsed()) {
            collection.unfold();
        } else {
            if (isOnBottomButton(y)) {
                JScrollBar verticalScrollBar = ((jetbrains.mps.nodeEditor.EditorComponent) myEditor).getVerticalScrollBar();
                verticalScrollBar.setValue(Math.max(verticalScrollBar.getValue() - (myY2 - myY1 - HEIGHT), 0));
            }
            collection.fold();
        }
    }
}
Example 89
Project: nmedit-master  File: NMNoteSeqEditor.java View source code
public static void main(String[] args) {
    JFrame f = new JFrame(NMNoteSeqEditor.class.getName());
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setBounds(0, 0, 400, 360);
    f.getContentPane().setLayout(null);
    final NMNoteSeqEditor ed = new NMNoteSeqEditor(null);
    ed.setUI(NoteSeqEditorUI.createUI(ed));
    f.getContentPane().add(ed);
    final JScrollBar sb = new JScrollBar(JScrollBar.VERTICAL, ed.getZoom(), 1, ed.getMinZoom(), ed.getMaxZoom() + 1);
    sb.addAdjustmentListener(new AdjustmentListener() {

        public void adjustmentValueChanged(AdjustmentEvent e) {
            ed.setZoom(sb.getValue());
        }
    });
    ed.setLocation(0, 0);
    ed.setSize(ed.getPreferredSize());
    sb.setLocation(ed.getWidth() + 2, 0);
    sb.setSize(13, ed.getHeight());
    f.getContentPane().addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {
            ed.randomize();
        }
    });
    f.getContentPane().add(sb);
    f.setVisible(true);
}
Example 90
Project: openaltimeter-downloader-master  File: AltimeterChart.java View source code
private JScrollBar getScrollBar(final ValueAxis domainAxis) {
    final JScrollBar scrollBar = new JScrollBar(JScrollBar.HORIZONTAL, 0, 0, 0, 0);
    scrollBar.addAdjustmentListener(new AdjustmentListener() {

        public void adjustmentValueChanged(AdjustmentEvent e) {
            int x = e.getValue();
            domainAxis.setRange(x, x + scrollBar.getVisibleAmount());
        }
    });
    return scrollBar;
}
Example 91
Project: orbisgis-master  File: MapsManager.java View source code
/**
         * Compute the best height to show all the items of the JTree 
         * plus the decoration height.
         * @return Height in pixels
         */
public Dimension getMinimalComponentDimension() {
    Dimension panel = getPreferredSize();
    Dimension treeDim = tree.getPreferredSize();
    // Get the vertical scrollbar width
    JScrollBar scrollBar = scrollPane.getVerticalScrollBar();
    if (scrollBar != null && scrollBar.isVisible()) {
        return new Dimension(panel.width + scrollBar.getWidth(), treeDim.height + getMinimumSize().height);
    } else {
        return new Dimension(panel.width, treeDim.height + getMinimumSize().height);
    }
}
Example 92
Project: paho.mqtt.java-master  File: MQTTHist.java View source code
/**
     * This run method runs in a separate thread created by this class and
     * waits to be notified that it needs to scroll the window. If no data is being
     * written to the log then it can be scrolled up and down by the user
     * without being continuously autoscrolled to theby this thread.
     */
public void run() {
    JScrollBar jsb = scroller.getVerticalScrollBar();
    while (running) {
        try {
            synchronized (histData) {
                histData.wait();
            }
            // Take a short nap after being notified to
            // allow the swing components to revalidate themselves
            Thread.sleep(100);
        } catch (Exception e) {
        }
        // Autoscroll the text area to the bottom
        jsb.setValue(jsb.getMaximum());
    }
}
Example 93
Project: pdfbox-master  File: HexEditor.java View source code
private JScrollPane getScrollPane() {
    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBorder(new LineBorder(Color.LIGHT_GRAY));
    Action blankAction = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
        }
    };
    scrollPane.getActionMap().put("unitScrollDown", blankAction);
    scrollPane.getActionMap().put("unitScrollLeft", blankAction);
    scrollPane.getActionMap().put("unitScrollRight", blankAction);
    scrollPane.getActionMap().put("unitScrollUp", blankAction);
    JScrollBar verticalScrollBar = scrollPane.createVerticalScrollBar();
    verticalScrollBar.setUnitIncrement(HexView.CHAR_HEIGHT);
    verticalScrollBar.setBlockIncrement(HexView.CHAR_HEIGHT * 20);
    verticalScrollBar.setValues(0, 1, 0, HexView.CHAR_HEIGHT * (model.totalLine() + 1));
    scrollPane.setVerticalScrollBar(verticalScrollBar);
    return scrollPane;
}
Example 94
Project: rapidminer-studio-master  File: PerspectiveProperties.java View source code
@Override
public void run() {
    final JScrollBar vScrollBar = scrollPane.getVerticalScrollBar();
    final JScrollBar hScrollBar = scrollPane.getHorizontalScrollBar();
    /** Tries reposition scroll bars to stored positions. */
    Runnable scrollBarUpdater = new Runnable() {

        @Override
        public void run() {
            vScrollBar.setValue(scrollBarsPosition.getValue().getVertical());
            hScrollBar.setValue(scrollBarsPosition.getValue().getHorizontal());
        }
    };
    int maxIterations = POSITION_SCROLL_BARS_MAX_RETRIES;
    int i = 0;
    do {
        try {
            SwingUtilities.invokeAndWait(scrollBarUpdater);
            Thread.sleep(POSITION_SCROLL_BARS_WAIT_PERIOD);
        } catch (InterruptedExceptionInvocationTargetException |  e) {
        }
        i++;
    } while (i < maxIterations && (vScrollBar.getValue() != scrollBarsPosition.getValue().getVertical() || hScrollBar.getValue() != scrollBarsPosition.getValue().getHorizontal()));
}
Example 95
Project: spicy-master  File: MyMouseEventListener.java View source code
public void mousePressed(MouseEvent e) {
    e.consume();
    Component comS = SwingUtilities.getDeepestComponentAt(pannelloPrincipale, e.getX(), e.getY());
    if ((comS instanceof JScrollBar || !((comS instanceof JPanel) || (comS instanceof JTree))) && comS != null) {
        if (tmp12 == null) {
            tmp12 = comS;
        }
    }
    if (!(Costanti.INTERMEDIE.equals(comS.getName()))) {
        dispacciaEvento(null, e, e.getPoint(), false);
    }
    jLayeredPane.moveToFront(component);
    component.updateUI();
}
Example 96
Project: StoryBear-master  File: BookBox.java View source code
/**
	 * @author Tobias
	 */
private void initShelf() {
    buecherRegal = new JLayeredPane();
    buecherRegal.setBounds(0, 0, Ressources.WINDOW.width, Ressources.WINDOW.height);
    levelBuecher = new JList<StoryInfo>();
    JScrollPane scrollpane = new Scrollbar(Ressources.SHELFCOLOR);
    scrollpane.setViewportView(levelBuecher);
    scrollpane.getViewport().setOpaque(false);
    scrollpane.getViewport().setBackground(new Color(0, 0, 0, 0));
    scrollpane.setOpaque(false);
    scrollpane.setBackground(new Color(0, 0, 0, 0));
    scrollpane.setBorder(null);
    scrollpane.setCursor(Ressources.CURSORCLICKABLE);
    JScrollBar sb = scrollpane.getVerticalScrollBar();
    sb.setPreferredSize(new Dimension(30, 0));
    sb.setBackground(Ressources.SHELFCOLOR);
    scrollpane.setBounds((int) (96 / Ressources.SCALE), (int) (60 / Ressources.SCALE), (int) (1138 / Ressources.SCALE), (int) (959 / Ressources.SCALE));
    buecherRegal.add(scrollpane);
    levelBuecher.setCellRenderer(new BookRenderer());
    levelBuecher.setOpaque(false);
    levelBuecher.setBackground(new Color(0, 0, 0, 0));
    baseLayer.add(buecherRegal);
    loadStories();
    levelBuecher.setSelectedIndex(0);
    JLabel shelf = new JLabel();
    shelf.setIcon(new ImageIcon(imagelib.menuImage(Imagelib.MENU_SHELF)));
    shelf.setBounds(0, 0, Ressources.WINDOW.width, Ressources.WINDOW.height);
    buecherRegal.add(shelf);
    baseLayer.setVisible(true);
    baseLayer.setBounds(0, 0, Ressources.WINDOW.width, Ressources.WINDOW.height);
    add(baseLayer);
}
Example 97
Project: svarog-master  File: NewArtifactTypesPanel.java View source code
private void initialize() {
    setLayout(new BorderLayout());
    CompoundBorder border = new CompoundBorder(new TitledBorder(_("Artifact types & sensitivity")), new EmptyBorder(3, 3, 3, 3));
    setBorder(border);
    JPanel typesPanel = new JPanel();
    typesPanel.setBorder(new EmptyBorder(5, 0, 0, 0));
    GroupLayout layout = new GroupLayout(typesPanel);
    typesPanel.setLayout(layout);
    layout.setAutoCreateContainerGaps(false);
    layout.setAutoCreateGaps(true);
    GroupLayout.SequentialGroup hGroup = layout.createSequentialGroup();
    GroupLayout.SequentialGroup vGroup = layout.createSequentialGroup();
    ParallelGroup checkBoxParallelGroup = layout.createParallelGroup();
    ParallelGroup textFieldParallelGroup = layout.createParallelGroup();
    ParallelGroup scrollBarParallelGroup = layout.createParallelGroup(Alignment.TRAILING);
    JCheckBox[] checkBoxes = getArtifactTypeCheckBoxes();
    JScrollBar[] scrollBars = getSensitivityScrollBars();
    JTextField[] textFields = getSensitivityTextFields();
    for (int i = 0; i < artifactTypes.length; i++) {
        vGroup.addGroup(layout.createParallelGroup(Alignment.CENTER).addComponent(checkBoxes[i]).addComponent(textFields[i]).addComponent(scrollBars[i]));
        checkBoxParallelGroup.addComponent(checkBoxes[i]);
        textFieldParallelGroup.addComponent(textFields[i]);
        scrollBarParallelGroup.addComponent(scrollBars[i]);
        checkBoxes[i].addItemListener(new CheckBoxListener(i));
        textFields[i].addFocusListener(new TextFieldListener(i));
        scrollBars[i].addAdjustmentListener(new ScrollBarListener(i));
    }
    hGroup.addGroup(checkBoxParallelGroup);
    hGroup.addGroup(textFieldParallelGroup);
    hGroup.addGroup(scrollBarParallelGroup);
    layout.setHorizontalGroup(hGroup);
    layout.setVerticalGroup(vGroup);
    add(typesPanel, BorderLayout.CENTER);
}
Example 98
Project: Triana-master  File: WaveView.java View source code
//    public void cleanUp() {
//        super.cleanUp();
//        waveViewPanelWindow.setVisible(false);
//    }
/**
     * Captures the events thrown out by WaveViewParameters.
     */
public void actionPerformed(ActionEvent e) {
    if (e.getSource() instanceof JButton) {
        JScrollBar scrollbar = scrollerForWaveViewPanel.getHorizontalScrollBar();
        boolean scrollbarAdjust = false;
        max = scrollbar.getMaximum();
        val = scrollbar.getValue();
        Dimension d = scrollerForWaveViewPanel.getSize();
        int w = d.width - scrollerForWaveViewPanel.getInsets().left - scrollerForWaveViewPanel.getInsets().right;
        int h = d.height - scrollerForWaveViewPanel.getInsets().top - scrollerForWaveViewPanel.getInsets().bottom - scrollbar.getSize().height;
        JButton b = (JButton) e.getSource();
        if (b == waveViewToolBar.zoomIn) {
            waveViewPanel.zoomIn(w, h);
            scrollbarAdjust = true;
        } else if (b == waveViewToolBar.zoomOut) {
            waveViewPanel.zoomOut(w, h);
            scrollbarAdjust = true;
        } else if (b == waveViewToolBar.fullSize) {
            waveViewPanel.fullSize(w, h);
        } else if (b == waveViewToolBar.print) {
        } else //
        if (b == waveViewToolBar.detail) {
            waveViewPanel.detail();
            setInfo();
        } else if (b == waveViewToolBar.properties) {
        //doubleClick();
        }
        if (scrollbarAdjust) {
            scrollbar.addAdjustmentListener(this);
        }
    }
}
Example 99
Project: visualvm-master  File: SimpleXYChart.java View source code
private void enableZooming() {
    scroller = new JScrollBar(JScrollBar.HORIZONTAL);
    attachHorizontalScrollBar(scroller);
    zoomInAction = new ZoomInAction();
    zoomOutAction = new ZoomOutAction();
    toggleViewAction = new ToggleViewAction();
    listener = new VisibleBoundsListener();
    addConfigurationListener(listener);
}
Example 100
Project: whitebox-geospatial-analysis-tools-master  File: ScrollerProperty.java View source code
@Override
public final void revalidate() {
    this.removeAll();
    //this.setupFormat();
    this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
    this.setBackground(backColour);
    this.add(Box.createHorizontalStrut(leftMargin));
    JLabel label = new JLabel(labelText);
    label.setPreferredSize(new Dimension(preferredWidth, preferredHeight));
    this.add(label);
    this.add(Box.createHorizontalGlue());
    this.add(new JLabel(lowerLabel));
    this.add(Box.createHorizontalStrut(5));
    if (this.value < this.minValue) {
        this.value = this.minValue;
    }
    if (this.value > this.maxValue) {
        this.value = this.maxValue;
    }
    int intVal = (int) (this.scrollerRange * (this.value - this.minValue) / (this.maxValue - this.minValue));
    scrollBar = new JScrollBar(Adjustable.HORIZONTAL, intVal, 0, 0, this.scrollerRange);
    //formattedTextField.setMaximumSize(new Dimension(5000, 24));
    scrollBar.setMaximumSize(new Dimension(Integer.MAX_VALUE, scrollBar.getPreferredSize().height));
    scrollBar.addPropertyChangeListener("value", this);
    scrollBar.addAdjustmentListener(new AdjustmentListener() {

        @Override
        public void adjustmentValueChanged(AdjustmentEvent e) {
            double scrollerVal = minValue + ((double) scrollBar.getValue() / scrollerRange) * (maxValue - minValue);
            setValue(scrollerVal);
        }
    });
    this.add(scrollBar);
    this.add(Box.createHorizontalStrut(5));
    this.add(new JLabel(upperLabel));
    //formattedTextField.revalidate();
    this.add(Box.createHorizontalStrut(rightMargin));
    super.revalidate();
}
Example 101
Project: zaproxy-master  File: SplashScreen.java View source code
/**
     * Append a message to the output window of this splash screen
     * @param msg the message that should be appended
     */
public void appendMsg(final String msg) {
    if (!EventQueue.isDispatchThread()) {
        try {
            EventQueue.invokeAndWait(new Runnable() {

                @Override
                public void run() {
                    appendMsg(msg);
                }
            });
        } catch (InvocationTargetException e) {
            LOGGER.error("Failed to append message: ", e);
        } catch (InterruptedException ignore) {
        }
        return;
    }
    displayRandomTip();
    getLogPanel().append(msg);
    JScrollBar vertical = getLogJScrollPane().getVerticalScrollBar();
    vertical.setValue(vertical.getMaximum());
}