Updating a JLabel in Java in c++ 2011View more random threads:
- Java Applet Won't Load In Browser 2011 Java
- what is difference between TCP/IP protocol and http...
- JAVA Error 1714. The older version of Java cannot be removed
- KeyPress Event Handlers in java
- WHAT IS PDA in java
- An unexpected error has been detected by HotSpot Virtual...
- All java error numbers # for 2011 in programming language
- Java is a beautiful language, but on web there are few web...
- Definition and introduction about java Libraries
- How to start JavaDb(Derby) server from Java application 2011
Code:import java.awt.*; import java.awt.event.*; import javax.swing.*; public class TestSwingListeners1 { public static void main(String[] args) { JFrame fr1 = new JFrame("Swing Window"); Container cp; JButton bt1; JButton bt2; int cnt1 = 0; int cnt2 = 0; String scr = null; String wnr = null; JButton btOK, btCancel; fr1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); fr1.setSize(300, 200); fr1.setResizable(false); cp = fr1.getContentPane(); cp.setLayout(new GridLayout(5,1)); btOK = new JButton("AC Milan"); btCancel = new JButton("Real Madrid"); JLabel lbl1 = new JLabel("Result: " + cnt1 + "X" + cnt2); JLabel lbl2 = new JLabel("Last Scorer: " + scr); JLabel lbl3 = new JLabel("Winner: " + wnr); cp.add(btOK); cp.add(btCancel); cp.add(lbl1); cp.add(lbl2); cp.add(lbl3); btOK.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ae) { } }); btCancel.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ae) { } }); fr1.show(); // Deprecated method! } }
Sponsored Links
There are currently 1 users browsing this thread. (0 members and 1 guests)