问题描述
比如我想写一个在键盘上按向上箭头然后就在frame里画一个圆出来但是怎么按也画不出来我这个程序错在那了???importjava.awt.*;importjava.awt.event.*;importjava.util.*;publicclasshh{publicstaticvoidmain(String[]args){newframe("asdasdasdasd");}}classframeextendsFrame{frame(Strings){super(s);this.setBounds(100,100,500,500);this.setVisible(true);this.addKeyListener(newA());this.addWindowListener(newB());}publicStrings;publicvoidff(intk){if(k==KeyEvent.VK_UP){s="up";}}publicvoidpaint(Graphicsg){if(s=="up"){g.setColor(Color.BLACK);g.fillOval(20,20,40,40);}}}classAextendsKeyAdapter{framef=null;publicvoidkeyPressed(KeyEvente){intkey=e.getKeyCode();f=(frame)e.getSource();f.ff(key);}}classBextendsWindowAdapter{publicvoidwindowClosing(WindowEvente){System.exit(0);}}
解决方案
解决方案二:
updateUI();
不觉得swing的界面很丑吗?
解决方案三:
引用1楼ycnanevol的回复:
JavacodeupdateUI();不觉得swing的界面很丑吗?
额。。怎么修改啊??