东理子JOptionPane类SHANDONGUNIVERSITYOFTECHNOLOGY系统提供一些常用模式对话框(标准对话框)询问一个确认问题,如showConfirmDialogyes/no/cancel。★showlnputDialog提示要求某些输入。★showMessageDialog告知用户某事已发生。★showOptionDialog上述三项的大统一(GrandUnification)。消息这些对话框的基本外形通常与右图类似图标输入值选项按钮专业专注创新
专业 专注 创新 JOptionPane类 系统提供一些常用模式对话框(标准对话框) showConfirmDialog 询问一个确认问题,如 yes/no/cancel。 showInputDialog 提示要求某些输入。 showMessageDialog 告知用户某事已发生。 showOptionDialog 上述三项的大统一 (Grand Unification)。 这些对话框的基本外形通常与右图类似
东理功JOptionPane类程序举例SHANDONG UNIVERSITYOFTECHNOLOGYDJDialogTest2.javaDJDialogTestjavaJOptionPaneTest.javaXpackage cn.sdut,eimport javax.swing.*importjava.awt.*;publicclassJoptionPaneTest(Cpublic static void main(string[l args)Joptionpane.showMessageDiaiog(null,"Hello","testtitle"JOptionPane.ERRORMESSAGE):JoptionPane.showMessageDiaiog(null,"Hello","testtitleJOptionPane.ERRORMESSAGE,newImageIcon("imgl.gif)),inti=JoptionPane.showConfirmDialog(null,"Howare you?");//是-0,否-1,取消-2JoptionPane.showInputDialog(null,"您现在还好吗?"),string[]s=("好",还可以"!;"您现在还好吗?”,“输入"JoptionPane.showInputDialog(null,JOptionPane.QUESTION MESSAGE,null,s,s[Ol);1区人选择一个选顶X输入testtitleX您现在还好码?您现在还好吗?7.Howareyou?好Hello取泪是Y萌定香(N)眼消确定确定取润
专业 专注 创新 JOptionPane类程序举例
static voidshowlessageDialog(Component parentComponent, Obiect message)调出标题为"lessage”的信息消息对话框static woidshovlessageDialog(Component parentComponent, Object message,String title, int messageType调出对话框,它显示使用由 messageType参数确定的默认图标的message。static voidshowlessageDialog(ComponentparentComponent,Object message, String title, int messagelype, Icon icon)调出一个显示信息的对话框,为其指定了所有参数。static intshovConfirnDialog(Component parentComponent, Object message)调出带有选项Yes、No和Cancel的对话框;标题为Select anOption。static intshovConfirnDialog(ComponentparentComponent,Obiect message,Stringtitle,int optionType)调出一个由optionType参数确定其中选项数的对话框。static intshovConfirnDialog(Component parentComponent, Object message, String title, int optionType, int messagelype)调用一个由optionType参数确定其中选项数的对话框,messageType参数确定要显示的图标static intshovConfirnDialog(Component parentComponent, Obiect message, String title, int optionType, int messagelype, Icon icon)调出一个带有指定图标的对话框,其中的选项数由optionType参数确定。static StrinrshovInputDialog (Component ParentComponent,Object message)显示请求用户输入内容的问题消息对话框,它以ParentComponent为父级。static Strin shovInputDialog(Component parentComponent,Obiect message, Obiect initialSelectionValue)显示请求用户输入内容的问题消息对话框,它以ParentComponent为父级。static StrinrshowInputDialog(Component parentComponent,Objectmessage,String title,intmessageType)显示请求用户输入内容的对话框,它以parentComponent为父级,该对话框的标题为title,消息类型为messageTypeostatic ObiectshovInputDialog (Component parentComponent, Object message, String title, int messagelype, Icon icon, Object[] selectionValues, Obiect initialSelectionValue)提示用户在可以指定初始选择、可能选择及其他所有选项的模块化的对话框中输入内容。static StrinrshovInputDialog (Obiect message)显示请求用户输入的问题消息对话框。static StrinrshovInputDialog(Obiect message, Obiect initialSelectionValue)显示请求用户输入的问题消息对话框,它带有已初始化为initialSelectionvalue的输入值。专业专注创新
专业 专注 创新
东理本章总体纲要SHANDONGUNIVERSITY OF TECHNOLOGY8.1组件和容器★8.1.1整体介绍★8.1.2 JFrame和JLabel★8.1.3JDialog和JOptionPane8.1.4JTextField和JPasswordField★8.1.5JButton、JCheckBox和JRadioButton★8.1.6JComboBox、JList、JTextArea和JScrollPane★8.1.7JSlider和JPanel8.2布局管理器8.3事件处理模型8.4高级图形用户界面专业专注创新
专业 专注 创新 8.1 组件和容器 8.1.1 整体介绍 8.1.2 JFrame和JLabel 8.1.3 JDialog和JOptionPane 8.1.4 JTextField和JPasswordField 8.1.5 JButton、JCheckBox和JRadioButton 8.1.6 JComboBox、JList、JTextArea和JScrollPane 8.1.7 JSlider和JPanel 8.2 布局管理器 8.3 事件处理模型 8.4 高级图形用户界面 本章总体纲要
文本框(JTextField)和东理功客密码框(JPasswordField)SHANDONG UNIVERSITY OF TECHNOLOGY两个类均用来编辑单java.lang.Object行文本,前者看到输L java. awt.Component<6*99入的字符,后者以L java. awt.Container号显示。javax.swing.JComponentjavax.swing.text.JTextComponent实际文本长度超过文javax.swing.JTextField本框宽度时,用键盘javax.swing.JPasswordField的左右键可以查看其内容。专业专注创新
专业 专注 创新 文本框(JTextField)和 密码框(JPasswordField) 两个类均用来编辑单 行文本,前者看到输 入的字符,后者以“*” 号显示。 实际文本长度超过文 本框宽度时,用键盘 的左右键可以查看其 内容