承漢JAVA 程式設計
通訊四乙 林承漢 D018869
2015年4月28日 星期二
4.27 智慧推盤4X4
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Calculator extends JFrame implements ActionListener{
public static void main(String[]args){
new Calculator();
}
public Calculator()
{
String s;
JFrame window=new JFrame("Calculator");
window.setDefaultLookAndFeelDecorated(true);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setLayout(new GridLayout(4,4));
JPanel jplPanel = new JPanel();
jplPanel.setLayout(new GridLayout(4,4));
JButton button[]=new JButton[17];
s=String.valueOf(1);
for (int i = 1; i <= 16; i++)
{
button[i] = new JButton();
button[i].setSize(50,50);
button[i].setText(Integer.toString(i));
button[i].setActionCommand("此按鈕為:"+i);
button[i].addActionListener(this);
jplPanel.add(button[i]);
}
window.getContentPane().add(jplPanel, BorderLayout.CENTER);
window.setSize(500,500);
window.setVisible(true);
}
public void actionPerformed(ActionEvent e ) {
String cmd = e.getActionCommand();
System.out.println(cmd);
}}
import java.awt.event.*;
import javax.swing.*;
public class Calculator extends JFrame implements ActionListener{
public static void main(String[]args){
new Calculator();
}
public Calculator()
{
String s;
JFrame window=new JFrame("Calculator");
window.setDefaultLookAndFeelDecorated(true);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setLayout(new GridLayout(4,4));
JPanel jplPanel = new JPanel();
jplPanel.setLayout(new GridLayout(4,4));
JButton button[]=new JButton[17];
s=String.valueOf(1);
for (int i = 1; i <= 16; i++)
{
button[i] = new JButton();
button[i].setSize(50,50);
button[i].setText(Integer.toString(i));
button[i].setActionCommand("此按鈕為:"+i);
button[i].addActionListener(this);
jplPanel.add(button[i]);
}
window.getContentPane().add(jplPanel, BorderLayout.CENTER);
window.setSize(500,500);
window.setVisible(true);
}
public void actionPerformed(ActionEvent e ) {
String cmd = e.getActionCommand();
System.out.println(cmd);
}}
4.17 智慧推盤3X3
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class mathew extends JFrame implements ActionListener{
public static void main(String[]args){
new mathew ();
}
public mathew ()
{
String s;
JFrame window=new JFrame("Calculator");
window.setDefaultLookAndFeelDecorated(true);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setLayout(new GridLayout(3,3));
JPanel jplPanel = new JPanel();
jplPanel.setLayout(new GridLayout(3,3));
JButton button[]=new JButton[10];
//s=Integer.toString(1);
s=String.valueOf(1);
//System.out.println(s);
//s="1";
for (int i = 1; i <= 9; i++)
{
button[i] = new JButton();
button[i].setActionCommand("此按鈕為:"+i);
button[i].addActionListener(this);
button[i].setSize(50,50);
button[i].setText(Integer.toString(i));
jplPanel.add(button[i]);
}
window.getContentPane().add(jplPanel, BorderLayout.CENTER);
window.setSize(500,500);
window.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
String cmd = e.getActionCommand();
System.out.println(cmd); }
}
import java.awt.event.*;
import javax.swing.*;
public class mathew extends JFrame implements ActionListener{
public static void main(String[]args){
new mathew ();
}
public mathew ()
{
String s;
JFrame window=new JFrame("Calculator");
window.setDefaultLookAndFeelDecorated(true);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setLayout(new GridLayout(3,3));
JPanel jplPanel = new JPanel();
jplPanel.setLayout(new GridLayout(3,3));
JButton button[]=new JButton[10];
//s=Integer.toString(1);
s=String.valueOf(1);
//System.out.println(s);
//s="1";
for (int i = 1; i <= 9; i++)
{
button[i] = new JButton();
button[i].setActionCommand("此按鈕為:"+i);
button[i].addActionListener(this);
button[i].setSize(50,50);
button[i].setText(Integer.toString(i));
jplPanel.add(button[i]);
}
window.getContentPane().add(jplPanel, BorderLayout.CENTER);
window.setSize(500,500);
window.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
String cmd = e.getActionCommand();
System.out.println(cmd); }
}
2015年4月24日 星期五
2015年4月11日 星期六
4.10 9 Button 按出數字
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class Test
{
public static void main(String[] args)
{
JFrame jtfMainFrame = new JFrame("Which Button Demo");
jtfMainFrame.setSize(450, 150);
JButton jbnButton1 = new JButton("Button 1");
JButton jbnButton2 = new JButton("Button 2");
JButton jbnButton3 = new JButton("Button 3");
JButton jbnButton4 = new JButton("Button 4");
JButton jbnButton5 = new JButton("Button 5");
JButton jbnButton6 = new JButton("Button 6");
JButton jbnButton7 = new JButton("Button 7");
JButton jbnButton8 = new JButton("Button 8");
JButton jbnButton9 = new JButton("Button 9");
jbnButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("1");
}
});
jbnButton2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("2");
}
});
jbnButton3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("3");
}
});
jbnButton4.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("4");
}
});
jbnButton5.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("5");
}
});
jbnButton6.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("6");
}
});
jbnButton7.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("7");
}
});
jbnButton8.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("8");
}
});
jbnButton9.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("9");
}
});
JPanel jplPanel = new JPanel();
jplPanel.add(jbnButton1);
jplPanel.add(jbnButton2);
jplPanel.add(jbnButton3);
jplPanel.add(jbnButton4);
jplPanel.add(jbnButton5);
jplPanel.add(jbnButton6);
jplPanel.add(jbnButton7);
jplPanel.add(jbnButton8);
jplPanel.add(jbnButton9);
jtfMainFrame.getContentPane().add(jplPanel, BorderLayout.CENTER);
jtfMainFrame.setVisible(true);
System.out.println("chih-yu hsu");
}
}
import java.awt.event.*;
import javax.swing.*;
class Test
{
public static void main(String[] args)
{
JFrame jtfMainFrame = new JFrame("Which Button Demo");
jtfMainFrame.setSize(450, 150);
JButton jbnButton1 = new JButton("Button 1");
JButton jbnButton2 = new JButton("Button 2");
JButton jbnButton3 = new JButton("Button 3");
JButton jbnButton4 = new JButton("Button 4");
JButton jbnButton5 = new JButton("Button 5");
JButton jbnButton6 = new JButton("Button 6");
JButton jbnButton7 = new JButton("Button 7");
JButton jbnButton8 = new JButton("Button 8");
JButton jbnButton9 = new JButton("Button 9");
jbnButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("1");
}
});
jbnButton2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("2");
}
});
jbnButton3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("3");
}
});
jbnButton4.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("4");
}
});
jbnButton5.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("5");
}
});
jbnButton6.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("6");
}
});
jbnButton7.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("7");
}
});
jbnButton8.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("8");
}
});
jbnButton9.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("9");
}
});
JPanel jplPanel = new JPanel();
jplPanel.add(jbnButton1);
jplPanel.add(jbnButton2);
jplPanel.add(jbnButton3);
jplPanel.add(jbnButton4);
jplPanel.add(jbnButton5);
jplPanel.add(jbnButton6);
jplPanel.add(jbnButton7);
jplPanel.add(jbnButton8);
jplPanel.add(jbnButton9);
jtfMainFrame.getContentPane().add(jplPanel, BorderLayout.CENTER);
jtfMainFrame.setVisible(true);
System.out.println("chih-yu hsu");
}
}
4.10- 9 Button
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class Test
{
public static void main(String[] args)
{
JFrame jtfMainFrame = new JFrame("Which Button Demo");
jtfMainFrame.setSize(450, 150);
JButton jbnButton1 = new JButton("Button 1");
JButton jbnButton2 = new JButton("Button 2");
JButton jbnButton3 = new JButton("Button 3");
JButton jbnButton4 = new JButton("Button 4");
JButton jbnButton5 = new JButton("Button 5");
JButton jbnButton6 = new JButton("Button 6");
JButton jbnButton7 = new JButton("Button 7");
JButton jbnButton8 = new JButton("Button 8");
JButton jbnButton9 = new JButton("Button 9");
JPanel jplPanel = new JPanel();
jplPanel.add(jbnButton1);
jplPanel.add(jbnButton2);
jplPanel.add(jbnButton3);
jplPanel.add(jbnButton4);
jplPanel.add(jbnButton5);
jplPanel.add(jbnButton6);
jplPanel.add(jbnButton7);
jplPanel.add(jbnButton8);
jplPanel.add(jbnButton9);
jtfMainFrame.getContentPane().add(jplPanel, BorderLayout.CENTER);
jtfMainFrame.setVisible(true);
System.out.print("chih-yu hsu");
}
}
import java.awt.event.*;
import javax.swing.*;
class Test
{
public static void main(String[] args)
{
JFrame jtfMainFrame = new JFrame("Which Button Demo");
jtfMainFrame.setSize(450, 150);
JButton jbnButton1 = new JButton("Button 1");
JButton jbnButton2 = new JButton("Button 2");
JButton jbnButton3 = new JButton("Button 3");
JButton jbnButton4 = new JButton("Button 4");
JButton jbnButton5 = new JButton("Button 5");
JButton jbnButton6 = new JButton("Button 6");
JButton jbnButton7 = new JButton("Button 7");
JButton jbnButton8 = new JButton("Button 8");
JButton jbnButton9 = new JButton("Button 9");
JPanel jplPanel = new JPanel();
jplPanel.add(jbnButton1);
jplPanel.add(jbnButton2);
jplPanel.add(jbnButton3);
jplPanel.add(jbnButton4);
jplPanel.add(jbnButton5);
jplPanel.add(jbnButton6);
jplPanel.add(jbnButton7);
jplPanel.add(jbnButton8);
jplPanel.add(jbnButton9);
jtfMainFrame.getContentPane().add(jplPanel, BorderLayout.CENTER);
jtfMainFrame.setVisible(true);
System.out.print("chih-yu hsu");
}
}
2015年3月31日 星期二
Button
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class mathew
{
public static void main(String[]args)
{
JFrame jtfMainFrame = new JFrame("Which Button Demo");
jtfMainFrame.setSize(450, 150);
JButton jbnButton1 = new JButton("Button 1");
JButton jbnButton2 = new JButton("Button 2");
JTextField jtfInput = new JTextField(20);
JPanel jplPanel = new JPanel();
jplPanel.add(jtfInput);
jplPanel.add(jbnButton1);
jplPanel.add(jbnButton2);
jtfMainFrame.getContentPane().add(jplPanel, BorderLayout.CENTER);
jtfMainFrame.setVisible(true);
System.out.print("林承漢");
}
}
import java.awt.event.*;
import javax.swing.*;
class mathew
{
public static void main(String[]args)
{
JFrame jtfMainFrame = new JFrame("Which Button Demo");
jtfMainFrame.setSize(450, 150);
JButton jbnButton1 = new JButton("Button 1");
JButton jbnButton2 = new JButton("Button 2");
JTextField jtfInput = new JTextField(20);
JPanel jplPanel = new JPanel();
jplPanel.add(jtfInput);
jplPanel.add(jbnButton1);
jplPanel.add(jbnButton2);
jtfMainFrame.getContentPane().add(jplPanel, BorderLayout.CENTER);
jtfMainFrame.setVisible(true);
System.out.print("林承漢");
}
}
訂閱:
文章 (Atom)