如何在类中使用joption窗格 [英] how to use the joption pane in a class

查看:74
本文介绍了如何在类中使用joption窗格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何显示joptionPane以显示按钮上的消息

i JFrame类,其中有一个jcomboBox和一个按钮
按钮上的
单击另一个类即Connect类被称为

现在我想要的是一条消息,因为发生了一些错误而出现了

但却给出了错误





// JOptionPane类型中的方法showMessageDialog(Component,Object,String,int)不适用于参数(String,String,String,int)







我应该传递哪个组件和对象,我在JFrame类中有组件,即jcomboBox,但我没有任何组件和连接类中的对象





请帮助我

how can i show the joptionPane to show the message on button click
i JFrame class which have a jcomboBox and a button
on the button click the other class i.e Connect class is been called
now what i want that a message shoud appear for some error occured
but it is giving error


// The method showMessageDialog(Component, Object, String, int) in the type JOptionPane is not applicable for the arguments (String, String, String, int)



which component and object should i pass, i have component in the JFrame class i.e jcomboBox but i dont have any component and object in Connect class


please help me

推荐答案

< a href =http://docs.oracle.com/javase/tutorial/uiswing/components/dialog.html> http://docs.oracle.com/javase/tutorial/uiswing/components/dialog.html [ ^ ]



read。
http://docs.oracle.com/javase/tutorial/uiswing/components/dialog.html[^]

read.


简单地说,当你按下按钮(据我所知)你想做这样的事情:

To simply put it, when you press the button( as i have understood ) you want to do something like this:
JOptionPane.showMessageDialog(yourFrame,"This is the error message that you want to display");





以下是来自docs.oracle.com的链接,以获取有关JOptionPane的更多信息:

http://docs.oracle.com/javase/7/docs/api /javax/swing/JOptionPane.html [ ^ ]



您也可以选择要显示的消息类型(错误消息,信息消息)等等,它都在上面的链接中。



祝你好运。



Here is the link from docs.oracle.com for better information about JOptionPane:
http://docs.oracle.com/javase/7/docs/api/javax/swing/JOptionPane.html[^]

You have the possibility as well to choose what kind of message you want to display(Error Message, Information Message etc.), it''s all in the link above.

Best regards.


这篇关于如何在类中使用joption窗格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆