Quantcast
Channel: 質問!ITmedia 新着質問(Java/253)
Viewing all articles
Browse latest Browse all 2439

JAVAプログラミング

$
0
0
プログラミングについて質問があります 割り勘ソフトを作りたいのですが button1を押したときに int i = Integer.parseInt(kazu.getText()); int e = Integer.parseInt(kane.getText()); int a = e/i; String s = String.valueOf(a); this.an.setText(s); というプログラムを実行したいのですが button1のクリック処理?イベント処理?というのはどのように書けばいいのでしょうか レイアウトは完成しているので ↓に付け足すような形でお願いします プログラミングの質問をするのは初めてなので何かおかしなところや足りないところがあれば教えてください public class jFram { public static void main(String[] args) { JFrame mainFrame = new JFrame("1"); mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); mainFrame.setSize(500,500); mainFrame.setResizable(false); mainFrame.setVisible(true); Container cont = mainFrame.getContentPane(); JButton button1 = new JButton("計算"); final JTextField kane = new JTextField(); final JTextField kazu = new JTextField(); JLabel mony = new JLabel("料金"); JLabel ninz = new JLabel("人数"); JLabel an = new JLabel("a"); button1.setLayout(null); cont.add(button1); button1.setBounds(40,380,100,30); button1.setBackground(Color.blue); kane.setLayout(null); cont.add(kane); kane.setBounds(160,340,100,30); kazu.setLayout(null); cont.add(kazu); kazu.setBounds(160,300,100,30); mony.setLayout(null); cont.add(mony); mony.setBounds(40,340,100,30); ninz.setLayout(null); cont.add(ninz); ninz.setBounds(40,300,100,30); an.setLayout(null); cont.add(an); an.setBounds(160,380,100,30); cont.setLayout(null); JPanel a = new JPanel(); a.setLayout(null); mainFrame.setVisible(true); } }

Viewing all articles
Browse latest Browse all 2439

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>