各位兄弟们,路过的都进来看一下啊 就是我想在一个面板里们添加一个按钮,然后就是当点击这个按钮的时候就会弹出一个窗口,不知道怎么做啊,就用java.awt里的这些构件或者其它的,不用jsp或者javaScript能做吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 问题是没装JB呢这个东西特吃内存我现在是用JCreator Pro楼上的朋友可以指点一下吗? import java.awt.*;import java.awt.event.*;class BasicButtons implements ActionListener{ private Frame win; private Label msg; private static final String hi="Hello!World!"; private static final String huh="What,me worry?"; private static final String bye="Exit"; public BasicButtons() { win = new Frame("Event handling Example"); init(); win.show(); } public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); if(cmd.equals(hi)) //msg.setText(hi); //这儿添加显示新窗口的代码就行了 else if(cmd.equals(huh)) msg.setText(huh); else if(cmd.equals(bye)) System.exit(0); } private void init() { win.setLayout(new FlowLayout()); addButton(hi); addButton(huh); addButton(bye); msg = new Label("This is a label."); msg.setFont(new Font("Dialog",Font.BOLD,14)); msg.setBackground(Color.green); msg.setAlignment(Label.CENTER); win.add(msg); win.setSize(600,100); } private void addButton(String name) { Button b = new Button(name); b.setFont(new Font("Helvetica",Font.BOLD,14)); b.addActionListener(this); win.add(b); }} to: xtaotao(淘淘你这个程序先前我有找到但是还是解决不了我的问题哦to:lubber() 具体要怎么做呢?另外是这样的在这个按钮所在的面板上还有输入信息的界面当点击那个按钮的时候还需要在另外的窗口里显示输入的信息哦 jsp可以啊。onclick 就可以了呀。 to:annahw(安娜)就是说想不用JSP看能不能做啊 关于数据库添加记录的问题. Singleton 动态建立JTable 又提一个极极极极极极极极极极菜鸟的问题,解决后马上结贴 是不是不用多线程的话,就什么都做不了 开始学习JAVA,大家推荐好的SDK. 四舍五入的问题请指点!谢谢! 拖动重画的JPanel 怎么获得一个输入流的大小或一个文件的大小? 怎样将一个串中某个子串去掉? 群组招募 为什么运行是控件就是显示不了?
这个东西特吃内存我现在是用JCreator Pro
楼上的朋友可以指点一下吗?
import java.awt.event.*;class BasicButtons implements ActionListener
{
private Frame win;
private Label msg;
private static final String hi="Hello!World!";
private static final String huh="What,me worry?";
private static final String bye="Exit";
public BasicButtons()
{
win = new Frame("Event handling Example");
init();
win.show();
}
public void actionPerformed(ActionEvent e)
{
String cmd = e.getActionCommand();
if(cmd.equals(hi))
//msg.setText(hi);
//这儿添加显示新窗口的代码就行了
else if(cmd.equals(huh))
msg.setText(huh);
else if(cmd.equals(bye))
System.exit(0);
}
private void init()
{
win.setLayout(new FlowLayout());
addButton(hi);
addButton(huh);
addButton(bye);
msg = new Label("This is a label.");
msg.setFont(new Font("Dialog",Font.BOLD,14));
msg.setBackground(Color.green);
msg.setAlignment(Label.CENTER);
win.add(msg);
win.setSize(600,100);
}
private void addButton(String name)
{
Button b = new Button(name);
b.setFont(new Font("Helvetica",Font.BOLD,14));
b.addActionListener(this);
win.add(b);
}
}
你这个程序先前我有找到
但是还是解决不了我的问题哦to:lubber() 具体要怎么做呢?
另外是这样的在这个按钮所在的面板上还有输入信息的界面
当点击那个按钮的时候还需要在另外的窗口里显示输入的信息哦
就是说想不用JSP看能不能做啊