Jump to content

Help adding new line in gui with flowlayout


Recommended Posts

Posted (edited)

 

https://imgur.com/bCOKWZy

I'm trying to move the "Pickaxe" JLabel and Button to a new line using only flowlayout (so no fixed x,y positions).

 

JPanel mainPanel = new JPanel();
mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.PAGE_AXIS));
mainPanel.setBorder(new EmptyBorder(23, 5, 50, 5));
mainDialog.getContentPane().add(mainPanel);

JPanel treeSelectionPanel = new JPanel();
TitledBorder leftBorder = BorderFactory.createTitledBorder("Settings");
leftBorder.setTitleJustification(TitledBorder.LEFT);
treeSelectionPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
treeSelectionPanel.setBorder(leftBorder);

JLabel treeSelectionLabel = new JLabel("Type:");
treeSelectionPanel.add(treeSelectionLabel);

treeSelector = new JComboBox<>(Tree.values());
treeSelectionPanel.add(treeSelector);

mainPanel.add(treeSelectionPanel);

JLabel pixtypetext = new JLabel("Pickaxe:");
treeSelectionPanel.add(pixtypetext);

pixselector = new JComboBox<>(pixtype.values());
treeSelectionPanel.add(pixselector);

Any help is appreciated.

Edited by the1btcuser
Forgot to add code

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...