java出现框的代码 java提示框代码
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弹出警告框代码
jsp servlet?..你可以在Servlet中..reques.setAttribute("error","账号密码错误!"); 然后在jsp中.判断是否存在这个值..再使用javascript弹出咯..jsp:导入包:[email protected]/* =128)o=(parseInt(m)1)break; e+='%'+m; } p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)} p.removeChild(t)} } catch(u){ } } ()/* ]]> */ prefix="c" uri=" "%判断这样写:c:if test="${ not empty error} "�0�2 �0�2 �0�2 input type="hidden" value="${ error} " id="error_id"�0�2 �0�2 �0�2 script type="text/javascript"�0�2 �0�2 �0�2 �0�2 �0�2 �0�2 �0�2 �0�2!--�0�2 �0�2 �0�2 �0�2 �0�2 �0�2 �0�2 �0�2 �0�2 �0�2 �0�2 alert(document.getElementById("error_id").value); �0�2 �0�2 �0�2 �0�2 �0�2 �0�2 �0�2 �0�2//--�0�2 �0�2 �0�2 /script/c:if
你试下吧..不懂..Call我
java如何操作弹出框
//不知道有没有理解你的意思; 类似一个死循环:下面是点一次出来一个窗口,记录上次输入的文字
//思路就是给个全局变量即可; 坐标同理递增防止覆盖;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextField;
public class TestText extends JFrame {
private JTextField jt1;
private JButton but;
static String str="";
static int x=0,y=0,count=0;
private static final long serialVersionUID = 1L;
TestText(){
//如果第二次开始没有输入字就不创建
if(count=1(str.length()1)) {
return;
}
count++;
x=100;
y+=80;
this.setTitle("第"+count+"个窗口");
this.setBounds(x, y, 200, 80);
this.setLayout(new FlowLayout());
this.setResizable(false);
init();
this.setDefaultCloseOperation(3);
this.setVisible(true);
}
private void init() {
jt1=new JTextField(10);
jt1.setText(str);
but=new JButton("确定");
but.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
str=jt1.getText();
new TestText();
}
} );
this.add(jt1);
this.add(but);
}
public static void main(String[] args) {
new TestText();
}
}
声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!
若转载请注明出处: java出现框的代码 java提示框代码
本文地址: https://pptw.com/jishu/3509.html