panel doesn't want to scroll

creative cloud libraries panel stopped working
creative cloud libraries not syncing
photoshop libraries panel not showing
creative cloud panel
to use creative cloud libraries you need to be logged into a creative cloud account
to use creative cloud libraries please update the creative cloud application
due to a problem initializing cc libraries, existing links to library graphics will appear broken
adobe library

I have this piece of code (a panel that contains other JComponents, in this case JButtons) and a problem.

import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
import java.util.*;

public class JTagPanelTest extends JPanel{

    public JTagPanelTest(){
        setLayout(new FlowLayout(FlowLayout.LEADING, 2, 0));
    }

    public void initializeTags(List<String> tags){
        tags.forEach(tag -> add(new JButton(tag)));
    }

    public static void main(String[] args){
        EventQueue.invokeLater(() -> {
            try{
                String lookAndFeelName = UIManager.getSystemLookAndFeelClassName();
                UIManager.setLookAndFeel(lookAndFeelName);
            }
            catch(Exception e){
                e.printStackTrace();
            }

            JTagPanelTest test = new JTagPanelTest();
            test.initializeTags(Arrays.asList("one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten",
                "012", "qwer", "z<xc", "rty", "poiu", "gfj", "zxcv", "mjnb", "mko", "nij", "bhu"));
            JScrollPane scrollPane = new JScrollPane(test);
            scrollPane.setHorizontalScrollBar(null);
            test.setPreferredSize(new Dimension(200, 100));
//          scrollPane.setPreferredSize(new Dimension(200, 180));
            JFrame frame = new JFrame("Test");
            frame.getContentPane().add(scrollPane, BorderLayout.CENTER);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setSize(new Dimension(200, 180));
            frame.setLocationRelativeTo(null);
            frame.setResizable(false);
            frame.setVisible(true);
        });
    }

}

I though it was enough to put my JTagPanelTest inside a JScrollPane to make it scrolling but it's not so, and I really don't know why.

It was of no use calculating the final height of the internal panel, as it results 0.

Note that the number of JButtons are not fixed, so the panel has to be scrollable in order to show all the "buttons".

Is there someone who can make me aware of my mistake?

Thank you

You tried the right approach by setting preferred size on scrollPane.

So revert to that change. The reason it is not scrolling is because your content is not added to align vertically. Set a layout the helps add items vertically.

For example:

test.setLayout(new BoxLayout(test, BoxLayout.Y_AXIS));
//test.setPreferredSize(new Dimension(200, 100));
scrollPane.setPreferredSize(new Dimension(200, 180));

NVidia Control Panel doesn't start,, Posted by RegularGuy: “NVidia Control Panel doesn't start, crashes when trying to load manual” Don't perform Panel refresh more than once a year as it may affect the panel's useable life. On the supplied remote control, press the HOME button. Select Settings. The next steps will depend on your TV menu options: Select Display & Sound → Expert panel settings → Panel Refresh. Select Display → Expert panel settings → Panel Refresh.

I understand that you want the buttons to wrap, hence you add them to a JPanel that uses the FlowLayout layout manager. I also understand that you want the JPanel containing those buttons to scroll. I achieved this by setting the preferred sizes of the JScrollPane and the JPanel containing the buttons, as shown in the below code.

import java.awt.Dimension;
import java.awt.EventQueue;
import java.util.Arrays;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.WindowConstants;

public class BtnScrl implements Runnable {
    public void run() {
        showGui();
    }

    private void showGui() {
        JFrame frame = new JFrame("BtnScrl");
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.add(createButtons());
        frame.pack();
        frame.setLocationByPlatform(true);
        frame.setVisible(true);
    }

    private JScrollPane createButtons() {
        JPanel panel = new JPanel();
        panel.setPreferredSize(new Dimension(400, 290));
        for (String tag : Arrays.asList("one",
                                        "two",
                                        "three",
                                        "four",
                                        "five",
                                        "six",
                                        "seven",
                                        "eight",
                                        "nine",
                                        "ten",
                                        "012",
                                        "qwer",
                                        "z<xc",
                                        "rty",
                                        "poiu",
                                        "gfj",
                                        "zxcv",
                                        "mjnb",
                                        "mko",
                                        "nij",
                                        "bhu")) {
            panel.add(new JButton(tag));
        }
        JScrollPane scrollPane = new JScrollPane(panel);
        scrollPane.setPreferredSize(new Dimension(400, 100));
        return scrollPane;
    }

    public static void main(String[] args) {
        EventQueue.invokeLater(new BtnScrl());
    }
}

Here is a screen capture of the running app.

Customizer API and add_panel(). Panel doesn't show, You want to add_setting and add_control to your panel to work. For example: function panel($wp_customize){ $wp_customize->add_panel('some_panel',array (� If the Nvidia Control Panel doesn't seem to be running: Press the Win key and type "services.msc" to open the Services window. Sort by name and scroll down to Nvidia, then right-click and restart

I've also found this code that resolves the problem of vertical stacked components. And this one.

Intel� Graphics Control Panel Fails to Launch after Installing it, If the above method doesn't work, see the information below: Uninstall the Intel� Graphics Control Panel using Apps & Features and only use Legacy drivers� Windows XP: If you don't see a Control Panel option, your Start menu may be set to "classic" or the link may have been disabled as part of a customization. Try Start > Settings > Control Panel, or execute control from the Run box.

11 Tips For Making Sure Your Conference Panel Doesn't Suck, I asked a bunch of panel moderator pros for their advice on the topic—How they would make sure a conference panel doesn't suck. Their tips� If the above method doesn't work, see the information below: Uninstall the Intel® Graphics Control Panel using Apps & Features and only use Legacy drivers (legacy drivers already include the Intel® Graphics Control Panel) . Access to the Microsoft Store may be blocked by your network administrator.

boxsizer - Panel doesn't expand in wxPython, The line you need to modify is: sizer_h.Add(st1, 1, wx.EXPAND). Should be: sizer_h.Add(panel1, 1, wx.EXPAND). Because you need to size the panel1 and not�

Windows Control Panel doesn't have "Language" under the , Windows Control Panel doesn't have "Language" under the Clock, Region and Language Tab. Hello, Strange question, but it appears on my�

Comments
  • Note all Swing components should be created on the Event Dispatch Thread (EDT). So all the code, not just the setVisible(...) should be part of the invokeLater(...)
  • This test.setPreferredSize(new Dimension(200, 100)); artificially constrains the test JPanel's size. You most definitely do not want to do this.
  • If I remove that line the buttons does not wraps at the edge of the panel
  • thank you so much!! ... but in this manner all the buttons appears in column... is there a way to have a list of buttons that wraps at the right edge of the panel and possibly extends vertically?
  • After a few tries with your code I came to the conclusion that the scrollpane scrolls because you added the line panel.setPreferredSize(new Dimension(400, 290));, and I don't know the height of the overall panel beforehand.
  • @maurotrev You can calculate the preferred size based on the sizes of the buttons. Or you can set an arbitrary size which is what JTable does. These are not the only options available. If there are details you wish to add to your question, you can. All you need to do is edit your question. Note that I did write in my answer that I set the preferred sizes of both the JPanel and the JScrollPane.