各位大侠们,请问在JAVA中怎样弹出一个消息框。如何弹出一个form.(是否可以用show). JOptionPane.showMessageDialog(null,"消息框内容","消息框标题",JOptionPane.OK_CANCEL_OPTION); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 import java.awt.event.*;import javax.swing.*;class ShowDemo extends JFrame implements ActionListener{ JButton buttonMessage,buttonFrame; JFrame frame; JPanel pane; ShowDemo() { super("Frame show"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); buttonMessage=new JButton("´ò¿ªÏûÏ¢¿ò"); buttonMessage.addActionListener(this); buttonFrame=new JButton("´ò¿ªForm2"); buttonFrame.addActionListener(this); pane=new JPanel(); pane.add(buttonMessage); pane.add(buttonFrame); getContentPane().add(pane); setSize(300,300); show(); frame=new JFrame("Form2"); frame.setSize(200,200); frame.setVisible(false); } public static void main(String[] arguments) { ShowDemo sd=new ShowDemo(); } public void actionPerformed(ActionEvent evt) { if(evt.getSource()==buttonFrame) { frame.setVisible(true); } else { JOptionPane.showMessageDialog(null,"我是消息框!"); } }} 不好意思我的中文显示有问题,重贴:import java.awt.event.*;import javax.swing.*;class ShowDemo extends JFrame implements ActionListener{ JButton buttonMessage,buttonFrame; JFrame frame; JPanel pane; ShowDemo() { super("Frame show"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); buttonMessage=new JButton("打开消息框"); buttonMessage.addActionListener(this); buttonFrame=new JButton("打开Form2"); buttonFrame.addActionListener(this); pane=new JPanel(); pane.add(buttonMessage); pane.add(buttonFrame); getContentPane().add(pane); setSize(300,300); show(); frame=new JFrame("Form2"); frame.setSize(200,200); frame.setVisible(false); } public static void main(String[] arguments) { ShowDemo sd=new ShowDemo(); } public void actionPerformed(ActionEvent evt) { if(evt.getSource()==buttonFrame) { frame.setVisible(true); } else { JOptionPane.showMessageDialog(null,"我是消息框!"); } }} 哈。javax.swing.JOptionPane就这个类 webservice怎么调存储过程 框架集跳转问题 分享一个项目missian(一个异步RPC的框架) org.apache.commons.fileupload.FileUploadException: Processing of multipart/form- proxyTargetClass问题 使用Ibatis操做CLOB ActionForm中取得中文变成乱码 请问哪个bbs论坛软件性能最好? Myeclipse 启动的时候总是如下错 DAO问题 一个困惑我一天的问题 关于xlst 如何对XML中的Qname类型作类型验证(用Java)
import java.awt.event.*;
import javax.swing.*;class ShowDemo extends JFrame implements ActionListener
{
JButton buttonMessage,buttonFrame;
JFrame frame;
JPanel pane;
ShowDemo()
{
super("Frame show");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
buttonMessage=new JButton("´ò¿ªÏûÏ¢¿ò");
buttonMessage.addActionListener(this);
buttonFrame=new JButton("´ò¿ªForm2");
buttonFrame.addActionListener(this);
pane=new JPanel();
pane.add(buttonMessage);
pane.add(buttonFrame);
getContentPane().add(pane);
setSize(300,300);
show();
frame=new JFrame("Form2");
frame.setSize(200,200);
frame.setVisible(false);
}
public static void main(String[] arguments)
{
ShowDemo sd=new ShowDemo();
}
public void actionPerformed(ActionEvent evt)
{
if(evt.getSource()==buttonFrame)
{
frame.setVisible(true);
}
else
{
JOptionPane.showMessageDialog(null,"我是消息框!");
}
}
}
import java.awt.event.*;
import javax.swing.*;class ShowDemo extends JFrame implements ActionListener
{
JButton buttonMessage,buttonFrame;
JFrame frame;
JPanel pane;
ShowDemo()
{
super("Frame show");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
buttonMessage=new JButton("打开消息框");
buttonMessage.addActionListener(this);
buttonFrame=new JButton("打开Form2");
buttonFrame.addActionListener(this);
pane=new JPanel();
pane.add(buttonMessage);
pane.add(buttonFrame);
getContentPane().add(pane);
setSize(300,300);
show();
frame=new JFrame("Form2");
frame.setSize(200,200);
frame.setVisible(false);
}
public static void main(String[] arguments)
{
ShowDemo sd=new ShowDemo();
}
public void actionPerformed(ActionEvent evt)
{
if(evt.getSource()==buttonFrame)
{
frame.setVisible(true);
}
else
{
JOptionPane.showMessageDialog(null,"我是消息框!");
}
}
}