java弹出提示框源代码,javaweb弹出提示框
求JAVA,固定时间弹出对话提示框,点确定关闭,提示“让眼睛休息休息”的源代码
import java.awt.BorderLayout;
创新互联是一家专业提供张湾企业网站建设,专注与成都网站建设、成都网站制作、H5建站、小程序制作等业务。10年已为张湾众多企业、政府机构等服务。创新互联专业网站建设公司优惠进行中。
import java.awt.GridLayout;
import java.awt.Label;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.*;
import javax.swing.*;
public class TestFrame {
public static void main(String args[]) throws InterruptedException {
new LaunchFrame();
}
}
class LaunchFrame implements ActionListener {
LaunchFrame() throws InterruptedException{
Thread.sleep(0);
JFrame f = new JFrame();
JButton jb = new JButton("确定");
jb.addActionListener(this);
Label l = new Label("让眼睛休息一会..");
f.setBounds(200, 200, 200, 200);
f.setLayout(new GridLayout(2,1));
f.add(l);
f.add(jb);
f.pack();
f.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
}
Java new JFrame(title)后如何弹出提示框?求源码举例
public class Test extends JFrame
{
public Test() {
setSize(100, 200);
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
addWindowListener(new WindowAdapter(){
@Override
public void windowClosing(WindowEvent e) {
int option= JOptionPane.showConfirmDialog(
Test.this, "确定退出系统? ", "提示 ",JOptionPane.YES_NO_CANCEL_OPTION);
if(option==JOptionPane.YES_OPTION)
if(e.getWindow() == Test.this)
{
System.exit(0);
}
else
{
return;
}
}
});
}
public static void main(String[] args) {
new Test().setVisible(true);
}
}
java中点击一个按钮弹出两个输入文本框的源代码
写了一个很简单的案例,可以参考和修改
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个文本框");
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弹出提示框源代码,javaweb弹出提示框
链接地址:http://cdiso.cn/article/dscjheg.html