G
Guest
Gast
Folgender Fehler tritt auf:
CanvasCenter.java [23:1] cannot resolve symbol
symbol : method BasicStroke (float,int,int)
location: class CanvasCenter
BasicStroke pen = BasicStroke(2.0F,
^
1 error
Errors compiling.
Woran könnte das liegen??
Hier der Code:
CanvasCenter.java [23:1] cannot resolve symbol
symbol : method BasicStroke (float,int,int)
location: class CanvasCenter
BasicStroke pen = BasicStroke(2.0F,
^
1 error
Errors compiling.
Woran könnte das liegen??
Hier der Code:
Code:
import java.awt.*;
import javax.swing.*;
import java.awt.geom.*;
import java.awt.BasicStroke.*;
public class CanvasCenter extends JPanel
{
static Color c;
static int Pinseldicke=1;
public void paintComponent(Graphics comp)
{
Graphics2D comp2D = (Graphics2D)comp;
Font f = new Font("TEST",Font.BOLD,24);
FontMetrics FM = getFontMetrics(f);
comp2D.setFont(f);
String text = "MANNHEIMER JUNGS";
int x = (getSize().width - FM.stringWidth(text)) / 2;
int y = getSize().height /2 ;
comp2D.drawString(text,x,y);
BasicStroke pen = BasicStroke(2.0F,
BasicStroke.CAP_BUTT,
BasicStroke.JOIN_BEVEL);
comp2D.setStroke(pen)
Line2D.Float linie = new Line2D.Float(140f,100F,125F,50F);
comp2D.draw(linie);
}
CanvasCenter()
{
setBackground(Color.gray);
}
public void init() {
}
//public void paint(Graphics2D g) {
//}
public boolean mouseDrag(Event e, int x, int y){
Graphics g = this.getGraphics();
g.setColor(c);
switch (Pinseldicke){ // in Abhaengigkeit von Pixelstaerke
// unterschiedlich große Rechtecke
case 1:
g.fillRect(x,y,2,2);
break;
case 2:
g.fillRect(x,y,4,4);
break;
case 3:
g.fillRect(x,y,10,10);
break;
case 4:
g.fillRect(x,y,15,15);
break;
case 5:
g.fillRect(x,y,30,30);
break;
}
return true;
}
public void setFarbe()
{
c = JColorChooser.showDialog(null,"Farbe aussuchen!", Color.black);
}
public void setPinseldicke(int Pinsel)
{
Pinseldicke=Pinsel;
}
}