日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
java點(diǎn)擊按鈕的代碼 java點(diǎn)擊按鈕觸發(fā)事件有哪些

java中點(diǎn)擊一個(gè)按鈕彈出兩個(gè)輸入文本框的源代碼

寫了一個(gè)很簡單的案例,可以參考和修改

創(chuàng)新互聯(lián)建站專注于企業(yè)全網(wǎng)營銷推廣、網(wǎng)站重做改版、巨鹿網(wǎng)站定制設(shè)計(jì)、自適應(yīng)品牌網(wǎng)站建設(shè)、HTML5商城開發(fā)、集團(tuán)公司官網(wǎng)建設(shè)、外貿(mào)網(wǎng)站建設(shè)、高端網(wǎng)站制作、響應(yīng)式網(wǎng)頁設(shè)計(jì)等建站業(yè)務(wù),價(jià)格優(yōu)惠性價(jià)比高,為巨鹿等各大城市提供網(wǎng)站開發(fā)制作服務(wù)。

import?java.awt.BorderLayout;

import?java.awt.GridLayout;

import?java.awt.event.ActionEvent;

import?java.awt.event.ActionListener;

import?javax.swing.JButton;

import?javax.swing.JDialog;

import?javax.swing.JFrame;

import?javax.swing.JLabel;

import?javax.swing.JTextField;

public?class?FromeDemo?extends?JFrame{

JButton?jbutton;

public?FromeDemo()?{

jbutton?=?new?JButton("彈出2個(gè)文本框");

jbutton.addActionListener(new?ActionListener()?{

@Override

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

JDialog?jd?=?new?JDialog();

jd.setBounds(320,?180,?260,?100);

jd.setTitle("彈出文本框");

jd.getContentPane().setLayout(new?GridLayout(2,?2));

jd.add(new?JLabel("文本框一"));

jd.add(new?JTextField(80));

jd.add(new?JLabel("文本框二"));

jd.add(new?JTextField(80));

jd.setModal(true);//確保彈出的窗口在其他窗口前面

jd.setVisible(true);

}

});

add(jbutton,BorderLayout.SOUTH);

setBounds(300,?100,?320,?320);

setTitle("測試");

setDefaultCloseOperation(EXIT_ON_CLOSE);

setVisible(true);

}

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

new?FromeDemo();

}

}

java中做一個(gè)按鈕,點(diǎn)擊按鈕后畫一個(gè)矩形的代碼怎么寫?

兄弟幫你寫了一個(gè):

import java.awt.Button;

import java.awt.Color;

import java.awt.Frame;

import java.awt.Graphics;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.awt.event.WindowAdapter;

import java.awt.event.WindowEvent;

import java.util.Random;

public class Print {

public static void main(String[] args) {

new Te();

}

}

class Te extends Frame implements ActionListener {

Color cc = Color.red;

int x = -20, y = -50;

Random r = new Random();

public Te() {

this.setLayout(null);

Button b = new Button("畫圓");

this.add(b);

b.setBounds(30,30,50,50);

b.addActionListener(this);

this.addWindowListener(new WindowAdapter () {

@Override

public void windowClosing(WindowEvent e) {

System.exit(0);

}

});

this.setBounds(200,200,500,400);

this.setVisible(true);

}

public void actionPerformed(ActionEvent e) {

this.cc = Color.red;

this.x = r.nextInt(400);

do {

int x1 = r.nextInt(300);

this.y = x1;

} while (this.y 50);

this.repaint();

}

@Override

public void paint(Graphics g) {

Color c = g.getColor();

g.setColor(cc);

g.drawRect(x,y,50,50);

g.setColor(c);

}

}

Java中按鈕事件代碼

加入在frame中的按鈕名為sure

Button sure=new Button("確定");

sure.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent evt)

{

frame1.setVisible(false);

Frame frame2=new Frame();

frame2.setVisible(true);

}

});

Java中實(shí)現(xiàn)點(diǎn)擊一個(gè)按鈕出現(xiàn)一個(gè)新的頁面且關(guān)閉當(dāng)前頁面

采用以下代碼即可:

JButton?btn=new?JButton(new?AbstractAction("關(guān)閉并打開")?{???

@Override

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

oldFrame.dispose();//?關(guān)閉并銷毀,無需銷毀可采用oldFrame.setVisible(false);

newFrame.setVisible(true);//?打開新窗口

}

});


新聞名稱:java點(diǎn)擊按鈕的代碼 java點(diǎn)擊按鈕觸發(fā)事件有哪些
轉(zhuǎn)載注明:http://www.dlmjj.cn/article/hhcojc.html