こんにちは、自分でサイズやレイアウトなどをコーディングして電卓を作ろうとしています(NetBeansを使用しようとせず、宿題ではありません)。しかし私は空きスペースに関する問題に直面しています。私はTextAreaとButtonsを持っていますが、下で見ることができるように、私はこのスペースの問題を処理できません。ここに私のコードは、単純な計算機のレイアウトについて
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();
}
}
とこれはプログラムの画像です。
あなたは私を助けることができる場合、私は感謝しています。とにかく感謝:)
素敵qeustion 1 – mKorbel
あなたはそれが、この中でどのように行われるかに見えるかもしれません[電卓コード](http://stackoverflow.com/questions/7441625/how-to-find-a -button-source-in-awt-calculator-homework/7441804#7441804)。おそらくあなたの使用に必要なものは正確ではありませんが、あなたにいくつかのアイデアを与えるかもしれません。 –
ここで、 '0'はどこですか?あなたは0ではないと考えている人々の一人ですか?私の二番目に若い妹が(概念的に)そこにいる。 –