额~新手入门~用eslipse编译java程序,在JLable处显示错误:Lable cannot be resolved to a type请教高手,这是咋回事?
解决方案 »
- java求一个数的立方根,不使用库函数
- java自动画线段,关于sleep
- 请教一下,我对接口这样理解对不对:
- 分享一个局域网的聊天室程序 (支持窗口界面和telnet界面)
- 求助:一道面试题,挑出本程序的错误,并改正!
- JDK1.5没有System.dirSep了吗?
- 请问如何为JPanel指定大小?用setBounds()和setPreferredSize()和setSize()好象都不行。前面的post都看了,没有解决问题。
- 在java applet中如何关闭IE窗口呢?
- 下载了jbuilder5,是rar格式的,解开后有两个文件,一个是rsc-jb5.bin,一个是rsc-jb5.cue,据说这两个文件是刻光盘的,请问谁知道怎么刻?不会用这两个文件直接安装吧?谢谢!
- 关于爬虫模拟登陆
- 初级线程题:用两个线程模拟对话
- 关于updateui
//Initial version with events.import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import javax.swing.*;
import javax.swing.event.*;public class DrawingPanel extends MouseInputAdapter
implements ActionListener {
private Frame frame; //overall window frame
private Panel panel; //drawing surface
private Lable statusbar; //status bar
private Graphics g; //drawing pen
//constructs a drawing panel of given size
public DrawingPanel(int width,int height) {
//set up the empty image onto which we will draw
BufferedImage image = new BufferedImage(width,height,BufferedImage.TYPE_INT_ARGB);
g = image.getGraphics();
g.setColor(Color.BLACK);
//enclose the image in a label inside a panel
Label label = new Label();
label.setIcon(new ImageIcon(image));
panel = new Panel(new FlowLayout());
panel.setBackground(Color.WHITE);
panel.setPreferredSize(new Dimension(width,height));
panel.add(label);
//the status bar that shows the mouse position
statusBar = new Label(" ");
//attach listener to observe mouse movement
panel.addMouseListener(this);
panel.addMouseMotionListener(this);
//set up the JFrame
frame = new Frame("Drawing Panel");
frame.setDefaultCloseOperation(Frame.EXIT_ON_CLOSE);
frame.setResizable(false);
frame.setLayout(new BorderLayout());
frame.add(panel,BorderLayout());
frame.add(statusBar,BorderLayout.SOUTH);
frame.pack();
frame.setVisible(true);
//start a repaint timer to refresh the screen
Timer timer = new Timer(250,this);
timer.start();
}
//obtains the Graphics object to draw on the panel
public Graphics getGraphics() {
return g;
}
//sets the background color of the drawing panel
public void setBackground(Color c) {
panel.setBackground(c);
}
//shows or hides the drawing panel on the screen
public void setVisible(boolean visible) {
frame.setVisible(visible);
}
//used for timer that repeatedly repaint screen
public void actionPerformed(ActionEvent e) {
panel.repaint();
}
//draws status bar text when mouse moves
public void mouseMoved(MouseEvent e) {
statusBar.setText("(" + e.getX() + "," + e.getY() + ")");
}
}
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Label;
import java.awt.Panel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.Timer;
import javax.swing.event.MouseInputAdapter;public class DrawingPanel extends MouseInputAdapter implements ActionListener {
private Frame frame; // overall window frame
private Panel panel; // drawing surface
private Label statusbar; // status bar
private Graphics g; // drawing pen // constructs a drawing panel of given size
public DrawingPanel(int width, int height) {
// set up the empty image onto which we will draw
BufferedImage image = new BufferedImage(width, height,
BufferedImage.TYPE_INT_ARGB);
g = image.getGraphics();
g.setColor(Color.BLACK); // enclose the image in a label inside a panel
Label label = new Label();
label.setIcon(new ImageIcon(image));
panel = new Panel(new FlowLayout());
panel.setBackground(Color.WHITE);
panel.setPreferredSize(new Dimension(width, height));
panel.add(label); // the status bar that shows the mouse position
statusbar = new Label(" "); // attach listener to observe mouse movement
panel.addMouseListener(this);
panel.addMouseMotionListener(this); // set up the JFrame
frame = new Frame("Drawing Panel");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setResizable(false);
frame.setLayout(new BorderLayout());
frame.add(panel, BorderLayout.NORTH);
frame.add(statusbar, BorderLayout.SOUTH);
frame.pack();
frame.setVisible(true); // start a repaint timer to refresh the screen
Timer timer = new Timer(250, this);
timer.start();
} private void setDefaultCloseOperation(int exitOnClose) {
// TODO Auto-generated method stub
} // obtains the Graphics object to draw on the panel
public Graphics getGraphics() {
return g;
} // sets the background color of the drawing panel
public void setBackground(Color c) {
panel.setBackground(c);
} // shows or hides the drawing panel on the screen
public void setVisible(boolean visible) {
frame.setVisible(visible);
} // used for timer that repeatedly repaint screen
public void actionPerformed(ActionEvent e) {
panel.repaint();
} // draws status bar text when mouse moves
public void mouseMoved(MouseEvent e) {
statusbar.setText("(" + e.getX() + "," + e.getY() + ")");
}
}稍微给你改了下,你有些变量名拼写错误。那个setIcon那个不知道怎么改。只能帮到这里了。加油
这是Import后面的javax文件中提示的错误:Access restriction: The type MouseInputAdapter is not accessible due to restriction on required library C:\Program Files\Java\jdk1.7.0\jre\lib\rt.jar
这是怎么回事呢?