hi
hab mir ein Malprogramm programmiert, als ich dann halb fertig war viel mir auf das ich gar nicht weiß wie man
das was man gemalt hat in einer datei(jpg) speichern kann. Ich weiß ncith ob das so überhaupts möglich ist
Hier einmal der Quelltext:
hoffe, dass nicht alles um sonst war
Jetzt schon mal danke für's helfen
hab mir ein Malprogramm programmiert, als ich dann halb fertig war viel mir auf das ich gar nicht weiß wie man
das was man gemalt hat in einer datei(jpg) speichern kann. Ich weiß ncith ob das so überhaupts möglich ist
Hier einmal der Quelltext:
Code:
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.util.*;
import java.io.*;
import javax.swing.text.*;
import java.awt.print.*;
public class Malprogramm extends JFrame {
static Malprogramm fenster;
int x,y;
int w,h;
int x2,y2;
int Farben1z;
int Farben2z;
int Farben3z;
int rx = 50;
int ry = 50;
CBildLeinwand bildanzeige;
ButtonGroup gruppe;
String Label;
String dateiname;
String Fuellen ="";
String TextEingabe = "";
String look;
private JComboBox extra;
private JComboBox Farbenwahl;
private JComboBox HFarbenwahl;
boolean text1 = false;
boolean booleanFuellen = false;
private Image dbImage;
private Graphics dbGraphics;
class ActionLauscher implements ActionListener {
public void actionPerformed(ActionEvent e) {
Label = e.getActionCommand();
if (Label.equals("speichern"))
speichern();
if (Label.equals("beenden"))
System.exit(0);
JComboBox cb = (JComboBox) e.getSource();
farbeaktuell();
}
}
Malprogramm (String titel) {
super(titel);
setLayout(new BorderLayout());
bildanzeige = new CBildLeinwand();
add(bildanzeige);
bildanzeige.setBackground(Color.white);
JMenuBar menuleiste = new JMenuBar();
setJMenuBar(menuleiste);
JMenu menu = new JMenu("Datei");
//menu erstellen
JMenuItem speichern = new JMenuItem("speichern"); //Menubutton laden
speichern.addActionListener(new ActionLauscher());
JMenuItem beenden = new JMenuItem("beenden");
beenden.addActionListener(new ActionLauscher());
menu.add(speichern);
menu.add(beenden);
JPanel gesamt = new JPanel();
gesamt.setLayout(new BorderLayout());
gesamt. setBackground(Color.yellow);
JPanel zeichnen = new JPanel();
zeichnen. setBackground(Color.yellow);
zeichnen.setLayout(new GridLayout(8,1,0,5));
gruppe = new ButtonGroup();
JButton Rechteck = new JButton();
Rechteck.setToolTipText("Rechteck");
Rechteck.setIcon(new ImageIcon("rechteck.png"));
Rechteck.setBackground(Color.yellow);
Rechteck.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(1, 1, 1, 1)));
JButton RundRechteck = new JButton();
RundRechteck.setToolTipText("Gerundetes Rechteck");
RundRechteck.setIcon(new ImageIcon("rundrechteck.png"));
RundRechteck.setBackground(Color.yellow);
RundRechteck.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(1, 1, 1, 1)));
JButton Text = new JButton();
Text.setToolTipText("Text");
Text.setIcon(new ImageIcon("text.png"));
Text.setBackground(Color.yellow);
Text.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(1, 1, 1, 1)));
JButton Oval = new JButton();
Oval.setToolTipText("Ovale");
Oval.setIcon(new ImageIcon("oval.png"));
Oval.setBackground(Color.yellow);
Oval.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(1, 1, 1, 1)));
JButton Linie = new JButton ();
Linie.setToolTipText("Linie");
Linie.setIcon(new ImageIcon("linie.png"));
Linie.setBackground(Color.yellow);
Linie.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(1, 1, 1, 1)));
JButton Poli = new JButton();
Poli.setToolTipText("Poligon");
Poli.setIcon(new ImageIcon("poli.png"));
Poli.setBackground(Color.yellow);
Poli.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(1, 1, 1, 1)));
JButton FreiHand = new JButton();
FreiHand.setToolTipText("Freihandlinie");
FreiHand.setIcon(new ImageIcon("freihand.png"));
FreiHand.setBackground(Color.yellow);
FreiHand.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(1, 1, 1, 1)));
JCheckBox Fuellen = new JCheckBox("Füllen");
Fuellen.addActionListener(new ActionLauscher());
JButton löschen = new JButton();
löschen.setToolTipText("löschen");
löschen.setIcon(new ImageIcon("löschen.png"));
löschen.setBackground(Color.yellow);
löschen.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(1, 1, 1, 1)));
Rechteck.addActionListener(new ActionLauscher(){
public void actionPerformed (ActionEvent e) {
Label = "Rechteck";
}
});
Oval.addActionListener(new ActionLauscher() {
public void actionPerformed (ActionEvent e){
Label = "Oval";
}
});
Poli.addActionListener(new ActionLauscher(){
public void actionPerformed (ActionEvent e){
Label = "Poligon";
}
});
RundRechteck.addActionListener(new ActionLauscher(){
public void actionPerformed (ActionEvent e){
Label = "RRechteck";
}
});
Text.addActionListener(new ActionLauscher(){
public void actionPerformed (ActionEvent e){
Label = "Text";
text1 = true;
}
});
Linie.addActionListener(new ActionLauscher(){
public void actionPerformed (ActionEvent e){
Label = "Linie";
}
});
FreiHand.addActionListener(new ActionLauscher(){
public void actionPerformed (ActionEvent e){
Label = "FreiHand";
}
});
löschen.addActionListener(new ActionLauscher(){
public void actionPerformed (ActionEvent e){
Label = "löschen";
}
});
gruppe.add(Poli);
gruppe.add(Oval);
gruppe.add(Rechteck);
gruppe.add(RundRechteck);
gruppe.add(Text);
gruppe.add(Linie);
gruppe.add(FreiHand);
gruppe.add(löschen);
zeichnen.add(Rechteck);
zeichnen.add(Oval);
zeichnen.add(Poli);
zeichnen.add(RundRechteck);
zeichnen.add(Text);
zeichnen.add(Linie);
zeichnen.add(FreiHand);
zeichnen.add(löschen);
JPanel Farben = new JPanel();
Farben. setBackground(Color.yellow);
Farben.setLayout(new GridLayout(8,1,0,0));
JLabel extras =new JLabel("Extras:");
String[] extraA = {"keine","3D-Model","Füllen","Metal", "Windows","Motif"};
extra = new JComboBox(extraA);
JLabel Eleer= new JLabel("");
extra.addActionListener(new ActionLauscher());
Farben.add(extras);
Farben.add(extra);
Farben.add(Eleer);
JLabel VG = new JLabel(" Vordergrund:");
String[] elemente = {"Schwarz","Weiß","Rot","Blau","Grün","Gelb","Orange","Cyan","Rosa","Eigene"};
Farbenwahl = new JComboBox(elemente);
JLabel leer = new JLabel("");
Farbenwahl.addActionListener(new ActionLauscher());
Farben.add(VG);
Farben.add(Farbenwahl);
Farben.add(leer);
JLabel HG = new JLabel(" Hintergrund:");
String[] HElemente = {"Weiß","Schwarz","Rot","Blau","Grün","Gelb","Orange","Cyan","Rosa","Eigene"};
HFarbenwahl = new JComboBox(HElemente);
HFarbenwahl.addActionListener(new ActionLauscher());
Farben.add(HG);
Farben.add(HFarbenwahl);
gesamt.add(zeichnen , BorderLayout.NORTH);
gesamt.add(Farben,BorderLayout.SOUTH);
add(gesamt , BorderLayout.WEST);
menuleiste.add(menu);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
public void speichern(){
FileDialog d = new FileDialog(this,"Bild speichern...",FileDialog.SAVE);
d.setVisible(true);
dateiname = d.getDirectory();
dateiname += d.getFile();
ImageIcon tmp= new ImageIcon(dateiname);
Image Bild = tmp.getImage();
}
public void farbeaktuell() {
String farbe = (String) Farbenwahl.getSelectedItem();
String Hfarbe = (String) HFarbenwahl.getSelectedItem();
Fuellen = (String) extra.getSelectedItem();
look = (String)extra.getSelectedItem();
if (look.equals("Windows"))
lookandfeel();
if (look.equals("Metal"))
lookandfeel();
if (look.equals("Motif"))
lookandfeel();
if (farbe.equals("Schwarz"))
bildanzeige.setForeground(Color.black);
if (farbe.equals("Weiß"))
bildanzeige.setForeground(Color.white);
if (farbe.equals("Rot"))
bildanzeige.setForeground(Color.red);
if (farbe.equals("Blau"))
bildanzeige.setForeground(Color.blue);
if (farbe.equals("Grün"))
bildanzeige.setForeground(Color.green);
if (farbe.equals("Gelb"))
bildanzeige.setForeground(Color.yellow);
if (farbe.equals("Orange"))
bildanzeige.setForeground(Color.orange);
if (farbe.equals("Cyan"))
bildanzeige.setForeground(Color.cyan);
if (farbe.equals("Rosa"))
bildanzeige.setForeground(Color.magenta);
if (farbe.equals("Eigene")) {
farbdialog();
}
if (Hfarbe.equals("Weiß"))
bildanzeige.setBackground(Color.white);
if (Hfarbe.equals("Schwarz"))
bildanzeige.setBackground(Color.black);
if (Hfarbe.equals("Rot"))
bildanzeige.setBackground(Color.red);
if (Hfarbe.equals("Blau"))
bildanzeige.setBackground(Color.blue);
if (Hfarbe.equals("Grün"))
bildanzeige.setBackground(Color.green);
if (Hfarbe.equals("Gelb"))
bildanzeige.setBackground(Color.yellow);
if (Hfarbe.equals("Orange"))
bildanzeige.setBackground(Color.orange);
if (Hfarbe.equals("Cyan"))
bildanzeige.setBackground(Color.cyan);
if (Hfarbe.equals("Rosa"))
bildanzeige.setBackground(Color.magenta);
if (Hfarbe.equals("Eigene"))
Hfarbdialog();
}
public void lookandfeel(){
try {
//PLAF-Klasse auswählen
String plaf = "unknown";
if (look.equals("Metal")) {
plaf = "javax.swing.plaf.metal.MetalLookAndFeel";
} else if (look.equals("Motif")) {
plaf = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
} else if (look.equals("Windows")) {
plaf = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
}
//LAF umschalten
UIManager.setLookAndFeel(plaf);
SwingUtilities.updateComponentTreeUI(this);
} catch (UnsupportedLookAndFeelException e) {
System.err.println(e.toString());
} catch (ClassNotFoundException e) {
System.err.println(e.toString());
} catch (InstantiationException e) {
System.err.println(e.toString());
} catch (IllegalAccessException e) {
System.err.println(e.toString());
}
}
public void farbdialog(){
Color current = bildanzeige.getForeground();
Color Eigene = JColorChooser.showDialog(
bildanzeige,
"Eigene Vordergrundfarbe",
current
);
bildanzeige.setForeground(Eigene);
}
public void Hfarbdialog() {
Color curren = bildanzeige.getBackground();
Color HEigene = JColorChooser.showDialog(
bildanzeige,
"Eigene Hintergrundfarbe",
curren
);
bildanzeige.setBackground(HEigene);
}
public void JDialog(){
class CFrageDialog extends JDialog implements ActionListener {
private JTextField eingabefeld;
private JButton oK, abbruch;
private String TextEingabe;
// der Konstruktor
CFrageDialog(JFrame f, String titel) {
super(f,titel,true); // Konstruktor der Basisklasse aufrufen
setResizable(false);
setLayout(new BorderLayout());
// es werden 2 Panels angelegt. Das eine enthält das TextField,
// das andere die Buttons
JPanel panel1 = new JPanel();
JLabel label = new JLabel("Ihr Text:");
panel1.add(label);
eingabefeld = new JTextField(50);
JScrollPane EingabeFeld = new javax.swing.JScrollPane();
EingabeFeld.setViewportView(eingabefeld);
add(EingabeFeld);
panel1.add(eingabefeld);
add("Center",panel1);
JPanel panel2 = new JPanel();
oK = new JButton("OK");
abbruch = new JButton("Abbruch");
panel2.add(oK);
panel2.add(abbruch);
add("South",panel2);
pack(); // Anordnung der Oberflächenelemente auf bevorzugte
// Größe initialisieren
// das Maus-Handling für die Buttons macht die Klasse
// selbst, also bei sich selber registrieren
oK.addActionListener(this);
abbruch.addActionListener(this);
// Fenster schließen = Fenster verbergen
setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
}
public void actionPerformed(ActionEvent e) {
String label;
label = e.getActionCommand();
if(label.equals("Abbruch")) {
TextEingabe = null;
setVisible(false);
return;
}
if(label.equals("OK")) {
TextEingabe = eingabefeld.getText();
setVisible(false);
return;
}
} // Ende von 'ActionPerformed'
// Diese Funktion liefert den eingegebenen Suchstring zurück
public String getString() {
return TextEingabe;
}
}
CFrageDialog frage = new CFrageDialog(this,"Ihr Text");
frage.setLocation(150,150);
frage.pack();
frage.setVisible(true);
TextEingabe = frage.getString();
}
public static void main(String[] args){
fenster = new Malprogramm("Malprogramm 3.0");
fenster.setSize(935,680);
fenster.pack();
fenster.setLocation(0,0);
fenster.setVisible(true);
}
class CBildLeinwand extends Panel implements MouseMotionListener, MouseListener {
public static final int RECHTECK = 1;
public static final int OVAL = 2;
public static final int POLIGON = 3;
public static final int RRECHTECK = 4;
public static final int TEXT = 5;
public static final int LINIE = 6;
public static final int FRECHTECK = 7;
public static final int FOVAL = 8;
public static final int FRRECHTECK = 9;
public static final int POLI = 10;
public static final int LÖSCHEN = 11;
Vector Rcolor = new Vector();
Vector Ocolor = new Vector();
Vector Pcolor = new Vector();
Vector RRcolor = new Vector();
Vector Tcolor = new Vector();
Vector Lcolor = new Vector();
Vector FRcolor = new Vector();
Vector FOcolor = new Vector();
Vector FRRcolor = new Vector();
Vector Policolor = new Vector();
Vector löschen = new Vector();
Vector rechteck = new Vector();
Vector oval = new Vector();
Vector poligon = new Vector();
Vector rrechteck = new Vector();
Vector text = new Vector();
Vector linie = new Vector();
Vector Frechteck = new Vector();
Vector Foval = new Vector();
Vector Frrechteck = new Vector();
Vector Poli = new Vector();
int mode;
public void setDrawMode (int mode) {
switch (mode) {
case RECHTECK:
case OVAL:
case POLIGON:
case RRECHTECK:
case TEXT:
case LINIE:
case FRECHTECK:
case FOVAL:
case FRRECHTECK:
case POLI:
case LÖSCHEN:
this.mode = mode;
break;
default:
throw new IllegalArgumentException();
}
}
public void mousePressed (MouseEvent e){
e.consume();
x = 0;
y = 0;
x = e.getX();
y = e.getY();
switch (mode) {
case TEXT:
x = e.getX();
y= e.getY();
repaint();
break;
case POLIGON:
Pcolor.addElement(getForeground());
poligon.addElement(new Rectangle(e.getX(), e.getY()));
int c = e.getX();
int d= e.getY();
repaint();
break;
}
}
public void mouseDragged (MouseEvent e){
e.consume();
int w1,h1;
w1 = 0;
h1 = 0;
w1 = e.getX();
h1 = e.getY();
w = w1 - x;
h = h1 - y;
x2 = w1;
y2 = h1;
switch (mode) {
case LINIE:
w = e.getX();
h = e.getY();
repaint();
break;
case POLI:
Policolor.addElement(getForeground());
Poli.addElement(new Rectangle(e.getX(), e.getY()));
h = e.getX();
w= e.getY();
repaint();
break;
}
repaint();
}
public void mouseReleased (MouseEvent e){
e.consume();
switch(mode) {
case RECHTECK:
Rcolor.addElement(getForeground());
rechteck.addElement(new Rectangle(x, y, w, h));
x2 = -1;
break;
case OVAL:
Ocolor.addElement(getForeground());
oval.addElement(new Rectangle(x, y, w, h));
x2 = -1;
break;
case RRECHTECK:
RRcolor.addElement(getForeground());
rrechteck.addElement(new Rectangle(x, y, w, h));
break;
case TEXT:
Tcolor.addElement(getForeground());
text.addElement(new Rectangle(x, y));
text.addElement(new String(TextEingabe));
break;
case LINIE:
Lcolor.addElement(getForeground());
linie.addElement(new Rectangle(x, y, w, h));
break;
case FRECHTECK:
FRcolor.addElement(getForeground());
Frechteck.addElement(new Rectangle(x, y, w, h));
x2 = -1;
break;
case FOVAL:
FOcolor.addElement(getForeground());
Foval.addElement(new Rectangle(x, y, w, h));
x2 = -1;
break;
case FRRECHTECK:
FRRcolor.addElement(getForeground());
Frrechteck.addElement(new Rectangle(x, y, w, h));
break;
case LÖSCHEN:
löschen.addElement(new Rectangle(x, y, w, h));
break;
}
repaint();
}
public void mouseClicked (MouseEvent e) {
repaint();
}
public void mouseEntered (MouseEvent e){
repaint();
}
public void mouseExited (MouseEvent e){
repaint();
}
public void mouseMoved (MouseEvent e){
}
CBildLeinwand (){
addMouseMotionListener(this);
addMouseListener(this);
}
public void update(Graphics g)
{
//Double-Buffer initialisieren
if (dbImage == null) {
dbImage = createImage(
this.getSize().width,
this.getSize().height
);
dbGraphics = dbImage.getGraphics();
}
//Hintergrund löschen
dbGraphics.setColor(getBackground());
dbGraphics.fillRect(
0,
0,
this.getSize().width,
this.getSize().height
);
//Vordergrund zeichnen
dbGraphics.setColor(getForeground());
paint(dbGraphics);
//Offscreen anzeigen
g.drawImage(dbImage,0,0,this);
}
public void paint(Graphics g) {
if (Fuellen.equals("Füllen")){
booleanFuellen = true;
} else{
booleanFuellen = false;
}
if (booleanFuellen == true) {
if (Label.equals("Oval"))
bildanzeige.setDrawMode(CBildLeinwand.FOVAL);
if (Label.equals("Rechteck"))
bildanzeige.setDrawMode(CBildLeinwand.FRECHTECK);
if (Label.equals("Poligon"))
bildanzeige.setDrawMode(CBildLeinwand.POLIGON);
if (Label.equals("RRechteck"))
bildanzeige.setDrawMode(CBildLeinwand.FRRECHTECK);
if (Label.equals("Text"))
bildanzeige.setDrawMode(CBildLeinwand.TEXT);
if(Label.equals("löschen"))
bildanzeige.setDrawMode(CBildLeinwand.LÖSCHEN);
if (text1 == true){
text1 = false;
JDialog();
}
if (Label.equals("Linie"))
bildanzeige.setDrawMode(CBildLeinwand.LINIE);
if (Label.equals("FreiHand"))
bildanzeige.setDrawMode(CBildLeinwand.POLI);
}else if(booleanFuellen == false){
if (Label.equals("Oval"))
bildanzeige.setDrawMode(CBildLeinwand.OVAL);
if (Label.equals("Rechteck"))
bildanzeige.setDrawMode(CBildLeinwand.RECHTECK);
if (Label.equals("Poligon"))
bildanzeige.setDrawMode(CBildLeinwand.POLIGON);
if (Label.equals("RRechteck"))
bildanzeige.setDrawMode(CBildLeinwand.RRECHTECK);
if (Label.equals("Text"))
bildanzeige.setDrawMode(CBildLeinwand.TEXT);
if(Label.equals("löschen"))
bildanzeige.setDrawMode(CBildLeinwand.LÖSCHEN);
if (text1 == true){
text1 = false;
JDialog();
}
if (Label.equals("Linie"))
bildanzeige.setDrawMode(CBildLeinwand.LINIE);
if (Label.equals("FreiHand"))
bildanzeige.setDrawMode(CBildLeinwand.POLI);
}
int re = rechteck.size();
int ov = oval.size();
int po = poligon.size();
int rre= rrechteck.size();
int te = text.size();
int li = linie.size();
int fre = Frechteck.size();
int fov = Foval.size();
int frre= Frrechteck.size();
int pol = Poli.size();
int lö = löschen.size();
g.setColor(getForeground());
for (int i=0; i < re; i++) {
Rectangle p = (Rectangle)rechteck.elementAt(i);
g.setColor((Color)Rcolor.elementAt(i));
g.drawRect(p.x, p.y, p.width, p.height);
}
if (mode == RECHTECK) {
g.setColor(getForeground());
if (x2 != -1) {
g.drawRect(x, y, w, h);
}
}
for (int i=0;i<lö;i++){
Rectangle p = (Rectangle)löschen.elementAt(i);
g.clearRect(p.x,p.y,p.width, p.height);
}
if (mode== LÖSCHEN){
g.clearRect(x,y,w,h);
}
for (int i=0; i < ov; i++) {
Rectangle p = (Rectangle)oval.elementAt(i);
g.setColor((Color)Ocolor.elementAt(i));
g.drawOval(p.x, p.y, p.width, p.height);
}
if (mode == OVAL) {
g.setColor(getForeground());
if (x2 != -1) {
g.drawOval(x, y, w, h);
}
}
for (int i=0; i < rre; i++) {
Rectangle p = (Rectangle)rrechteck.elementAt(i);
g.setColor((Color)RRcolor.elementAt(i));
g.drawRoundRect(p.x, p.y, p.width, p.height, rx, ry);
}
if (mode == RRECHTECK) {
g.setColor(getForeground());
if (x2 != -1) {
g.drawRoundRect(x, y, w, h ,ry ,ry);
}
}
for (int i=0; i < li; i++) {
Rectangle p = (Rectangle)linie.elementAt(i);
g.setColor((Color)Lcolor.elementAt(i));
g.drawLine(p.x, p.y, p.width, p.height);
}
if (mode == LINIE) {
g.setColor(getForeground());
if (x2 != -1) {
g.drawLine(x, y, w, h);
}
}
for (int i=0; i < fre; i++) {
Rectangle p = (Rectangle)Frechteck.elementAt(i);
g.setColor((Color)FRcolor.elementAt(i));
g.fillRect(p.x, p.y, p.width, p.height);
}
if (mode == FRECHTECK) {
g.setColor(getForeground());
if (x2 != -1) {
g.fillRect(x, y, w, h);
}
}
for (int i=0; i < fov; i++) {
Rectangle p = (Rectangle)Foval.elementAt(i);
g.setColor((Color)FOcolor.elementAt(i));
g.fillOval(p.x, p.y, p.width, p.height);
}
if (mode == FOVAL) {
g.setColor(getForeground());
if (x2 != -1) {
g.fillOval(x, y, w, h);
}
}
for (int i=0; i < frre; i++) {
Rectangle p = (Rectangle)Frrechteck.elementAt(i);
g.setColor((Color)FRRcolor.elementAt(i));
g.fillRoundRect(p.x, p.y, p.width, p.height, rx, ry);
}
if (mode == FRRECHTECK) {
g.setColor(getForeground());
if (x2 != -1) {
g.fillRoundRect(x, y, w, h ,ry ,ry);
}
}
String[] TextEingabe1 = new String[te];
for (int i=0; i < te; i++) {
Rectangle p = (Rectangle)text.elementAt(i);
String w = (String)text.elementAt(i);
g.setColor((Color)Tcolor.elementAt(i));
TextEingabe1[te] = TextEingabe;
g.drawString(TextEingabe1[te], p.x ,p.y);
}
if (mode == TEXT) {
g.setColor(getForeground());
if (x2 != -1) {
g.drawString(TextEingabe, x, y);
}
}
int[] Array = new int[po];
int d[] = new int[po];
int r[] = new int[po];
int e[] = new int[po];
for(int q=0; q<po;q++){
r[q] = x;
e[q] = y;
}
for (int i=0; i < po; i++) {
Rectangle p = (Rectangle)poligon.elementAt(i);
g.setColor((Color)Pcolor.elementAt(i));
for(int q=0; q<po;q++){
Array[q] = p.width;
d[q] = p.height;
g.drawPolygon(Array, d,po);
}
}
if (mode == POLIGON) {
g.setColor(getForeground());
g.drawPolygon(r, e,po);
}
int[] x = new int[pol];
int[] y = new int[pol];
for (int i=0; i < pol; i++) {
Rectangle p = (Rectangle)Poli.elementAt(i);
g.setColor((Color)Policolor.elementAt(i));
for(int q=0; q<pol; q++){
x[q] = p.width;
y[q] = p.height;
g.drawPolyline(x,y,pol);
}
}
if (mode == POLI) {
g.setColor(getForeground());
if (x2 != -1) {
g.drawPolyline(x, y,pol);
}
}
}
class CZeitThread extends Thread {
public void run() {
bildanzeige.repaint();
// kurze Zeit schlafen
try {
sleep(2);
}
catch(InterruptedException e) {
return;
}
}
}
public Dimension getMinimumSize() {
return fenster.getSize();
}
public Dimension getPreferredSize() {
return getMinimumSize();
}
}
}
hoffe, dass nicht alles um sonst war
Jetzt schon mal danke für's helfen