Package javax.swing

Examples of javax.swing.JScrollBar


   *            a string representing the line to be printed
   * @param type
   *            The logical format type.
   */
  private void handleAddLine(final String header, final String line, final NotificationType type) {
    final JScrollBar vbar = scrollPane.getVerticalScrollBar();
    final int currentLocation = vbar.getValue();
   
    setAutoScrollEnabled((vbar.getValue() + vbar.getVisibleAmount() == vbar.getMaximum()));
    insertNewline();

    final java.text.Format formatter = new java.text.SimpleDateFormat("[HH:mm] ");
    final String dateString = formatter.format(new Date());
    insertTimestamp(dateString);

    insertHeader(header);
    insertText(line, type);
   
    // wait a bit so that the scroll bar knows where it should scroll
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        if (isAutoScrollEnabled()) {
          scrollToBottom();
        } else {
          // the scroll bar insists changing its value, so jump back.
          // in a sane toolkit it would be possible to defer drawing
          // until this
          vbar.setValue(currentLocation);
          setUnreadLinesWarning(true);
        }
      }
    });
  }
View Full Code Here


  /**
   * Sets the window to its preferred size.
   */
  public void sizeToDefault() {
    Dimension prefSize = getDefaultEditorPaneSize();
    JScrollBar vsb = editorScrollPane.getVerticalScrollBar();
    if (vsb != null)
      prefSize.setSize(prefSize.getWidth() + vsb.getPreferredSize().getWidth(), prefSize.getHeight());
    editorScrollPane.setPreferredSize(prefSize);
    int width = prefSize.width;
    this.setPreferredSize(new Dimension(width, width));
    this.setSize(this.getPreferredSize());
  }
View Full Code Here

                // lock viewports with each other...
                // remove old master listeners
                final JViewport viewport = modelChart.getViewport();
                lockChartsToOneScrollbar(viewport, isLastMaximizedChartPanelView, modelChart, masterViewPortChangeListener);

                final JScrollBar horizontalScrollBar = modelChart.getHorizontalScrollBar();
                // clean old change listeners
                ChangeListener[] changeListeners = ((DefaultBoundedRangeModel) horizontalScrollBar.getModel()).getChangeListeners();
                for (int j = 0; j < changeListeners.length; j++) {
                    if (changeListeners[j] instanceof ScrollBarMaximumChangeListener) {
                        horizontalScrollBar.getModel().removeChangeListener(changeListeners[j]);
                    }
                }
                if (isLastMaximizedChartPanelView && isWatched()) {
                    horizontalScrollBar.getModel().addChangeListener(new ScrollBarMaximumChangeListener());
                }
                if (isLastMaximizedChartPanelView) {
                    horizontalScrollBar.setEnabled(!isWatched());
                }
            }
            row++;
        }
        if (noMaximizedChartPanelView) {
View Full Code Here

        return chartPanelViews.get(i);
    }

    public void setWatched(boolean watched) {
        this.watched = watched;
        final JScrollBar horizontalScrollBar = ((ModelChartImpl) getLastMaximizedChartPanelView().getModelChart()).getHorizontalScrollBar();
        if (watched) {
            horizontalScrollBar.setValue(horizontalScrollBar.getMaximum());
        }
        horizontalScrollBar.setEnabled(!watched);
    }
View Full Code Here

            !personalJava) {
      String direction = tmp;
      if (!direction.equals("none")) {
        if (!direction.equals("East") && !direction.equals("West"))
          direction = "East";
        JScrollBar scrollBar = new JScrollBar();
        tPanel.add(direction, scrollBar);
        terminal.setScrollbar(scrollBar);
      }
    }
View Full Code Here

    return horizontalScrollBar(scrollPane);
  }

  @RunsInEDT
  private static @Nonnull JScrollBar horizontalScrollBar(final @Nonnull JScrollPane scrollPane) {
    JScrollBar result = execute(new GuiQuery<JScrollBar>() {
      @Override
      protected JScrollBar executeInEDT() {
        return scrollPane.getHorizontalScrollBar();
      }
    });
View Full Code Here

    return verticalScrollBar(scrollPane);
  }

  @RunsInEDT
  private static @Nonnull JScrollBar verticalScrollBar(final @Nonnull JScrollPane scrollPane) {
    JScrollBar result = execute(new GuiQuery<JScrollBar>() {
      @Override
      protected JScrollBar executeInEDT() {
        return scrollPane.getVerticalScrollBar();
      }
    });
View Full Code Here

    target = fixture.target();
  }

  @Test
  public void should_return_horizontal_JScrollBar_using_driver() {
    JScrollBar scrollBar = mock(JScrollBar.class);
    when(driver.horizontalScrollBarIn(target)).thenReturn(scrollBar);
    JScrollBarFixture scrollBarFixture = fixture.horizontalScrollBar();
    assertThat(scrollBarFixture.target()).isSameAs(scrollBar);
    verify(driver).horizontalScrollBarIn(target);
  }
View Full Code Here

    verify(driver).horizontalScrollBarIn(target);
  }

  @Test
  public void should_return_vertical_JScrollBar_using_driver() {
    JScrollBar scrollBar = mock(JScrollBar.class);
    when(driver.verticalScrollBarIn(target)).thenReturn(scrollBar);
    JScrollBarFixture scrollBarFixture = fixture.verticalScrollBar();
    assertThat(scrollBarFixture.target()).isSameAs(scrollBar);
    verify(driver).verticalScrollBarIn(target);
  }
View Full Code Here

    });
  }

  @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");
  }
View Full Code Here

TOP

Related Classes of javax.swing.JScrollBar

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.