A、JOptionPane.messageDialog(this, "您输入了非法字符", "警告对话框", JOptionPane.WARNING_MESSAGE);
B、new JOptionPane.messageDialog(this, "您输入了非法字符", "警告对话框", JOptionPane.WARNING_MESSAGE);
C、JOptionPane.showMessageDialog(this, "您输入了非法字符", "警告对话框", JOptionPane.WARNING_MESSAGE);
D、new JOptionPane.showMessageDialog(this, "您输入了非法字符", "警告对话框", JOptionPane.WARNING_MESSAGE);
本题的功能是监听键盘键的敲击,并显示在窗口中。 import javax,.swing.*; importjava.awt.*; , import java.awt.event.*; public class java3 extends JFrame. extends KeyListener { private String linel=""line2="" private String line3="" private JTextArea textArea; public java3 { super("java3"); textArea=new JTextArea(10,15); textArea.setText("Press any key on the key- board…"); textArea.setEnabled(false); addKeyListener(this); getContentPane.add(textArea); setSize(350,100); show; } public void keyPressed(KeyEvent e) { linel="Key pressed:"+e.getKeyText(e. getKeyCode); setLines2and3(e); } public void keyReleased(KeyEvent e) { linel="Key released:"+e.getKeyText(e. getKeyCode); setLines2and3(e): } public void keyTyped(KeyEvent e) { Linel="Key typed:"+e.getKeychar; setLines2and3(e); } private void setLines2and3(KeyEvent e) { line2="This key is"+(e.isActionKey?"" :"not")+"an action key"; String temp=e.getKeyModifiersText(e.get- Modifiers); hne3="Modifier keys pressed:"+(temp.e- quals("")?"none":temp); textArea.setText(linel+"\n"+line2+"\n" +line3+"\n"); } public static void main(String args[]) { java3 app=new java3; addWindowListener(new Windowadapted { public void windowClosing(WindowEvent e) { System.exit(0); } }); } }
B.在写GUI程序时,AWT和Swing不能同时使用
C.AWT和Swing在不同的平台上都有相同的表示
D.AWT中的类是从Swing继承的
A.每个Swing构件的程序必须有一个容器
B.Swing是AWT的扩展
C.Swing采用的MVC的思想
D.Swing构件以“J”开头
为了保护您的账号安全,请在“简答题”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!