欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

Java帶注釋的代碼 java怎么注釋代碼

Java代碼注釋

ResourceBundle res;

網(wǎng)站建設(shè)哪家好,找創(chuàng)新互聯(lián)公司!專注于網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站建設(shè)、微信開(kāi)發(fā)、小程序制作、集團(tuán)企業(yè)網(wǎng)站建設(shè)等服務(wù)項(xiàng)目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了無(wú)棣免費(fèi)建站歡迎大家使用!

//打開(kāi)對(duì)應(yīng)的db.prop屬性文件文件,和你的java class同一目錄下

res = ResourceBundle.getBundle("db");

//從文件中取得ulr, user, password, jdbc driver名字

String url=res.getString("url");

String user=res.getString("user");

String password=res.getString("password");

String className = res.getString("classname");

try{

//初始化你的jdbc dirver

Class.forName(className).newInstance();

//建立connection

conn = DriverManager.getConnection(url,user,password);

}catch(Exception e)

{

e.printStackTrace();

}

return conn;

Java游戲代碼注釋

import javax.swing.*;import java.awt.*;import java.awt.event.*;public class lianliankan implements ActionListener{JFrame mainFrame; //主面板Container thisContainer;JPanel centerPanel,southPanel,northPanel; //子面板JButton diamondsButton[][] = new JButton[6][5];//游戲按鈕數(shù)組JButton exitButton,resetButton,newlyButton; //退出,重列,重新開(kāi)始按鈕JLabel fractionLable=new JLabel("0"); //分?jǐn)?shù)標(biāo)簽JButton firstButton,secondButton; //分別記錄兩次被選中的按鈕int grid[][] = new int[8][7];//儲(chǔ)存游戲按鈕位置static boolean pressInformation=false; //判斷是否有按鈕被選中int x0=0,y0=0,x=0,y=0,fristMsg=0,secondMsg=0,validateLV; //游戲按鈕的位置坐標(biāo)int i,j,k,n;//消除方法控制public void init(){mainFrame=new JFrame("JKJ連連看");thisContainer = mainFrame.getContentPane();thisContainer.setLayout(new BorderLayout());centerPanel=new JPanel();southPanel=new JPanel();northPanel=new JPanel();thisContainer.add(centerPanel,"Center");thisContainer.add(southPanel,"South");thisContainer.add(northPanel,"North");centerPanel.setLayout(new GridLayout(6,5));for(int cols = 0;cols 6;cols++){for(int rows = 0;rows 5;rows++ ){diamondsButton[cols][rows]=new JButton(String.valueOf(grid[cols+1][rows+1]));diamondsButton[cols][rows].addActionListener((java.awt.event.ActionListener) this);centerPanel.add(diamondsButton[cols][rows]);}}exitButton=new JButton("退出");exitButton.addActionListener((java.awt.event.ActionListener) this);resetButton=new JButton("重列");resetButton.addActionListener((java.awt.event.ActionListener) this);newlyButton=new JButton("再來(lái)一局");newlyButton.addActionListener((java.awt.event.ActionListener) this);southPanel.add(exitButton);southPanel.add(resetButton);southPanel.add(newlyButton);fractionLable.setText(String.valueOf(Integer.parseInt(fractionLable.getText())));northPanel.add(fractionLable);mainFrame.setBounds(280,100,500,450);mainFrame.setVisible(true);}public void randomBuild() {int randoms,cols,rows;for(int twins=1;twins=15;twins++) {randoms=(int)(Math.random()*25+1);for(int alike=1;alike=2;alike++) {cols=(int)(Math.random()*6+1);rows=(int)(Math.random()*5+1);while(grid[cols][rows]!=0) {cols=(int)(Math.random()*6+1);rows=(int)(Math.random()*5+1);}this.grid[cols][rows]=randoms;}}}public void fraction(){fractionLable.setText(String.valueOf(Integer.parseInt(fractionLable.getText())+100));}public void reload() {int save[] = new int[30];int n=0,cols,rows;int grid[][]= new int[8][7];for(int i=0;i=6;i++) {for(int j=0;j=5;j++) {if(this.grid[i][j]!=0) {save[n]=this.grid[i][j];n++;}}}n=n-1;this.grid=grid;while(n=0) {cols=(int)(Math.random()*6+1);rows=(int)(Math.random()*5+1);while(grid[cols][rows]!=0) {cols=(int)(Math.random()*6+1);rows=(int)(Math.random()*5+1);}this.grid[cols][rows]=save[n];n--;}mainFrame.setVisible(false);pressInformation=false; //這里一定要將按鈕點(diǎn)擊信息歸為初始init();for(int i = 0;i 6;i++){for(int j = 0;j 5;j++ ){if(grid[i+1][j+1]==0)diamondsButton[i][j].setVisible(false);}}}public void estimateEven(int placeX,int placeY,JButton bz) {if(pressInformation==false) {x=placeX;y=placeY;secondMsg=grid[x][y];secondButton=bz;pressInformation=true;}else {x0=x;y0=y;fristMsg=secondMsg;firstButton=secondButton;x=placeX;y=placeY;secondMsg=grid[x][y];secondButton=bz;if(fristMsg==secondMsg secondButton!=firstButton){xiao();}}}public void xiao() { //相同的情況下能不能消去。仔細(xì)分析,不一條條注釋if((x0==x (y0==y+1||y0==y-1)) || ((x0==x+1||x0==x-1)(y0==y))){ //判斷是否相鄰remove();}else{for (j=0;j7;j++ ) {if (grid[x0][j]==0){ //判斷第一個(gè)按鈕同行哪個(gè)按鈕為空if (yj) { //如果第二個(gè)按鈕的Y坐標(biāo)大于空按鈕的Y坐標(biāo)說(shuō)明第一按鈕在第二按鈕左邊f(xié)or (i=y-1;i=j;i-- ){ //判斷第二按鈕左側(cè)直到第一按鈕中間有沒(méi)有按鈕if (grid[x][i]!=0) {k=0;break;}else{ k=1; } //K=1說(shuō)明通過(guò)了第一次驗(yàn)證}if (k==1) {linePassOne();}}if (yj){ //如果第二個(gè)按鈕的Y坐標(biāo)小于空按鈕的Y坐標(biāo)說(shuō)明第一按鈕在第二按鈕右邊f(xié)or (i=y+1;i=j ;i++ ){ //判斷第二按鈕左側(cè)直到第一按鈕中間有沒(méi)有按鈕if (grid[x][i]!=0){k=0;break;}else { k=1; }}if (k==1){linePassOne();}}if (y==j ) {linePassOne();}}if (k==2) {if (x0==x) {remove();}if (x0x) {for (n=x0;n=x-1;n++ ) {if (grid[n][j]!=0) {k=0;break;}if(grid[n][j]==0 n==x-1) {remove();}}}if (x0x) {for (n=x0;n=x+1 ;n-- ) {if (grid[n][j]!=0) {k=0;break;}if(grid[n][j]==0 n==x+1) {remove();}}}}}for (i=0;i8;i++ ) { //列if (grid[i][y0]==0) {if (xi) {for (j=x-1;j=i ;j-- ) {if (grid[j][y]!=0) {k=0;break;}else { k=1; }}if (k==1) {rowPassOne();}}if (xi) {for (j=x+1;j=i;j++ ) {if (grid[j][y]!=0) {k=0;break;}else { k=1; }}if (k==1) {rowPassOne();}}if (x==i) {rowPassOne();}}if (k==2){if (y0==y) {remove();}if (y0y) {for (n=y0;n=y-1 ;n++ ) {if (grid[i][n]!=0) {k=0;break;}if(grid[i][n]==0 n==y-1) {remove();}}}if (y0y) {for (n=y0;n=y+1 ;n--) {if (grid[i][n]!=0) {k=0;break;}if(grid[i][n]==0 n==y+1) {remove();}}}}}}}public void linePassOne(){if (y0j){ //第一按鈕同行空按鈕在左邊f(xié)or (i=y0-1;i=j ;i-- ){ //判斷第一按鈕同左側(cè)空按鈕之間有沒(méi)按鈕if (grid[x0][i]!=0) {k=0;break;}else { k=2; } //K=2說(shuō)明通過(guò)了第二次驗(yàn)證}}if (y0j){ //第一按鈕同行空按鈕在與第二按鈕之間for (i=y0+1;i=j ;i++){if (grid[x0][i]!=0) {k=0;break;}else{ k=2; }}}}public void rowPassOne(){if (x0i) {for (j=x0-1;j=i ;j-- ) {if (grid[j][y0]!=0) {k=0;break;}else { k=2; }}}if (x0i) {for (j=x0+1;j=i ;j++ ) {if (grid[j][y0]!=0) {k=0;break;}else { k=2; }}}}public void remove(){firstButton.setVisible(false);secondButton.setVisible(false);fraction();pressInformation=false;k=0;grid[x0][y0]=0;grid[x][y]=0;}public void actionPerformed(ActionEvent e) {if(e.getSource()==newlyButton){int grid[][] = new int[8][7];this.grid = grid;randomBuild();mainFrame.setVisible(false);pressInformation=false;init();}if(e.getSource()==exitButton)System.exit(0);if(e.getSource()==resetButton)reload();for(int cols = 0;cols 6;cols++){for(int rows = 0;rows 5;rows++ ){if(e.getSource()==diamondsButton[cols][rows])estimateEven(cols+1,rows+1,diamondsButton[cols][rows]);}}}public static void main(String[] args) {lianliankan llk = new lianliankan();llk.randomBuild();llk.init();}}

java代碼注釋所有代碼

好像和另外一個(gè)一樣,貼一下:

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

public class GoodLucky extends JFrame implements ActionListener{

JTextField tf = new JTextField(); //實(shí)例化一個(gè)文本域

//設(shè)置兩個(gè)按鈕

JButton b1 = new JButton("開(kāi)始");

JButton b2 = new JButton("停止");

boolean isGo = false;

//構(gòu)造函數(shù)

public GoodLucky(){

b1.setActionCommand("start");//在開(kāi)始按鈕上設(shè)置一個(gè)動(dòng)作監(jiān)聽(tīng) start

JPanel p = new JPanel(); //實(shí)例化一個(gè)可視化容器

//將兩個(gè)按鈕添加到可視化容器上面,用add方法

p.add(b1);

p.add(b2);

//在兩個(gè)按鈕上增加監(jiān)聽(tīng)的屬性,自動(dòng)調(diào)用下面的監(jiān)聽(tīng)處理方法actionPerformed(ActionEvent e),如果要代碼有更好的可讀性,可用內(nèi)部類實(shí)現(xiàn)動(dòng)作

//監(jiān)聽(tīng)處理。

b1.addActionListener(this);

b2.addActionListener(this);

//將停止按鈕設(shè)置為不可編輯(即不可按的狀態(tài))

b2.setEnabled(false);

this.getContentPane().add(tf,"North"); //將上面的文本域放在面板的北方,也就是上面(上北下南左西右東)

this.getContentPane().add(p,"South"); //將可視化容器pannel放在南邊,也就是下面

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //設(shè)置用戶在此窗體上發(fā)起 "close" 時(shí)默認(rèn)執(zhí)行的操作,參數(shù)EXIT_ON_CLOSE是使用 System exit 方法退出應(yīng)用程序。僅在應(yīng)用程序中使用

this.setSize(300,200); //設(shè)置面板大小,寬和高

this.setLocation(300,300); //設(shè)置面板剛開(kāi)始的出現(xiàn)的位置

Cursor cu = new Cursor(Cursor.HAND_CURSOR); //用指定名稱創(chuàng)建一個(gè)新的定制光標(biāo)對(duì)象,參數(shù)表示手狀光標(biāo)類型

this.setCursor(cu); //為指定的光標(biāo)設(shè)置光標(biāo)圖像,即設(shè)置光標(biāo)圖像為上面所創(chuàng)建的手狀光標(biāo)類型

this.setVisible(true); //將面板可視化設(shè)置為true,即可視,如果為false,即程序運(yùn)行時(shí)面板會(huì)隱藏

tf.setText("welcome you! "); //設(shè)置面板的標(biāo)題為歡迎

this.go(); //調(diào)用go方法

}

public void go(){

while(true){ //這里是死循環(huán),也就是說(shuō)用戶不點(diǎn)擊停止按鈕的話他一直循環(huán)出現(xiàn)隨機(jī)數(shù),直到用戶點(diǎn)擊停止按鈕循環(huán)才能推出,具體流程在actionPerformed方法中控制。

if(isGo == true){ //上面所定義的isGo的初始值為false,所以程序第一次到此會(huì)跳過(guò)

String s = ""; //設(shè)置空字符串

for(int j = 1; j = 7;j++){ //產(chǎn)生7個(gè)隨機(jī)數(shù)

int i = (int)(Math.random() * 36) + 1;//每個(gè)隨機(jī)數(shù)產(chǎn)生方式,這里定義靈活,可以自由定義隨機(jī)數(shù)產(chǎn)生的方式

if(i 10){

s = s + " 0" + i; //如果產(chǎn)生的隨機(jī)數(shù)小于10的話做處理:這里就牽扯到一個(gè)重要的概念,簡(jiǎn)單敘述一下:

/*

當(dāng)一個(gè)字符串與一個(gè)整型數(shù)項(xiàng)相加的意思是連接,上面的s = s + " 0" + i的意思是字符串s鏈接0再連接整型i值,而不會(huì)導(dǎo)致0和整型的i相加,

產(chǎn)生的效果為s0i,由于s為空字符串(上面定義過(guò)的),所以當(dāng)i小于零時(shí),在個(gè)位數(shù)前面加上0,比如產(chǎn)生的隨機(jī)數(shù)i為7的話,顯示效果為 07.

*/

}else{

s = s + " " + i; //如果產(chǎn)生的隨機(jī)數(shù)比10打的話,那么加上空格顯示,即數(shù)字和數(shù)字之間有個(gè)空格

}

//以上循環(huán)循環(huán)七次,以保證能出現(xiàn)7個(gè)隨機(jī)數(shù)

}

tf.setText(s); //將產(chǎn)生的隨機(jī)數(shù)全部顯示在文本域上,用文本域?qū)ο髏f調(diào)用它的設(shè)置文本的方法setText(String)實(shí)現(xiàn)。

}

//以下為線程延遲

try{

Thread.sleep(10); //線程類同步方法sleep,睡眠方法,括號(hào)里的單位為ms。

}catch(java.lang.InterruptedException e){

e.printStackTrace(); //異常捕獲,不用多說(shuō)。

}

}

}

//以下是上面設(shè)置的事件監(jiān)聽(tīng)的具體處理辦法,即監(jiān)聽(tīng)時(shí)間處理方法,自動(dòng)調(diào)用

public void actionPerformed(ActionEvent e){ //傳入一個(gè)動(dòng)作事件的參數(shù)e

String s = e.getActionCommand(); //設(shè)置字符串s來(lái)存儲(chǔ)獲得動(dòng)作監(jiān)聽(tīng),上面的start

/*

以下這個(gè)條件語(yǔ)句塊的作用為:用戶點(diǎn)擊開(kāi)始后(捕獲start,用方法getActionCommand()),將命令觸發(fā)設(shè)置為true,從而執(zhí)行上面的go方法中的循環(huán)體(因?yàn)檠h(huán)體中要求isGo參數(shù)為true,而初始為false)。

執(zhí)行循環(huán)快產(chǎn)生隨機(jī)數(shù),并將開(kāi)始按鈕不可編輯化,而用戶只可以使用停止按鈕去停止。如果用戶按下停止時(shí),也就是沒(méi)有傳入?yún)?shù)“start”的時(shí)候,

執(zhí)行else語(yǔ)句塊中的語(yǔ)句,isGo設(shè)置為false,將不執(zhí)行上面go中的循環(huán)語(yǔ)句塊,從而停止產(chǎn)生隨機(jī)數(shù),并顯示,并且把開(kāi)始按鈕設(shè)置為可用,而把

停止按鈕設(shè)置為不可用,等待用戶按下開(kāi)始再去開(kāi)始新一輪循環(huán)產(chǎn)生隨機(jī)數(shù)。

*/

if(s.equals("start")){ //如果捕獲到start,也就是用戶觸發(fā)了動(dòng)作監(jiān)聽(tīng)器,那么下面處理

isGo = true; //設(shè)置isGo為true

b1.setEnabled(false); //將開(kāi)始按鈕設(shè)置為不可用

b2.setEnabled(true); //將停止按鈕設(shè)置為可用

}else{

isGo = false; //將isGo設(shè)置為false,isGo為循環(huán)標(biāo)志位

b2.setEnabled(false); //設(shè)置停止按鈕為不可用(注意看是b2,b2是停止按鈕)

b1.setEnabled(true); //設(shè)置開(kāi)始按鈕為可用

}

}

public static void main(String[] args){

new GoodLucky(); //產(chǎn)生類的實(shí)例,執(zhí)行方法

}

}

java 源代碼注釋

import java.awt.*;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import javax.swing.*;

public class GameTest extends JFrame implements ActionListener{

/*

* 新建一個(gè)主面板(這個(gè)類可能是自定義的,本程序和API中沒(méi)有)。

*/

MainPanel j=new MainPanel();

JButton jPreview;

JLabel label;

Container container;

JPanel panel;

/**

* 主函數(shù)

* @param args

*/

public static void main(String[] args) {

//運(yùn)行程序

new GameTest();

}

/**

* 構(gòu)造函數(shù)。

*

*/

public GameTest()

{

//新建一個(gè)標(biāo)題為“拼圖”的窗口

JFrame fr =new JFrame("拼圖");

//獲取窗口容器。

container=fr.getContentPane();

//創(chuàng)建菜單條

JMenuBar jMenuBar=new JMenuBar();

//以下初始化菜單,并且設(shè)置快捷鍵和添加監(jiān)聽(tīng)器。

JMenu jMenuGame=new JMenu("游戲(G)");

jMenuGame.setMnemonic('g');

JMenuItem jMenuItemStart = new JMenuItem("開(kāi)始(S)");

jMenuItemStart.setMnemonic('s');

jMenuItemStart.addActionListener(this);

JMenuItem jMenuItemExit=new JMenuItem("退出(E)");

jMenuItemExit.setMnemonic('e');

jMenuItemExit.addActionListener(this);

jMenuGame.add(jMenuItemStart);

jMenuGame.add(jMenuItemExit);

//初始化按鈕并設(shè)置快捷鍵和添加監(jiān)聽(tīng)器

JButton jChoice=new JButton("選圖(X)");

jChoice.setMnemonic('x');

jChoice.addActionListener(this);

jPreview=new JButton("預(yù)覽(P)");

jPreview.setMnemonic('p');

jPreview.addActionListener(this);

//將菜單和按鈕添加到菜單條中

jMenuBar.add(jMenuGame);

jMenuBar.add(jChoice);

jMenuBar.add(jPreview);

//將菜單條設(shè)為該窗口的主菜單

fr.setJMenuBar(jMenuBar);

//將主面板添加到該窗口的容器中。

container.add(j);

//設(shè)置大小

fr.setSize(315,360 );

fr.setVisible(true);

//設(shè)置默認(rèn)關(guān)閉方式。

fr.setDefaultCloseOperation(3);

}

/**

* 事件處理函數(shù)。

*/

public void actionPerformed(ActionEvent e) {

if(e.getActionCommand()=="開(kāi)始(S)")

{

j.Start();

}

if(e.getActionCommand()=="預(yù)覽(P)")

{

j.setVisible(false);

panel=new JPanel();

Icon icon=new ImageIcon("pictrue/pic"+"_"+MainPanel.pictureID+".jpg");

label=new JLabel(icon);

label.setBounds(300, 300, 0, 0);

panel.add(label);

panel.setSize(300, 300);

panel.setVisible(true);

this.container.add(panel);

jPreview.setText("返回(P)");

}

if(e.getActionCommand()=="返回(P)")

{

panel.setVisible(false);

j.setVisible(true);

j.repaint();

jPreview.setText("預(yù)覽(P)");

}

if(e.getActionCommand()=="退出(E)")

{

System.exit(0);

}

if(e.getActionCommand()=="選圖(X)")

{

//初始化選擇框,并提供選擇。

Choice pic = new Choice();

pic.add("七里香");

pic.add("依然范特西");

pic.add("八度空間");

pic.add("十一月的肖邦");

pic.add("魔杰座");

pic.add("葉惠美");

pic.add("我很忙");

int i=JOptionPane.showConfirmDialog(this, pic, "選擇圖片", JOptionPane.OK_CANCEL_OPTION);

if(i==JOptionPane.YES_OPTION)

{

//選擇圖片

MainPanel.pictureID=pic.getSelectedIndex()+1;

j.removeAll();

j.reLoadPicture();

j.repaint();

}

}

}

}

急求java代碼注釋

import?java.awt.Button;//使用java.awt包提供的Button(按鈕)

import?java.awt.Frame;//使用java.awt包提供的容器frame(帶標(biāo)題框)

import?java.awt.Label;//使用java.awt包提供的Lable控件

import?java.awt.Panel;//使用java.awt包提供的容器panel(面板)

import?java.awt.TextField;//使用java.awt包內(nèi)的TextField類

import?java.awt.event.ActionEvent;

import?java.awt.event.ActionListener;

public?class?denglu?implements?ActionListener?{

denglu()?{

Panel?p1,?p2,?p3;

TextField?tName,?tPassword;

Frame?f;

//框架組件

f?=?new?Frame("學(xué)生信息管理系統(tǒng)");

//設(shè)置橫軸?縱軸?寬??高

f.setBounds(100,?100,?300,?200);

//設(shè)置默認(rèn)布局為BorderLayout

f.setLayout(null);

p1?=?new?Panel();

p2?=?new?Panel();

p3?=?new?Panel();

//新建文本標(biāo)簽組件

Label?I1?=?new?Label("學(xué)號(hào):");

Label?I2?=?new?Label("密碼:");

//建立文本框組件?列的值是8

tName?=?new?TextField(8);

tPassword?=?new?TextField(8);

//輸出的密碼用*表示

tPassword.setEchoChar('*');

//建立按鈕組件

Button?b1?=?new?Button("登陸");

Button?b2?=?new?Button("注冊(cè)");

//添加當(dāng)前框架監(jiān)聽(tīng)事件

b2.addActionListener(this);

//同上

p1.setBounds(60,?40,?180,?30);

p2.setBounds(60,?80,?180,?30);

p3.setBounds(60,?120,?180,?40);

//將文本框,按鈕等組件加入到面板上

p1.add(I1);

p1.add(tName);

p2.add(I2);

p2.add(tPassword);

p3.add(b1);

p3.add(b2);

//將面板添加到frame框架上去

f.add(p1);

f.add(p2);

f.add(p3);

//框架可見(jiàn)

f.setVisible(true);

}

public?static?void?main(String?args[])?{

new?denglu();

}

public?void?actionPerformed(ActionEvent?arg0)?{

//new?zhuce();

}

}

java代碼每一句的注釋

import?java.awt.*;???//awt的圖形包

import?javax.swing.*;//swing的圖形包

import?java.io.*; //IO流處理包

import?java.awt.event.*;?//事件處理包

public?class?CDInfor?extends?JFrame?implements?ActionListener//繼承swing?的Frame?實(shí)現(xiàn)?事件接口?

{

BufferedReader?in;? //輸入輸出管道流

FileWriter?out;

JPanel?jPanel1?=?new?JPanel(); //定義?6個(gè)Jpanel(容器)用來(lái)裝組件?(就是你按鈕什么的)

JPanel?jPanel2?=?new?JPanel(new?GridLayout(4,1)); //其中這個(gè)是??用網(wǎng)格的布局管理器

JPanel?jPanel3?=?new?JPanel();

JPanel?jPanel5?=?new?JPanel();

JPanel?jPanel4?=?new?JPanel();

JPanel?jPanel6?=?new?JPanel();

JScrollPane?jScrollPane1?=?new?JScrollPane(); //定義滾動(dòng)條

JTextArea?jTextArea1?=?new?JTextArea("",10,25); //定義輸入框

GridLayout?gridLayout1?=?new?GridLayout(); //整體用的事?網(wǎng)格布局管理器

JTextField?jTextField1?=?new?JTextField(10);? //文本輸入框

JTextField?jTextField2?=?new?JTextField(10);?

JTextField?jTextField3?=?new?JTextField(10);?

JLabel?jLabel1?=?new?JLabel("唱片編號(hào):"); //定義顯示的字?(只用來(lái)顯示字)

JLabel?jLabel2?=?new?JLabel("唱片名稱:");

JLabel?jLabel3?=?new?JLabel("歌手姓名:");

JButton?jButton1?=?new?JButton("增加"); //定義按鈕

JButton?jButton2?=?new?JButton("取消");

String?str;

public?CDInfor()?{ //構(gòu)造方法?程序啟動(dòng)的時(shí)候?或者調(diào)用這個(gè)類的時(shí)候執(zhí)行(這里是程序啟動(dòng))

try?{

setDefaultCloseOperation(EXIT_ON_CLOSE);????//天劍程序關(guān)閉的方法?要不然?你點(diǎn)關(guān)閉?界面沒(méi)了?但是資源沒(méi)釋放

jbInit(); //調(diào)用jbInit()方法?用于實(shí)現(xiàn)事件

}

catch?(Exception?exception)?{ //錯(cuò)誤捕捉

exception.printStackTrace();

}

}

public?void?jbInit()

{

Container?cp?=?getContentPane(); //定義一個(gè)pane的容器

cp.setLayout(new?BorderLayout()); //布局為邊框布局

jButton1.addActionListener(this); //將按鈕1?綁定事件

jButton2.addActionListener(this); //將按鈕2?綁定事件

jTextArea1.setEditable(false); //將這個(gè)輸入框設(shè)定為不可編輯

jScrollPane1.getViewport().add(jTextArea1); //滾動(dòng)條和jTextArea1綁定

jPanel3.add(jLabel1);?jPanel3.add(jTextField1);???//將各個(gè)組件加入Jpanel里

jPanel4.add(jLabel2);?jPanel4.add(jTextField2);

jPanel5.add(jLabel3);?jPanel5.add(jTextField3);

jPanel6.add(jButton1);?jPanel6.add(jButton2);

jPanel1.add(jScrollPane1);

jPanel2.add(jPanel3);?jPanel2.add(jPanel4);?jPanel2.add(jPanel5);?jPanel2.add(jPanel6);

jPanel2.setPreferredSize(new?Dimension(10,?150));

cp.add("Center",jPanel1);

cp.add("South",jPanel2);???

}

public?void?actionPerformed(ActionEvent?e) //實(shí)現(xiàn)事件監(jiān)聽(tīng)

{

if(e.getSource()==jButton1) //如果當(dāng)前是?按鈕一的話

{

try?{}?

catch?(Exception?ex)?{}

}

jTextField1.setText("");? //內(nèi)容全部清空

jTextField2.setText("");

jTextField3.setText("");

}

public?static?void?main(String[]?args)?throws?Exception

{

CDInfor?kk?=?new?CDInfor(); //應(yīng)為main是Static?所以?要new?本身類

kk.setSize(350,350); //設(shè)定大小

kk.setTitle("Please?caculat:"); //設(shè)定標(biāo)題欄文字

kk.setVisible(true); //是否顯示?這個(gè)窗口

}

}

還不夠詳細(xì)么親~?采納吧~~

標(biāo)題名稱:Java帶注釋的代碼 java怎么注釋代碼
新聞來(lái)源:http://chinadenli.net/article40/dodjpho.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供動(dòng)態(tài)網(wǎng)站云服務(wù)器ChatGPT域名注冊(cè)微信小程序網(wǎng)站營(yíng)銷

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

營(yíng)銷型網(wǎng)站建設(shè)