代码如下~!!!但是画不出黑色的圆来 只有面板的背景颜色。我用netbeans写的
求救啊~!!!不胜感激~!!!
import java.awt.Color;
import java.awt.*;
import java.awt.geom.*;
import javax.swing.*;
class LittleChessPanel extends javax.swing.JPanel {
public LittleChessPanel() {
initComponents();
setBackground(new java.awt.Color(0, 0, 255));
setSize(new java.awt.Dimension(50, 50));
}
void Componentpaint(Graphics g) {
super.paintComponents(g);
g2=(Graphics2D)g;
g2.fillOval(5,5,40,40);
g2.setColor(new java.awt.Color(0,0,0));
}
void setlittlechesscolor(Color c) {g2.setColor(c);
}
int x,y,state=0;
private Graphics2D g2;
int getx(){return x;}
void setx(int i){x=i;}
int gety(){return y;}
void sety(int j){y=j;}
int getstate(){return state;}
void setstate(int s){state=s;}
// <editor-fold defaultstate="collapsed" desc=" 生成的代码 ">
private void initComponents() {
setAlignmentX(0.0F);
setAlignmentY(0.0F);
setPreferredSize(new java.awt.Dimension(50, 50));
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(0, 50, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(0, 50, Short.MAX_VALUE)
);
}// </editor-fold>
}