Note that there are some explanatory texts on larger screens.

plurals
  1. POabout layouts in simple calculator
    text
    copied!<p>hi there i am trying to make a calculator with coding sizes,layouts etc. by myself (trying to not use NetBeans and it is not a homework). but i am facing with a problem about empty spaces. i have a TextArea and Buttons but as you can see below i cant handle this space problem. here is my code,</p> <pre><code>import java.awt.BorderLayout; import java.awt.Color; import java.awt.FlowLayout; import java.awt.GridLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JSeparator; import javax.swing.JTextArea; public class calculator extends JFrame { public calculator(){ initComponents(); } private void initComponents(){ JPanel panelScreen = new JPanel(new GridLayout(0,1)); JTextArea screen = new JTextArea(); panelScreen.add(screen); JFrame frame = new JFrame("CALCULATOR"); frame.setDefaultCloseOperation(EXIT_ON_CLOSE); JPanel panelButtons = new JPanel(new GridLayout(3,3)); JButton oneButton = new JButton("1"); panelButtons.add(oneButton); JButton twoButton = new JButton("2"); panelButtons.add(twoButton); JButton threeButton = new JButton("3"); panelButtons.add(threeButton); JButton fourButton = new JButton("4"); panelButtons.add(fourButton); JButton fiveButton = new JButton("5"); panelButtons.add(fiveButton); JButton sixButton = new JButton("6"); panelButtons.add(sixButton); JButton sevenButton = new JButton("7"); panelButtons.add(sevenButton); JButton eightButton = new JButton("8"); panelButtons.add(eightButton); JButton nineButton = new JButton("9"); panelButtons.add(nineButton); frame.getContentPane().add(panelScreen, BorderLayout.NORTH); //frame.getContentPane().add(new JSeparator(), BorderLayout.CENTER); frame.getContentPane().add(panelButtons, BorderLayout.SOUTH); frame.setBounds(50, 50, 500, 500); frame.setResizable(false); //frame.pack(); frame.setVisible(true); } public static void main(String[] args) { new calculator(); } } </code></pre> <p>and this the picture of programme;</p> <p><img src="https://i.stack.imgur.com/LaPzE.jpg" alt="enter image description here"></p> <p>i appreciate if you can help me. anyway thanks :)</p>
 

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