Code example for JScrollPane

Methods: setHorizontalScrollBarPolicysetVerticalScrollBarPolicy

0
        Container pane = getContentPane();
        pane.setLayout(new MigLayout("", "[grow]", "[][]"));
        pane.add(new JLabel(_("These tiles have been discarded during the game")), "wrap, growx, gapbottom 10");
 
        panel = new JPanel();
        scroll = new JScrollPane(panel);
        pane.add(scroll, "wrap, grow, width 400::, height 150::");
        scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
        scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
 
        panel.setLayout(new MigLayout("", "[]", ""));
        pack();
    } 
 
    public void addTile(Tile tile) {
        Image icon = client.getResourceManager().getTileImage(tile).getScaledInstance(ICON_SIZE, ICON_SIZE, Image.SCALE_FAST);
        panel.add(new JLabel(new ImageIcon(icon)), "");
        scroll.getViewport().setViewPosition(new Point(panel.getWidth(), 0));
    } 
 
Contextual code suggestions in your IDE  Get Codota for Java