| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 599 人关注过本帖
标题:[求助]请教!簿知道程序什么错误!~
只看楼主 加入收藏
qsrock
Rank: 1
等 级:新手上路
帖 子:255
专家分:0
注 册:2005-12-29
收藏
 问题点数:0 回复次数:4 
[求助]请教!簿知道程序什么错误!~
我运行出来的错误都不是错误!所以不知道那里错了!~请教下!~
很多奇怪错误!~高手指出下!
错误是软件包 java.swing 不存在
import java.awt.*;
import java.awt.geom.*;
import java.swing.*;
public class Map extends JFrame
{
public Map()
{
super("Map");
setSize(350,350);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
MapPane map=new MapPane();
Container content=getContentPane();
content.add(map);
setVisible(true);
}
public static void main(String[] arguments)
{
Map frame=new Map();
}
};
class MapPane extends JPanel
{
public void paintComponent(Graphics comp)
{
Graphics2D comp2D=(Graphics)comp;
comp2D.setColor(Color.blue);
Rectangle2D.Float background=new Rectangle2D.Float(0F,0F,(float)getSize().width,(float)getSize().height);
comp2D.setColor(Color.white);
BasicStroke pen=new BasicStroke(2F,BasicStroke.CAP_BUTT,BasicStroke.JOIN_ROUND);
comp2D.setStroke(pen);
for(int ax=0;ax<340;ax+=10)
for(int ay=0;ay<340;ay+=10){
Arc2D.Float wave=new Arc2D.Float(ax,ay,10,10,0,-180,Arc2D.OPEN);
comp2D.draw(wave);
}
GradientPaint gp=new GradientPaint(0F,0F,Color.green,350F,350F,Color.orange,true);
comp2D.setPaint(gp);
GeneralPath f1=new GeneralPath();
f1.moveTo(10F,12F);
f1.lineTo(234F,15F);
f1.lineTo(253F,25F);
f1.lineTo(261F,71F);
f1.lineTo(344F,209F);
f1.lineTo(336F,278F);
f1.lineTo(295F,310F);
f1.lineTo(259F,274F);
f1.lineTo(205F,188F);
f1.lineTo(211F,171F);
f1.lineTo(195F,174F);
f1.lineTo(191F,118F);
f1.lineTo(120F,56F);
f1.lineTo(94F,68F);
f1.lineTo(81F,49F);
f1.lineTo(12F,37F);
comp2D.fill(f1);
comp2D.setColor(Color.black);
BasicStroke pen2=new BasicStroke();
comp2D.setStroke(pen2);
Ellipse2D.Float e1=new Ellipse2D.Float(235,140,15,15);
Ellipse2D.Float e2=new Ellipse2D.Float(225,130,15,15);
Ellipse2D.Float e3=new Ellipse2D.Float(245,130,15,15);
comp2D.fill(e1);
comp2D.fill(e2);
comp2D.fill(e3);
}
};

[此贴子已经被作者于2006-9-6 22:48:50编辑过]

搜索更多相关主题的帖子: java import Map awt 
2006-09-06 22:14
qsrock
Rank: 1
等 级:新手上路
帖 子:255
专家分:0
注 册:2005-12-29
收藏
得分:0 
已经改正了!不好意思!

import java.awt.*;
import java.awt.geom.*;
import javax.swing.*;

public class Map extends JFrame {
public Map() {
super("Map");
setSize(350, 350);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
MapPane map = new MapPane();
Container content = getContentPane();
content.add(map);
setVisible(true);
}

public static void main(String[] arguments) {
Map frame = new Map();
}

}

class MapPane extends JPanel {
public void paintComponent(Graphics comp) {
Graphics2D comp2D = (Graphics2D)comp;
comp2D.setColor(Color.blue);
Rectangle2D.Float background = new Rectangle2D.Float(
0F, 0F, (float)getSize().width, (float)getSize().height);
comp2D.fill(background);
// Draw waves
comp2D.setColor(Color.white);
BasicStroke pen = new BasicStroke(2F,
BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND);
comp2D.setStroke(pen);
for (int ax = 0; ax < 340; ax += 10)
for (int ay = 0; ay < 340 ; ay += 10) {
Arc2D.Float wave = new Arc2D.Float(ax, ay,
10, 10, 0, -180, Arc2D.OPEN);
comp2D.draw(wave);
}
// Draw Florida
GradientPaint gp = new GradientPaint(0F, 0F, Color.green,
350F,350F, Color.orange, true);
comp2D.setPaint(gp);
GeneralPath fl = new GeneralPath();
fl.moveTo(10F, 12F);
fl.lineTo(234F, 15F);
fl.lineTo(253F, 25F);
fl.lineTo(261F, 71F);
fl.lineTo(344F, 209F);
fl.lineTo(336F, 278F);
fl.lineTo(295F, 310F);
fl.lineTo(259F, 274F);
fl.lineTo(205F, 188F);
fl.lineTo(211F, 171F);
fl.lineTo(195F, 174F);
fl.lineTo(191F, 118F);
fl.lineTo(120F, 56F);
fl.lineTo(94F, 68F);
fl.lineTo(81F, 49F);
fl.lineTo(12F, 37F);
fl.closePath();
comp2D.fill(fl);
// Draw ovals
comp2D.setColor(Color.black);
BasicStroke pen2 = new BasicStroke();
comp2D.setStroke(pen2);
Ellipse2D.Float e1 = new Ellipse2D.Float(235, 140, 15, 15);
Ellipse2D.Float e2 = new Ellipse2D.Float(225, 130, 15, 15);
Ellipse2D.Float e3 = new Ellipse2D.Float(245, 130, 15, 15);
comp2D.fill(e1);
comp2D.fill(e2);
comp2D.fill(e3);
}
}

[此贴子已经被作者于2006-9-6 22:47:06编辑过]

2006-09-06 22:44
wanghongxian
Rank: 1
等 级:新手上路
帖 子:100
专家分:0
注 册:2005-12-13
收藏
得分:0 
[经验]很简单修改下
把主类的public 去掉就可以了

2006-09-07 23:02
NiceGirl
Rank: 2
等 级:新手上路
威 望:4
帖 子:909
专家分:0
注 册:2006-6-18
收藏
得分:0 
我这里运行正常~~!

曾经以为百般艰难,蓦然回首,才发现已飞渡千山。。!
2006-09-07 23:23
hanshaojin
Rank: 1
等 级:新手上路
帖 子:30
专家分:0
注 册:2005-12-5
收藏
得分:0 

javax


2006-09-22 18:10
快速回复:[求助]请教!簿知道程序什么错误!~
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.032253 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved