2019年1月10日 星期四
2015年11月5日 星期四
C# 計算機加減乘除
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
string b1;
string b2;
b1 = textBox1.Text;
float a1 = float.Parse(b1);
b2 = textBox2.Text;
float a2 = float.Parse(b2);
float c1 = a1 + a2;
label2.Text = c1.ToString();
}
private void label2_Click(object sender, EventArgs e)
{
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
string b1;
string b2;
b1 = textBox1.Text;
float a1 = float.Parse(b1);
b2 = textBox2.Text;
float a2 = float.Parse(b2);
float c1 = a1 - a2;
label2.Text = c1.ToString();
}
private void label3_Click(object sender, EventArgs e)
{
}
private void button3_Click(object sender, EventArgs e)
{
string b1;
string b2;
b1 = textBox1.Text;
float a1 = float.Parse(b1);
b2 = textBox2.Text;
float a2 = float.Parse(b2);
float c1 = a1 * a2;
label2.Text = c1.ToString();
}
private void button4_Click(object sender, EventArgs e)
{
string b1;
string b2;
b1 = textBox1.Text;
float a1 = float.Parse(b1);
b2 = textBox2.Text;
float a2 = float.Parse(b2);
float c1 = a1 / a2;
label2.Text = c1.ToString();
if(a2==0)
label2.Text="分母不能為0";
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
string b1;
string b2;
b1 = textBox1.Text;
float a1 = float.Parse(b1);
b2 = textBox2.Text;
float a2 = float.Parse(b2);
float c1 = a1 + a2;
label2.Text = c1.ToString();
}
private void label2_Click(object sender, EventArgs e)
{
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
string b1;
string b2;
b1 = textBox1.Text;
float a1 = float.Parse(b1);
b2 = textBox2.Text;
float a2 = float.Parse(b2);
float c1 = a1 - a2;
label2.Text = c1.ToString();
}
private void label3_Click(object sender, EventArgs e)
{
}
private void button3_Click(object sender, EventArgs e)
{
string b1;
string b2;
b1 = textBox1.Text;
float a1 = float.Parse(b1);
b2 = textBox2.Text;
float a2 = float.Parse(b2);
float c1 = a1 * a2;
label2.Text = c1.ToString();
}
private void button4_Click(object sender, EventArgs e)
{
string b1;
string b2;
b1 = textBox1.Text;
float a1 = float.Parse(b1);
b2 = textBox2.Text;
float a2 = float.Parse(b2);
float c1 = a1 / a2;
label2.Text = c1.ToString();
if(a2==0)
label2.Text="分母不能為0";
}
}
}
2015年10月30日 星期五
C# 4*4 按按鈕出現數字不重複
em;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
Button[,] Buttons = new System.Windows.Forms.Button[5, 5];
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
for (int i = 1; i < 5; i++)
{
for (int j = 1; j < 5; j++)
{
Buttons[i, j] = new Button();
Buttons[i, j].Size = new Size(50, 50);
Buttons[i, j].Location = new Point(i * 50, j * 50);
this.Controls.Add(Buttons[i, j]);//出現在畫面中
}
}
}
private void button1_Click(object sender, EventArgs e)
{
int pro=0;
for ( int i = 1; i < 5; i++)
{
for (int j = 1; j < 5; j++)
{
pro = pro+1;
Buttons[i, j].Text = pro.ToString();
}
}
}
private void pictureBox2_Click(object sender, EventArgs e)
{
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
Button[,] Buttons = new System.Windows.Forms.Button[5, 5];
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
for (int i = 1; i < 5; i++)
{
for (int j = 1; j < 5; j++)
{
Buttons[i, j] = new Button();
Buttons[i, j].Size = new Size(50, 50);
Buttons[i, j].Location = new Point(i * 50, j * 50);
this.Controls.Add(Buttons[i, j]);//出現在畫面中
}
}
}
private void button1_Click(object sender, EventArgs e)
{
int pro=0;
for ( int i = 1; i < 5; i++)
{
for (int j = 1; j < 5; j++)
{
pro = pro+1;
Buttons[i, j].Text = pro.ToString();
}
}
}
private void pictureBox2_Click(object sender, EventArgs e)
{
}
}
}
2015年10月23日 星期五
c# 9宮格亂數3格不重複
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
int rndmoney1 = 100;
int rndmoney2 = 100;
int rndmoney3 = 100;
//int rndmoney4 = 100;
// int rndmoney5 = 100;
// int rndmoney6 = 100;
// int rndmoney7 = 100;
// int rndmoney8 = 100;
// int rndmoney9 = 100;
public Form1()
{
InitializeComponent();
}
private void button10_Click(object sender, EventArgs e)
{
}
private void button10_Click_1(object sender, EventArgs e)
{
button10.Enabled = true;
Random rnd = new Random();
button1.Enabled = false;
button2.Enabled = false;
button3.Enabled = false;
button4.Enabled = false;
button5.Enabled = false;
button6.Enabled = false;
button7.Enabled = false;
button8.Enabled = false;
button9.Enabled = false;
rndmoney1 = rnd.Next(0, 9);
rndmoney2 = rnd.Next(0, 9);
if((rndmoney1 == rndmoney2))
{
//MessageBox.Show("數字重複");
rndmoney2 = rnd.Next(0, 9);
button2.Text = rndmoney2.ToString();
}
rndmoney3 = rnd.Next(0, 9);
do
{
// MessageBox.Show("數字重複");
rndmoney3 = rnd.Next(0, 9);
button3.Text = rndmoney3.ToString();
} while ((rndmoney1 == rndmoney3) || (rndmoney2 == rndmoney3));
//rndmoney4 = rnd.Next(0, 9);
//rndmoney5 = rnd.Next(0, 9);
//rndmoney6 = rnd.Next(0, 9);
//rndmoney7 = rnd.Next(0, 9);
//rndmoney8 = rnd.Next(0, 9);
//rndmoney9 = rnd.Next(0, 9);
button1.Text = rndmoney1.ToString();
button2.Text = rndmoney2.ToString();
button3.Text = rndmoney3.ToString();
//button4.Text = rndmoney4.ToString();
//button5.Text = rndmoney5.ToString();
//button6.Text = rndmoney6.ToString();
//button7.Text = rndmoney7.ToString();
//button8.Text = rndmoney8.ToString();
//button9.Text = rndmoney9.ToString();
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
int rndmoney1 = 100;
int rndmoney2 = 100;
int rndmoney3 = 100;
//int rndmoney4 = 100;
// int rndmoney5 = 100;
// int rndmoney6 = 100;
// int rndmoney7 = 100;
// int rndmoney8 = 100;
// int rndmoney9 = 100;
public Form1()
{
InitializeComponent();
}
private void button10_Click(object sender, EventArgs e)
{
}
private void button10_Click_1(object sender, EventArgs e)
{
button10.Enabled = true;
Random rnd = new Random();
button1.Enabled = false;
button2.Enabled = false;
button3.Enabled = false;
button4.Enabled = false;
button5.Enabled = false;
button6.Enabled = false;
button7.Enabled = false;
button8.Enabled = false;
button9.Enabled = false;
rndmoney1 = rnd.Next(0, 9);
rndmoney2 = rnd.Next(0, 9);
if((rndmoney1 == rndmoney2))
{
//MessageBox.Show("數字重複");
rndmoney2 = rnd.Next(0, 9);
button2.Text = rndmoney2.ToString();
}
rndmoney3 = rnd.Next(0, 9);
do
{
// MessageBox.Show("數字重複");
rndmoney3 = rnd.Next(0, 9);
button3.Text = rndmoney3.ToString();
} while ((rndmoney1 == rndmoney3) || (rndmoney2 == rndmoney3));
//rndmoney4 = rnd.Next(0, 9);
//rndmoney5 = rnd.Next(0, 9);
//rndmoney6 = rnd.Next(0, 9);
//rndmoney7 = rnd.Next(0, 9);
//rndmoney8 = rnd.Next(0, 9);
//rndmoney9 = rnd.Next(0, 9);
button1.Text = rndmoney1.ToString();
button2.Text = rndmoney2.ToString();
button3.Text = rndmoney3.ToString();
//button4.Text = rndmoney4.ToString();
//button5.Text = rndmoney5.ToString();
//button6.Text = rndmoney6.ToString();
//button7.Text = rndmoney7.ToString();
//button8.Text = rndmoney8.ToString();
//button9.Text = rndmoney9.ToString();
}
}
}
2015年5月8日 星期五
4x4 按鈕出現亂數
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);
JPanel jplPanel = new JPanel();
int i;
int j=1;
int num1 , num2;
JButton jbnButton[] = new JButton[16];
JButton changeButton[] = new JButton[2];
jplPanel.setLayout (new GridLayout(4, 4));
for(i = 0;i<=15;i++){
jbnButton[i]=new JButton((int)(Math.random()*16+1) + " ");
jplPanel.add(jbnButton[i]);
String s = Integer.toString(i+1);
jbnButton[i].addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
/*if(j<2){
changeButton[j] = jbnButton[i];
num1 = i;
j++;
}
else if(j==2){
changeButton[j]=jbnButton[i];
jbnButton[num1] = changeButton[j];
jbnButton[i] = changeButton[j-1];
j=1;
}*/
//j++;
//JButton btn = (JButton[i])e.getSourec();
//lab.setText(btn.getLabel+".");
System.out.print((int)(Math.random()*16+1) + " ");
}
});
}
jtfMainFrame.getContentPane().add(jplPanel, BorderLayout.CENTER);
jtfMainFrame.setVisible(true);
System.out.print("盧楷中\n");
}
}
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);
JPanel jplPanel = new JPanel();
int i;
int j=1;
int num1 , num2;
JButton jbnButton[] = new JButton[16];
JButton changeButton[] = new JButton[2];
jplPanel.setLayout (new GridLayout(4, 4));
for(i = 0;i<=15;i++){
jbnButton[i]=new JButton((int)(Math.random()*16+1) + " ");
jplPanel.add(jbnButton[i]);
String s = Integer.toString(i+1);
jbnButton[i].addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
/*if(j<2){
changeButton[j] = jbnButton[i];
num1 = i;
j++;
}
else if(j==2){
changeButton[j]=jbnButton[i];
jbnButton[num1] = changeButton[j];
jbnButton[i] = changeButton[j-1];
j=1;
}*/
//j++;
//JButton btn = (JButton[i])e.getSourec();
//lab.setText(btn.getLabel+".");
System.out.print((int)(Math.random()*16+1) + " ");
}
});
}
jtfMainFrame.getContentPane().add(jplPanel, BorderLayout.CENTER);
jtfMainFrame.setVisible(true);
System.out.print("盧楷中\n");
}
}
2015年4月24日 星期五
4乘4按鈕
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);
JPanel jplPanel = new JPanel();
int i;
int j=1;
int num1 , num2;
JButton jbnButton[] = new JButton[16];
JButton changeButton[] = new JButton[2];
jplPanel.setLayout (new GridLayout(4, 4));
for(i = 0;i<=15;i++){
jbnButton[i]=new JButton(""+(i+1));
jplPanel.add(jbnButton[i]);
String s = Integer.toString(i+1);
jbnButton[i].addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
/*if(j<2){
changeButton[j] = jbnButton[i];
num1 = i;
j++;
}
else if(j==2){
changeButton[j]=jbnButton[i];
jbnButton[num1] = changeButton[j];
jbnButton[i] = changeButton[j-1];
j=1;
}*/
//j++;
//JButton btn = (JButton[i])e.getSourec();
//lab.setText(btn.getLabel+".");
System.out.println(""+s);
}
});
}
jtfMainFrame.getContentPane().add(jplPanel, BorderLayout.CENTER);
jtfMainFrame.setVisible(true);
System.out.print("盧楷中\n");
}
}
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);
JPanel jplPanel = new JPanel();
int i;
int j=1;
int num1 , num2;
JButton jbnButton[] = new JButton[16];
JButton changeButton[] = new JButton[2];
jplPanel.setLayout (new GridLayout(4, 4));
for(i = 0;i<=15;i++){
jbnButton[i]=new JButton(""+(i+1));
jplPanel.add(jbnButton[i]);
String s = Integer.toString(i+1);
jbnButton[i].addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
/*if(j<2){
changeButton[j] = jbnButton[i];
num1 = i;
j++;
}
else if(j==2){
changeButton[j]=jbnButton[i];
jbnButton[num1] = changeButton[j];
jbnButton[i] = changeButton[j-1];
j=1;
}*/
//j++;
//JButton btn = (JButton[i])e.getSourec();
//lab.setText(btn.getLabel+".");
System.out.println(""+s);
}
});
}
jtfMainFrame.getContentPane().add(jplPanel, BorderLayout.CENTER);
jtfMainFrame.setVisible(true);
System.out.print("盧楷中\n");
}
}
2015年4月23日 星期四
java 9乘9乘法
public class Test
{
public static void main(String args[])
{
int i=1,k;
do{
k=1;
do
{
System.out.print(i+"*"+k+"="+(i*k)+"\t");
k++;
}while (k<=9);
System.out.println();
i++;
}while(i<=9);
}
}
{
public static void main(String args[])
{
int i=1,k;
do{
k=1;
do
{
System.out.print(i+"*"+k+"="+(i*k)+"\t");
k++;
}while (k<=9);
System.out.println();
i++;
}while(i<=9);
}
}
JAVA 兩個按鈕與文字方格
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(150, 150);
JButton jbnButton1 = new JButton("Button 1");
JButton jbnButton2 = new JButton("Button 2");
JPanel jplPanel = new JPanel();
JTextField jtfInput = new JTextField(20);
jplPanel.add(jbnButton1);
jplPanel.add(jbnButton2);
jplPanel.add(jtfInput);
jtfMainFrame.getContentPane().add(jplPanel, BorderLayout.CENTER);
jtfMainFrame.setVisible(true);
System.out.print("hi");
}
}
import java.awt.event.*;
import javax.swing.*;
class Test {
public static void main(String args[])
{
JFrame jtfMainFrame = new JFrame("Which Button Demo");
jtfMainFrame.setSize(150, 150);
JButton jbnButton1 = new JButton("Button 1");
JButton jbnButton2 = new JButton("Button 2");
JPanel jplPanel = new JPanel();
JTextField jtfInput = new JTextField(20);
jplPanel.add(jbnButton1);
jplPanel.add(jbnButton2);
jplPanel.add(jtfInput);
jtfMainFrame.getContentPane().add(jplPanel, BorderLayout.CENTER);
jtfMainFrame.setVisible(true);
System.out.print("hi");
}
}
java 迴圈製作按鍵
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);
JPanel jplPanel = new JPanel();
int i;
int j=1;
JButton jbnButton[] = new JButton[9];
for(i = 0;i<=8;i++){
//JButton jbnButton1 = new JButton("Button 1")
//jbnButton[i] = new JButton();
jbnButton[i]=new JButton("Button"+(i+1));
jplPanel.add(jbnButton[i]);
String s = Integer.toString(i+1);
jbnButton[i].addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("Button"+s);
}
});
}
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);
JPanel jplPanel = new JPanel();
int i;
int j=1;
JButton jbnButton[] = new JButton[9];
for(i = 0;i<=8;i++){
//JButton jbnButton1 = new JButton("Button 1")
//jbnButton[i] = new JButton();
jbnButton[i]=new JButton("Button"+(i+1));
jplPanel.add(jbnButton[i]);
String s = Integer.toString(i+1);
jbnButton[i].addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("Button"+s);
}
});
}
jtfMainFrame.getContentPane().add(jplPanel, BorderLayout.CENTER);
jtfMainFrame.setVisible(true);
System.out.print("chih-yu hsu");
}
}
java 1~10
class Test {
public static void main(String[] args) {
int i;
for (i = 1; i <= 10; i++) {
System.out.println(i);
}
}
}
public static void main(String[] args) {
int i;
for (i = 1; i <= 10; i++) {
System.out.println(i);
}
}
}
按鈕排列
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);
JPanel jplPanel = new JPanel();
int i;
int j=1;
int num1 , num2;
JButton jbnButton[] = new JButton[9];
JButton changeButton[] = new JButton[2];
jplPanel.setLayout (new GridLayout(3, 3));
for(i = 0;i<=8;i++){
jbnButton[i]=new JButton("Button"+(i+1));
jplPanel.add(jbnButton[i]);
String s = Integer.toString(i+1);
jbnButton[i].addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
/*if(j<2){
changeButton[j] = jbnButton[i];
num1 = i;
j++;
}
else if(j==2){
changeButton[j]=jbnButton[i];
jbnButton[num1] = changeButton[j];
jbnButton[i] = changeButton[j-1];
j=1;
}*/
//j++;
//JButton btn = (JButton[i])e.getSourec();
//lab.setText(btn.getLabel+".");
System.out.println("Button"+s);
}
});
}
jtfMainFrame.getContentPane().add(jplPanel, BorderLayout.CENTER);
jtfMainFrame.setVisible(true);
System.out.print("chih-yu hsu");
}
}
2015年4月9日 星期四
設置九個按鈕且有反應
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.print("Button 1!");
}
});
jbnButton2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
System.out.print("Button 2!");
}
});
jbnButton3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
System.out.print("Button 3!");
}
});
jbnButton4.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
System.out.print("Button 4!");
}
});
jbnButton5.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
System.out.print("Button 5!");
}
});
jbnButton6.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
System.out.print("Button 6!");
}
});
jbnButton7.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
System.out.print("Button 7!");
}
});
jbnButton8.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
System.out.print("Button 8!");
}
});
jbnButton9.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
System.out.print("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");
jbnButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
System.out.print("Button 1!");
}
});
jbnButton2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
System.out.print("Button 2!");
}
});
jbnButton3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
System.out.print("Button 3!");
}
});
jbnButton4.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
System.out.print("Button 4!");
}
});
jbnButton5.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
System.out.print("Button 5!");
}
});
jbnButton6.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
System.out.print("Button 6!");
}
});
jbnButton7.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
System.out.print("Button 7!");
}
});
jbnButton8.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
System.out.print("Button 8!");
}
});
jbnButton9.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
System.out.print("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月27日 星期五
java 按鈕
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");
JPanel jplPanel = new JPanel();
jplPanel.add(jbnButton1);
jtfMainFrame.getContentPane().add(jplPanel, BorderLayout.CENTER);
jtfMainFrame.setVisible(true);
}
}
ctrl c:跳開
2015年3月12日 星期四
java
<html>
<head>
<title> The First Example: Hello, World </title>
</head>
<body>
<h2> This line is HTML </h2>
<script language="JavaScript">
<!--
document.write("Hello, World.This sentence is written using JavaScript.");
// Text on the right of 2 slashes is comment
/* This is comment
that occur more than 1 line
*/
//-->
</script>
<noscript>
Sorry, but your browser doesn't run JavaScript.
</noscript>
<h2> This line is HTML </h2>
</body>
</html>
步驟1.開啟wordpad
步驟2.貼上程式碼
步驟3.更改姓名
步驟4.儲存檔案index 選擇txt副檔名
步驟5.更改副檔名為htm
2015年3月5日 星期四
安裝java執行一個程式+這堂課對自己的期許與(三個問題)
1為什麼修這門課?
學寫程式,好找工作
2 希望在這堂課學到什麼知識(目標)?
學會java
3 我要如何修習這門課?
上課和自修
安裝JAVA
選電腦 按右鍵
進階系統設定 選環境變數
變數path編輯 變數值後加/;
貼上JAVA所在資料夾C:\Program Files (x86)\Java\jdk1.8.0_31\bin 即可
學寫程式,好找工作
2 希望在這堂課學到什麼知識(目標)?
學會java
3 我要如何修習這門課?
上課和自修
安裝JAVA
選電腦 按右鍵
進階系統設定 選環境變數
變數path編輯 變數值後加/;
貼上JAVA所在資料夾C:\Program Files (x86)\Java\jdk1.8.0_31\bin 即可
訂閱:
文章 (Atom)















