As exercise, I am trying to make an application to make a quiz but I can't figure out how to make a layout similar to this:
JOptionPane.showConfirmDialog(panel,"How to make this layout?","QUIZ FRAME",JOptionPane.YES_NO_CANCEL_OPTION);
In particular I can't find a way to insert the question in the first line and all the remainig buttons to a different line (or multiple lines if long answers). I tried with every possible layout manager but I either get one object per line (GridLayout) or everything in one line like in FlowLayout.
I figure it out how to use ActionEvent to slide to the next panel (question) if I click on a button (answer) and everything else but not this simple layout I am looking for. Any advice?
EDIT: my intention was to make the same layout but without using JOptionPane. I managed to do something similar from scratch with multiple panels and nested layouts. I am just a beginner so I am sure there must be some other better way to do it.
public static void main(String[] args) {
JFrame frame = new JFrame("QUIZ FRAME");
JPanel panel = new JPanel();
JPanel panel2 = new JPanel();
JPanel panel3 = new JPanel();
JLabel question1 = new JLabel("QUESTION 1");
JLabel questiontext = new JLabel(" TEXT FOR QUESTION NUMBER 1 ");
JButton answer = new JButton("Answer");
JButton answer2 = new JButton("Answer2");
JButton answer3 = new JButton("Answer3");
answer.setSize(50,50);
answer2.setSize(50,50);
answer3.setSize(50,50);
BorderLayout framelayout = new BorderLayout();
BorderLayout panellayout = new BorderLayout();
BorderLayout panellayout2 = new BorderLayout();
GridLayout panellayout3 = new GridLayout(1,3,30,30);
frame.setLayout(framelayout);
panel.setLayout(panellayout);
panel2.setLayout(panellayout2);
panel3.setLayout(panellayout3);
panel.setBackground(Color.BLUE);
panel2.setBackground(Color.RED);
panel.setPreferredSize(new Dimension( 500,30));
panel2.setPreferredSize(new Dimension(500,50));
frame.add(panel, framelayout.NORTH);
frame.add(panel2,framelayout.CENTER);
frame.add(panel3,framelayout.SOUTH);
question1.setHorizontalAlignment(0);
question1.setVerticalAlignment(0);
panel.add(question1);
panel2.add(questiontext, panellayout2.WEST);
panel3.add(answer);
panel3.add(answer2);
panel3.add(answer3);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}