Jump to content

Help adding new line in gui with flowlayout


the1btcuser

Recommended Posts

 

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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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