「java中弹框」java弹出提示

博主:adminadmin 2023-01-15 00:18:07 322

今天给各位分享java中弹框的知识,其中也会对java弹出提示进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

java怎么设置弹出文本框?

其实很简单的哦\x0d\x0a\x0d\x0aimport javax.swing.JOptionPane;\x0d\x0a\x0d\x0apublic class Test {\x0d\x0a\x0d\x0apublic static void main(String[] args) {\x0d\x0aString s=JOptionPane.showInputDialog("请输入:");\x0d\x0a}\x0d\x0a}\x0d\x0a非常简单的一个弹消息框的代码

java中实现弹出不同的警告和提示框

显示一个错误对话框,该对话框显示的 message 为 'alert':

JOptionPane.showMessageDialog(null, "alert", "alert", JOptionPane.ERROR_MESSAGE); 

2.显示一个内部信息对话框,其 message 为 'information': 

JOptionPane.showInternalMessageDialog(frame, "information","information", JOptionPane.INFORMATION_MESSAGE); 

3.显示一个信息面板,其 options 为 "yes/no",message 为 'choose one': 

JOptionPane.showConfirmDialog(null, "choose one", "choose one", JOptionPane.YES_NO_OPTION); 

4.显示一个内部信息对话框,其 options 为 "yes/no/cancel",message 为 'please choose one',并具有 title 信息: 

JOptionPane.showInternalConfirmDialog(frame, 

"please choose one", "information", 

JOptionPane.YES_NO_CANCEL_OPTION, 

JOptionPane.INFORMATION_MESSAGE); 

5.显示一个警告对话框,其 options 为 OK、CANCEL,title 为 'Warning',message 为 'Click OK to continue': 

Object[] options = { "OK", "CANCEL" }; 

JOptionPane.showOptionDialog(null, "Click OK to continue", "Warning", 

JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, 

null, options, options[0]); 

6.显示一个要求用户键入 String 的对话框: 

String inputValue = JOptionPane.showInputDialog("Please input a value"); 

7.显示一个要求用户选择 String 的对话框:

Object[] possibleValues = { "First", "Second", "Third" }; 

Object selectedValue = JOptionPane.showInputDialog(null, "Choose one", "Input", 

JOptionPane.INFORMATION_MESSAGE, null, 

possibleValues, possibleValues[0]);

以上摘抄自CSDN, 纯复制~ 不过挺符合你的要求的

如何用java弹出自己编辑的对话框

import java.awt.BorderLayout;

import java.awt.Container;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JOptionPane;

public class showMessage extends JFrame{

    public showMessage(){

        Container c =this.getContentPane();

        JButton jb = new JButton("点我出现message");

        c.add(jb,BorderLayout.NORTH);

        setSize(100, 80);

        setVisible(true);

        

        jb.addActionListener(new ActionListener() {

            

            @Override

            public void actionPerformed(ActionEvent arg0) {

                JOptionPane.showMessageDialog(null, "没错,我就是神奇的Message!");

                

            }

        });

        

    }

    

    public static void main(String[] args) {

        new showMessage();

    }

}

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();

}

}

java中弹框的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于java弹出提示、java中弹框的信息别忘了在本站进行查找喔。