I am attempting to align JToggleButtons in a JToolBar. I want the buttons to be aligned vertically and to the left. My code is as follows:
JToolBar toolbar = new JToolBar();
toolbar.setLayout(new FlowLayout());
toolbar.setAlignmentX(FlowLayout.LEFT);
toolbar.add(new JToggleButton("Test"));
toolbar.add(new JToggleButton("Test2"));
toolbar.add(new JToggleButton("Test3"));
toolbar.add(new JToggleButton("Test with a long name"));
This is what the result looks like.
Also, when docked to the left, it looks like this. Ideally, I want the buttons to stack on each other vertically (and still remain aligned to the left). Any tips?