Topic: 求助:java图形界面的问题 |
Print this page |
1.求助:java图形界面的问题 | Copy to clipboard |
Posted by: turing514 Posted on: 2006-07-27 14:00 package map; import java.awt.event.*; import java.awt.*; import javax.swing.*; /** * <p>Title: </p> * * <p>Description: </p> * * <p>Copyright: Copyright 2006</p> * * <p>Company: </p> * * @author not attributable * @version 1.0 */ public class test extends JFrame { public test() { super("Map"); setSize(500,500); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); MapPane map1=new MapPane(); Container content =(JPanel)getContentPane(); content.add(map1); } public static void main(String[] args) { test Frame = new test(); Frame.show(); } } class MapPane extends JFrame{ public void paintComponent(Graphics comp){ Graphics comp2D =(Graphics2D)comp; comp2D.drawString("haiwang",100,100); } } 编译是老出现错误(本程序是21天学通java的现成的程序): java.lang.IllegalArgumentException: adding a window to a container at java.awt.Container.addImpl(Container.java:616) at java.awt.Container.add(Container.java:307) at map.test.<init>(test.java:24) at map.test.main(test.java:28) Exception in thread "main" 各个大虾给说说为什么? |
2.Re:求助:java图形界面的问题 [Re: turing514] | Copy to clipboard |
Posted by: turing514 Posted on: 2006-07-27 15:19 怎么没有人来问答问题阿 |
3.Re:求助:java图形界面的问题 [Re: turing514] | Copy to clipboard |
Posted by: xintao222 Posted on: 2006-08-06 14:38 class MapPane extends JFrame{ public void paintComponent(Graphics comp){ Graphics comp2D =(Graphics2D)comp; comp2D.drawString("haiwang",100,100); } 将extends JFrame改为extends JPanel就没问题了 |
4.Re:求助:java图形界面的问题 [Re: turing514] | Copy to clipboard |
Posted by: why Posted on: 2006-08-06 21:10 turing514 wrote: 才不過一個小時多 沒有耐性請自便...... |
5.Re:求助:java图形界面的问题 [Re: turing514] | Copy to clipboard |
Posted by: yinzhun Posted on: 2006-08-11 14:57 上上楼的说的对只要将extends JFrame改为extends JPanel就没问题了 如果你写JFrame 在把它加到Container 当然要错了 |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |