Search in sources :

Example 46 with JScrollBar

use of javax.swing.JScrollBar in project Payara by payara.

the class ResultsPanel method setDetailText.

public void setDetailText(String details) {
    detailText.setText(details);
    JScrollBar scrollBar = textScrollPane.getVerticalScrollBar();
    if (scrollBar != null) {
        scrollBar.setValue(0);
    }
}
Also used : JScrollBar(javax.swing.JScrollBar)

Example 47 with JScrollBar

use of javax.swing.JScrollBar in project litiengine by gurkenlabs.

the class Program method setupInterface.

private static void setupInterface() {
    MenuBar menuBar = new MenuBar();
    JFrame window = ((JFrame) Game.getScreenManager());
    Game.onTerminating(s -> {
        boolean terminate = notifyPendingChanges();
        if (terminate) {
            getUserPreferences().setFrameState(((JFrame) Game.getScreenManager()).getExtendedState());
        }
        return terminate;
    });
    window.setResizable(true);
    window.setMenuBar(menuBar);
    if (userPreferences.getWidth() != 0 && userPreferences.getHeight() != 0) {
        window.setSize(userPreferences.getWidth(), userPreferences.getHeight());
    }
    if (userPreferences.getFrameState() != JFrame.ICONIFIED && userPreferences.getFrameState() != JFrame.NORMAL) {
        window.setExtendedState(userPreferences.getFrameState());
    }
    Canvas canvas = Game.getScreenManager().getRenderComponent();
    canvas.setFocusable(true);
    canvas.setSize((int) (window.getSize().width * 0.75), window.getSize().height);
    window.remove(canvas);
    JPanel renderPane = new JPanel(new BorderLayout());
    renderPane.add(canvas);
    renderPane.setMinimumSize(new Dimension(300, 0));
    initCanvasPopupMenu(canvas);
    JPanel contentPane = new JPanel(new BorderLayout());
    window.setContentPane(contentPane);
    horizontalScroll = new JScrollBar(JScrollBar.HORIZONTAL);
    renderPane.add(horizontalScroll, BorderLayout.SOUTH);
    verticalScroll = new JScrollBar(JScrollBar.VERTICAL);
    renderPane.add(verticalScroll, BorderLayout.EAST);
    horizontalScroll.addAdjustmentListener(e -> {
        if (EditorScreen.instance().getMapComponent().isLoading()) {
            return;
        }
        Point2D newFocus = new Point2D.Double(horizontalScroll.getValue(), Game.getCamera().getFocus().getY());
        Game.getCamera().setFocus(newFocus);
    });
    verticalScroll.addAdjustmentListener(e -> {
        if (EditorScreen.instance().getMapComponent().isLoading()) {
            return;
        }
        Point2D newFocus = new Point2D.Double(Game.getCamera().getFocus().getX(), verticalScroll.getValue());
        Game.getCamera().setFocus(newFocus);
    });
    MapObjectPanel mapEditorPanel = new MapObjectPanel();
    MapSelectionPanel mapSelectionPanel = new MapSelectionPanel();
    JSplitPane mapWrap = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    mapWrap.setMinimumSize(new Dimension(300, 0));
    mapWrap.setBottomComponent(mapEditorPanel);
    mapWrap.setTopComponent(mapSelectionPanel);
    mapWrap.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, evt -> userPreferences.setSelectionEditSplitter(mapWrap.getDividerLocation()));
    if (userPreferences.getSelectionEditSplitter() != 0) {
        mapWrap.setDividerLocation(userPreferences.getSelectionEditSplitter());
    }
    JPanel bottomPanel = new JPanel(new BorderLayout());
    JTabbedPane bottomTab = new JTabbedPane();
    bottomTab.addTab(Resources.get("assettree_assets"), initAssetsComponent());
    bottomTab.addTab("Console", initConsole());
    bottomTab.setIconAt(0, new ImageIcon(Resources.getImage("asset.png")));
    bottomTab.setIconAt(1, new ImageIcon(Resources.getImage("console.png")));
    bottomPanel.add(bottomTab, BorderLayout.CENTER);
    statusBar = new JLabel("");
    statusBar.setPreferredSize(new Dimension(0, 16));
    statusBar.setFont(new Font(ConsoleLogHandler.CONSOLE_FONT, Font.PLAIN, 10));
    bottomPanel.add(statusBar, BorderLayout.SOUTH);
    EditorScreen.instance().getMapComponent().onSelectionChanged(selection -> {
        if (selection.isEmpty()) {
            statusBar.setText("");
        } else {
            statusBar.setText(" " + selection.size() + " selected objects");
        }
    });
    JSplitPane rendersplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, renderPane, bottomPanel);
    if (userPreferences.getBottomSplitter() != 0) {
        rendersplit.setDividerLocation(userPreferences.getBottomSplitter());
    } else {
        rendersplit.setDividerLocation((int) (window.getSize().height * 0.75));
    }
    rendersplit.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, evt -> userPreferences.setBottomSplitter(rendersplit.getDividerLocation()));
    rendersplit.setContinuousLayout(true);
    JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, rendersplit, mapWrap);
    split.setContinuousLayout(true);
    split.addComponentListener(new ComponentAdapter() {

        @Override
        public void componentResized(ComponentEvent e) {
            userPreferences.setWidth(window.getWidth());
            userPreferences.setHeight(window.getHeight());
        }
    });
    split.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, evt -> userPreferences.setMainSplitter(split.getDividerLocation()));
    contentPane.add(split, BorderLayout.CENTER);
    split.setDividerLocation(userPreferences.getMainSplitterPosition() != 0 ? userPreferences.getMainSplitterPosition() : (int) (window.getSize().width * 0.75));
    JToolBar toolbar = initToolBar();
    contentPane.add(toolbar, BorderLayout.NORTH);
    EditorScreen.instance().setMapEditorPanel(mapEditorPanel);
    EditorScreen.instance().setMapSelectionPanel(mapSelectionPanel);
    Menu mnFile = initFileMenu();
    menuBar.add(mnFile);
    Menu mnView = initViewMenu();
    menuBar.add(mnView);
    Menu mnProject = initProjectMenu();
    menuBar.add(mnProject);
    Menu mnMap = initMapMenu();
    menuBar.add(mnMap);
}
Also used : JPanel(javax.swing.JPanel) ImageIcon(javax.swing.ImageIcon) Canvas(java.awt.Canvas) JTabbedPane(javax.swing.JTabbedPane) MenuBar(java.awt.MenuBar) MapObjectPanel(de.gurkenlabs.utiliti.swing.panels.MapObjectPanel) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) JToolBar(javax.swing.JToolBar) Font(java.awt.Font) JScrollBar(javax.swing.JScrollBar) BorderLayout(java.awt.BorderLayout) JFrame(javax.swing.JFrame) Point2D(java.awt.geom.Point2D) ComponentEvent(java.awt.event.ComponentEvent) PopupMenu(java.awt.PopupMenu) Menu(java.awt.Menu) JPopupMenu(javax.swing.JPopupMenu) JSplitPane(javax.swing.JSplitPane) ComponentAdapter(java.awt.event.ComponentAdapter)

Example 48 with JScrollBar

use of javax.swing.JScrollBar in project OsmAnd-tools by osmandapp.

the class JScrollPopupMenu method show.

public void show(Component invoker, int x, int y) {
    JScrollBar scrollBar = getScrollBar();
    if (scrollBar.isVisible()) {
        int extent = 0;
        int max = 0;
        int i = 0;
        int unit = -1;
        int width = 0;
        for (Component comp : getComponents()) {
            if (!(comp instanceof JScrollBar)) {
                Dimension preferredSize = comp.getPreferredSize();
                width = Math.max(width, preferredSize.width);
                if (unit < 0) {
                    unit = preferredSize.height;
                }
                if (i++ < maximumVisibleRows) {
                    extent += preferredSize.height;
                }
                max += preferredSize.height;
            }
        }
        Insets insets = getInsets();
        int widthMargin = insets.left + insets.right;
        int heightMargin = insets.top + insets.bottom;
        scrollBar.setUnitIncrement(unit);
        scrollBar.setBlockIncrement(extent);
        scrollBar.setValues(0, heightMargin + extent, 0, heightMargin + max);
        width += scrollBar.getPreferredSize().width + widthMargin;
        int height = heightMargin + extent;
        scrollBar.setSize(new Dimension(width, height));
        setPopupSize(new Dimension(width, height));
    }
    super.show(invoker, x, y);
}
Also used : Insets(java.awt.Insets) Dimension(java.awt.Dimension) Component(java.awt.Component) JScrollBar(javax.swing.JScrollBar)

Example 49 with JScrollBar

use of javax.swing.JScrollBar in project OsmAnd-tools by osmandapp.

the class JScrollPopupMenu method getScrollBar.

protected JScrollBar getScrollBar() {
    if (popupScrollBar == null) {
        popupScrollBar = new JScrollBar(JScrollBar.VERTICAL);
        popupScrollBar.addAdjustmentListener(new AdjustmentListener() {

            @Override
            public void adjustmentValueChanged(AdjustmentEvent e) {
                doLayout();
                repaint();
            }
        });
        popupScrollBar.setVisible(true);
    }
    return popupScrollBar;
}
Also used : AdjustmentEvent(java.awt.event.AdjustmentEvent) AdjustmentListener(java.awt.event.AdjustmentListener) JScrollBar(javax.swing.JScrollBar)

Example 50 with JScrollBar

use of javax.swing.JScrollBar in project freeplane by freeplane.

the class GlassPaneNodeSelector method findMapComponent.

// 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);
}
Also used : Container(java.awt.Container) MainView(org.freeplane.view.swing.map.MainView) MapView(org.freeplane.view.swing.map.MapView) Point(java.awt.Point) Component(java.awt.Component) JScrollBar(javax.swing.JScrollBar)

Aggregations

JScrollBar (javax.swing.JScrollBar)60 Dimension (java.awt.Dimension)12 Point (java.awt.Point)12 JScrollPane (javax.swing.JScrollPane)10 JLabel (javax.swing.JLabel)7 JPanel (javax.swing.JPanel)6 Component (java.awt.Component)5 JTabbedPane (javax.swing.JTabbedPane)5 JTextArea (javax.swing.JTextArea)5 GridBagConstraints (java.awt.GridBagConstraints)4 Insets (java.awt.Insets)4 ActionEvent (java.awt.event.ActionEvent)4 JPopupMenu (javax.swing.JPopupMenu)4 JViewport (javax.swing.JViewport)4 Color (java.awt.Color)3 GridBagLayout (java.awt.GridBagLayout)3 ActionListener (java.awt.event.ActionListener)3 AdjustmentEvent (java.awt.event.AdjustmentEvent)3 AdjustmentListener (java.awt.event.AdjustmentListener)3 IOException (java.io.IOException)3