Note that there are some explanatory texts on larger screens.

plurals
  1. PONeeds ideas on how to insert a small text phrase above a panel
    primarykey
    data
    text
    <p>I am trying to insert the "Puzzle Game" text circled in red in the attached image.</p> <p>I have already placed the 4 blue buttons and the textfields all in 1 GridLayout.</p> <p>I tried inserting the text together with the GridLayout as a non-clickable button, but it didn't work as the sizes per cell in GridLayout is the same throughout.</p> <p>Trying to use setBounds as well, but it doesn't even show up in the JFrame =/ . </p> <p><img src="https://i.stack.imgur.com/B2d3S.png" alt="image"></p> <pre><code> // create a new panel - panel1 JPanel panel1 = new JPanel(); // set layout of panel1 panel1.setLayout(new GridLayout(3,2)); panel1.setPreferredSize(new Dimension(500,200)); // create new buttons - button1 to button4 JButton button1 = new JButton("Start Game"); JButton button2 = new JButton("Get History"); JButton button3 = new JButton("Reset Game"); JButton button4 = new JButton("Exit Game"); // create label and text field for entering of player's names JLabel label1 = new JLabel("Enter Player's name:",JLabel.CENTER); JTextField field1 = new JTextField(); // add the labels and text field to panel1 panel1.add(label1); panel1.add(field1); // adds button1 to button4 to panel1 panel1.add(button1); panel1.add(button2); panel1.add(button3); panel1.add(button4); // create a new general panel to contain all panels containing components placed at the bottom JPanel btmGenP = new JPanel(); this.add(btmGenP,BorderLayout.SOUTH); btmGenP.add(panel1,FlowLayout.LEFT); // create a new panel - panel2 JPanel panel2 = new JPanel(); panel2.setLayout(null); panel2.setBounds(50,50,50,50); this.add(panel2); // add Jlabel text to panel2 JLabel puzgame = new JLabel("~~Puzzle Game~~"); panel2.add(puzgame); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload