# Kohlenschichtwiderstände



## Lls27 (20. Mai 2012)

Hallo,

ich bin grad an einem Kohleschichtwiderstandberechner und mir wurde schon mal geholfen. Da ich wieder nicht weiter weiß hoffe ich nochmal hier Hilfe zu bekommen. Das Progamm sollte etwa so aussehen:
Resistor Colour Code


```
import java.awt.Borderlayout;
import java.awt.event.ItemListener;
import java.awt.choice;
import java.awt.color;
import java.awt.flowlayout;
import java.awt.Graphics;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.BorderFactory;
import javax.swing.Jframe;
import javax.swing.Jlabel;
import javax.swing.Jpanel;

Public class Resistor
{
    Jframe j frame;
    choice ch1;
    choice ch2;
    choice ch3;
    choice ch4;
    JLabel1 resistorImg;
    JLabel1 resistorImg1;
    JLabel1 display1;
    JLabel1 display2;
    JLabel1 display3;
    JLabel1 display4;
    JLabel1 result;
    
    Color black;
    Color brown;
    Color orange;
    Color yellow;
    Color green;
    Color blue;
    Color violet;
    Color gray;
    Color white;
    
    public static void main(string[] args)
    {
        new Resistor.frame();
    }
    
    void frame()
    {
        Jpanel1 panel1 = newJpanel();
        Jpanel1 panel2 = newJpanel();
        Jpanel1 panel3 = newJpanel();
        
        jframe = new Jframe();
        jframe.setTitle("Resistor code");
        jframe.setSize(400, 300);
        jframe.setLocation(300,200);
        jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        
        
        l1 = new Jlabel {"  Resistor Color Code Application"};
       
       display1 = new Jlabel("-");
       display2 = new Jlabel("-");
       display3 = new Jlabel("-");
       display4 = new Jlabel("-");
       
       ch1 = new Choice();
       ch2 = new Choice();
       ch3 = new Choice();
       ch4 = new Choice();
       
       black = new color(0,0,0);
       brown = new color(108,59,14);
       red = new color (255,0,0);
       orange = new color(241,180,25);
       yellow = new color (251,251,17);
       blue = new color(0,0,250);
       violet = new color (218,16,252);
       gray = new color (150,150,150);
       white = new color(255,255,255);
       green = new color(0,255,0);
       
       final myDraw mdraw = new myDraw();
       
       string[] strl = new string[10];
       
       strl[0]= "black";
       strl[1]= "brown";
       strl[2]= "red";
       strl[3]= "orange";
       strl[4]= "yellow";
       strl[5]= "green";
       strl[6]= "blue";
       strl[7]= "violet";
       strl[8]= "gray";
       strl[9]= "white";
       
       for(int i=0; i <strl.lenght; i++)
       {ch1. insert(strl[i], i);       
       }
       
       ch1.addItemListener( new ItemListener()
       
       {
        public void itemStateChanged(ItemEvent arg0)
        {
            int select;
            select = ch1.getselectedIndex();
            switch(select)
            {
                case0: display1.setText("");
                ch1.setBackground(black);
                mdraw.setColor1(black);
            break;
                case1: display1.setText("1");
                ch1.setBackground(brown);
                mdraw.setColor1(brown);
            break;
                case2: display1.setText("2");
                ch1.setBackground(red);
                mdraw.setColor1(red);
            break;
                case3: display1.setText("3");
                ch1.setBackground(orange);
                mdraw.setColor1(orange);
            break;
                case4: display1.setText("4");
                ch1.setBackground(yellow);
                mdraw.setColor1(yellow);
            break;
                case5: display1.setText("5");
                ch1.setBackground(green);
                mdraw.setColor1(green);
            break;
                case6: display1.setText("6");
                ch1.setBackground(blue);
                mdraw.setColor1(blue);
            break;
                 case7: display1.setText("7");
                ch1.setBackground(violet);
                mdraw.setColor1(violet);
            break;
                case8: display1.setText("8");
                ch1.setBackground(gray);
                mdraw.setColor1(gray);
            break;
                case9: display1.setText("9");
                ch1.setBackground(white);
                mdraw.setColor1(white);
            break;
        default:
        mdraw.setcolor3(black);
        break;
            }
        }}};
        
    string[] str2 = new string[10];
    str2[0]= "black";
    str2[1]= "brown";
    str2[2]= "red";
    str2[3]= "orange";
    str2[4]= "yellow";
    str2[5]= "green";
    str2[6]= "blue";
    str2[7]= "violet";
    str2[8]= "gray";
    str2[9]= "white";
    
    for(int x=0; x< str2.lenght; x++)
    {
        ch2.insert{
            str2[x], x);
        }
        ch2.addItemListener( new ItemListener(){
        public void itemStateChange(itemEvent argo){
            
            int select;
            select = ch2.getSelectedIndex();
            
            switch(select)
            {
                case 0: display2.setText("0");
                ch2.setBackground(black);
                mdraw.setcolor2(black);
                break;
                 case 1: display2.setText("1");
                ch2.setBackground(brown);
                mdraw.setcolor2(brown);
                break;
                case 2: display2.setText("2");
                ch2.setBackground(red);
                mdraw.setcolor2(red);
                break;
                case 3: display2.setText("3");
                ch2.setBackground(orange);
                mdraw.setcolor2(orange);
                break;
             case 4: display2.setText("4");
                ch2.setBackground(yellow);
                mdraw.setcolor2(yellow);
                break;
             case 5: display2.setText("5");
                ch2.setBackground(green);
                mdraw.setcolor2(green);
                break;
            case 6: display2.setText("6");
                ch2.setBackground(blue);
                mdraw.setcolor2(blue);
                break;
             case 7: display2.setText("7");
                ch2.setBackground(violet);
                mdraw.setcolor2(violet);
                break;
            case 8: display2.setText("8");
                ch2.setBackground(gray);
                mdraw.setcolor2(gray);
                break;
            case 9: display2.setText("9");
                mdraw.setcolor2(white);
                break;
            }
        }}};
    
    string[] str3 = new string[10];
    
    str3[0]= "black";
    str3[1]= "brown";
    str3[2]= "red";
    str3[3]= "orange";
    str3[4]= "yellow";
    str3[5]= "green";
    str3[6]= "blue";
    str3[7]= "violet";
    str3[8]= "gray";
    str3[9]= "white";
    
    for(int x=0; x< str3[x], 
);
}

ch3.addItenListener(new ItemListener()(
    public void itemStateChanged(ItemEvent arg0)
    {
        int select;
            select = ch3.getSelectedIndex();
            
            switch(select)
            {
                case 0: display2.setText("-");
                ch2.setBackground(black);
                mdraw.setcolor2(black);
                break;
                 case 1: display2.setText("1");
                ch2.setBackground(brown);
                mdraw.setcolor2(brown);
                break;
                case 2: display2.setText("2");
                ch2.setBackground(red);
                mdraw.setcolor2(red);
                break;
                case 3: display2.setText("3");
                ch2.setBackground(orange);
                mdraw.setcolor2(orange);
                break;
             case 3: display2.setText("3");
                ch2.setBackground(orange);
                mdraw.setcolor2(orange);
                break;
             case 4: display2.setText("4");
                ch2.setBackground(yellow);
                mdraw.setcolor2(yellow);
                break;
             case 5: display2.setText("5");
                ch2.setBackground(green);
                mdraw.setcolor2(green);
                break;
            case 6: display2.setText("6");
                ch2.setBackground(blue);
                mdraw.setcolor2(blue);
                break;
             case 7: display2.setText("7");
                ch2.setBackground(violet);
                mdraw.setcolor2(violet);
                break;
            case 8: display2.setText("8");
                ch2.setBackground(gray);
                mdraw.setcolor2(gray);
                break;
            case 9: display2.setText("9");
                mdraw.setcolor2(white);
                break;
            }
    }}};
            string[] str4 = new string[10];
            str4[0]= "Black";
              str3[0]= "black";
    str3[1]= "brown";
    str3[2]= "red";
    str3[3]= "orange";
    str3[4]= "yellow";
    str3[5]= "green";
    str3[6]= "blue";
    str3[7]= "violet";
    str3[8]= "gray";
    str3[9]= "white";
    
    for(int x=0; x< str4.length; x++)
    {
        ch4.insert(str4[x], x);
    }
}
    Ch4.addItemListener(new itemListener(){
        public void itemStateChanged(ItemEvent arg0)
    {
        int select;
            select = ch4.getSelectedIndex();
            
            switch(select)
            {
                case 0: display2.setText("oomuint");
                ch2.setBackground(black);
                mdraw.setcolor2(black);
                break;
                 case 1: display2.setText("0oomuint");
                ch2.setBackground(brown);
                mdraw.setcolor2(brown);
                break;
                case 2: display2.setText("koomuint");
                ch2.setBackground(red);
                mdraw.setcolor2(red);
                break;
                case 3: display2.setText("okoomuint");
                ch2.setBackground(orange);
                mdraw.setcolor2(orange);
                break;
             case 3: display2.setText("00koomunit");
                ch2.setBackground(orange);
                mdraw.setcolor2(orange);
                break;
             case 4: display2.setText("Moommunit");
                ch2.setBackground(yellow);
                mdraw.setcolor2(yellow);
                break;
             case 5: display2.setText("0oomunnit");
                ch2.setBackground(green);
                mdraw.setcolor2(green);
                break;
            case 6: display2.setText("moomuint");
                ch2.setBackground(blue);
                mdraw.setcolor2(blue);
                break;
             case 7: display2.setText("omunit");
                ch2.setBackground(violet);
                mdraw.setcolor2(violet);
                break;
            case 8: display2.setText("-");
                ch2.setBackground(gray);
                mdraw.setcolor2(gray);
                break;
            case 9: display2.setText("-");
                mdraw.setcolor2(white);
                break;
            }
    }}};
    panel1.setBackground(color.white);
    panel2.setBackground(color.white);
    panel3.setBackground(color.white);
    
    panel1.setBorder(borderFactory.createLowerdbevelborder()};
    panel3.setBorder(borderFactory.createLowerdbevelborder()};
    
    panel1.setLayOUT( NEW bORDERlAYOUT());
    panel1.add( (new BorderLayout().NORTh,11);
               
    panel12.setLayout(new flowLayout());
    panel12.add(ch1);
    panel12.add(ch2);
    
    panel12.setLayout( new FlowLayout());
    panel12.add(ch1);
    panel12.add(ch2);
    panel12.add(ch3);
    panel12.add(ch4);
    
    panel1.add((new BorderLayout().south, panel12);
               
    panel13.add((new BorderLayout().center, display1);
    panel13.add((new BorderLayout().center, display2);
    panel13.add((new BorderLayout().center, display3);
    panel13.add((new BorderLayout().center, display4);
    
    jframe.getcontentpane().add( new BorderLayout().north, panel1);
     jframe.getcontentpane().add( new BorderLayout().center, panel1);
     jframe.getcontentpane().add( new BorderLayout().south, panel1);
     
     jframe.setBackground(Color.white);
     jframe.setvisible(true);
     }
     }
     
     class myDraw extends Jpanel{
        private color color1;
           private color color2;
               private color color3;
                   private color color4;
                   
    public void paintcomponent(Graphics g)
    {
        g.setColor(color.white);
        g.fillrect(0,0, this.getwidth(),this.getHeight());
        
        this.repaint();
        
        g.setColor(color.LIGHT_GRAY);
        g.fillRoundRect(this.getWidth()/2-75, this.getHeight()/2-40, 150, 80, 20, 20);
        g.fillRoundRect(this.getWidth()/2-90, this.getHeight()/2-50, 90, 100, 15, 15);
        g.fillRoundRect(this.getWidth()/2+65, this.getHeight()/2-50, 30, 100, 15, 15);
        
        g.getColor(color1));
    g.fillRoundRect(this.getwIDTH()/2-25, THIS.GetHeight()/2-40,10,80, 10, 10);
         g.getColor(color2));
    g.fillRoundRect(this.getwIDTH()/2-20, THIS.GetHeight()/2-40,10,80, 10, 10);
    
         g.getColor(color3));
    g.fillRoundRect(this.getwIDTH()/2+18, THIS.GetHeight()/2-40,10,80, 10, 10);
         g.getColor(color4));
    g.fillRoundRect(this.getwIDTH()/2+45, THIS.GetHeight()/2-40,10,80, 10, 10);
    
    g.setColor(color.black);
    g.fillDrect(this.getwidth()/2-145, this.getHeight()/ 2,55,5, true);
     g.fillDrect(this.getwidth()/2+95, this.getHeight()/ 2,55,5, false);
      g.fillDrect(this.getwidth()/2+145, this.getHeight()/ 2,5,50, false);
       g.fillDrect(this.getwidth()/2-145, this.getHeight()/ 2,5,50, true);
     
     }
```

Soweit erst. Nun muss das GUI erstellt und gestartet werden , doch da weiß ich nicht mehr weiter.
Muss auch zugeben, dass ich mir teilweise Hilfe geholt habe, wie im letzten Teil  .
Die Werte stimmen noch net ganz, aber mir gehts erstmal um den vorhingenannten Punkt


----------



## XHelp (20. Mai 2012)

a) Falsches Forum, da hier fertige Projekte vorgestellt werden
b) Wo ist deine Frage?


----------



## Lls27 (20. Mai 2012)

Oh, mein Fehler
In welchem Forums müsste es rein?

PS: Frage ist, was fehlen würde


----------



## XHelp (20. Mai 2012)

Ein Mod wird das schon selber verschieben, brauchst nicht noch mal posten.

Was fehlen würde wofür? Stell eine konkrete Frage, die man auch konkret beantworten kann.


----------



## Lls27 (20. Mai 2012)

Das Programm startet nicht.
Und meine Frage ist, warum das Programm nicht startet.


----------



## Final_Striker (20. Mai 2012)

Lls27 hat gesagt.:


> PS: Frage ist, was fehlen würde



Ähm...

Wo hast du das her?

Im dem Code sind soviele Fehler drin wie das Ding Zeilen hat.
Die Bezeichnung der Klassen stimmt ja hinten und vorne nicht.
Java ist CaseSentitive, dass bedeutet das man auf Groß-/Kleinschreibung achten muss.

EDIT:



> Das Programm startet nicht.
> Und meine Frage ist, warum das Programm nicht startet.



Weil da gefühlte tausend Fehler drin sind?!


----------



## Lls27 (20. Mai 2012)

also gehts jetzt erstmal um die Groß-und Kleinschreibung?


----------



## Final_Striker (20. Mai 2012)

Ich denke, es wäre schon mal sinnvoll die Klassennamen richtig zu schreiben, wenn du das Programm ausführen willst.


----------



## XHelp (20. Mai 2012)

Dir werden ja vom Compiler Fehler angezeigt: "Zeile XY Fehler Z". Schau einfach was diese Fehler bedeuten.
Und "startet nicht" ist immer noch keine Problembeschreibung. Wenn du Fehler angezeigt bekommst, dann nenne diese auch. Wenn dazu eine Zeilennummer gibt, dann nenne diese auch. etc etc


----------



## Lls27 (20. Mai 2012)

Hab teilweise schon korrigert,
doch manchml verändert sich die ganze Struktur des Programms :/


----------



## Lls27 (20. Mai 2012)

So hab das mal überarbeitet


```
import java.awt.BorderLayout;
import java.awt.Choice;
import java.awt.Color;
import java.awt.event.ItemListener;
import java.awt.choice;

import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class Resistor
{
    JFrame j frame;
    Choice ch1;
    Choice ch2;
    Choice ch3;
    Choice ch4;
    JLabel1 resistorImg;
    JLabel1 resistorImg1;
    JLabel1 display1;
    JLabel1 display2;
    JLabel1 display3;
    JLabel1 display4;
    JLabel1 result;
    
    Color black;
    Color brown;
    Color orange;
    Color yellow;
    Color green;
    Color blue;
    Color violet;
    Color gray;
    Color white;
    Color red;
    
    public static void main(String[] args)
    {
        new Resistor.frame();
    }
    
    void frame()
    {
        JPanel panel1 = newJpanel();
        JPanel panel2 = newJpanel();
        JPanel panel3 = newJpanel();
        
        JFrame = new Jframe();
        JFrame.setTitle("Resistor code");
        JFrame.setSize(400, 300);
        JFrame.setLocation(300,200);
        JFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        
        
        l1 = new Jlabel {"  Resistor Color Code Application"};
       
       display1 = new Jlabel("-");
       display2 = new Jlabel("-");
       display3 = new Jlabel("-");
       display4 = new Jlabel("-");
       
       ch1 = new Choice();
       ch2 = new Choice();
       ch3 = new Choice();
       ch4 = new Choice();
       
       black = new Color(0,0,0);
       brown = new Color(108,59,14);
       red = new Color (255,0,0);
       orange = new Color(241,180,25);
       yellow = new Color (251,251,17);
       blue = new Color(0,0,250);
       violet = new Color (218,16,252);
       gray = new Color (150,150,150);
       white = new Color(255,255,255);
       green = new Color(0,255,0);
       
       final myDraw myDraw = new myDraw();
       
       String[] strl = new String[10];
       
       strl[0]= "black";
       strl[1]= "brown";
       strl[2]= "red";
       strl[3]= "orange";
       strl[4]= "yellow";
       strl[5]= "green";
       strl[6]= "blue";
       strl[7]= "violet";
       strl[8]= "gray";
       strl[9]= "white";
       
       for(int i=0; i <strl.length; i++)
       {ch1. insert(strl[i], i);       
       }
       
       ch1.addItemListener( new ItemListener()
       
       {
        public void itemStateChanged(ItemEvent arg0)
        {
            int select;
            select = ch1.getSelectedIndex();
            switch(select)
            {{
                case0: display1.setText("");
                ch1.setBackground(black);
                myDraw.setColor1(black);
            break;
                case1: display1.setText("1");
                ch1.setBackground(brown);
                myDraw.setColor1(brown);
            break;
                case2: display1.setText("2");
                ch1.setBackground(red);
                myDraw.setColor1(red);
            break;
                case3: display1.setText("3");
                ch1.setBackground(orange);
                myDraw.setColor1(orange);
            break;
                case4: display1.setText("4");
                ch1.setBackground(yellow);
                myDraw.setColor1(yellow);
            break;
                case5: display1.setText("5");
                ch1.setBackground(green);
                myDraw.setColor1(green);
            break;
                case6: display1.setText("6");
                ch1.setBackground(blue);
                myDraw.setColor1(blue);
            break;
                 case7: display1.setText("7");
                ch1.setBackground(violet);
                myDraw.setColor1(violet);
            break;
                case8: display1.setText("8");
                ch1.setBackground(gray);
                myDraw.setColor1(gray);
            break;
                case9: display1.setText("9");
                ch1.setBackground(white);
                myDraw.setColor1(white);
            break;
        default:
        myDraw.setcolor3(black);
        break;
            }
        }}};
        
    private JPanel newJpanel() {
		// TODO Auto-generated method stub
		return null;
	}

	String[] str2 = new String[10];
    str2[0]= "black";
    str2[1]= "brown";
    str2[2]= "red";
    str2[3]= "orange";
    str2[4]= "yellow";
    str2[5]= "green";
    str2[6]= "blue";
    str2[7]= "violet";
    str2[8]= "gray";
    str2[9]= "white";
    
    for(int x=0; x< str2.lenght; x++)
    {
        ch2.insert{
            str2[x], x);
        }
        ch2.addItemListener( new ItemListener(){
        public void itemStateChange(ItemEvent argo){
            
            int select;
            select = ch2.getSelectedIndex();
            
            switch(select)
            {
                case 0: display2.setText("0");
                ch2.setBackground(black);
                myDraw.setcolor2(black);
                break;
                 case 1: display2.setText("1");
                ch2.setBackground(brown);
                myDraw.setcolor2(brown);
                break;
                case 2: display2.setText("2");
                ch2.setBackground(red);
                myDraw.setcolor2(red);
                break;
                case 3: display2.setText("3");
                ch2.setBackground(orange);
                myDraw.setcolor2(orange);
                break;
             case 4: display2.setText("4");
                ch2.setBackground(yellow);
                myDraw.setcolor2(yellow);
                break;
             case 5: display2.setText("5");
                ch2.setBackground(green);
                myDraw.setcolor2(green);
                break;
            case 6: display2.setText("6");
                ch2.setBackground(blue);
                myDraw.setcolor2(blue);
                break;
             case 7: display2.setText("7");
                ch2.setBackground(violet);
                myDraw.setcolor2(violet);
                break;
            case 8: display2.setText("8");
                ch2.setBackground(gray);
                myDraw.setcolor2(gray);
                break;
            case 9: display2.setText("9");
                myDraw.setcolor2(white);
                break;
            }
        }

		@Override
		public void itemStateChanged(ItemEvent e) {
			// TODO Auto-generated method stub
			
		}}};
    
    String[] str3 = new String[10];
    
    str3[0]= "black";
    str3[1]= "brown";
    str3[2]= "red";
    str3[3]= "orange";
    str3[4]= "yellow";
    str3[5]= "green";
    str3[6]= "blue";
    str3[7]= "violet";
    str3[8]= "gray";
    str3[9]= "white";
    
    for(int x=0; x< str3[x], 
);


ch3.addItenListener(new ItemListener()(
    public void itemStateChanged(ItemEvent arg0)
    {
        int select;
            select = ch3.getSelectedIndex();
            
            switch(select)
            {
                case 0: display2.setText("-");
                ch2.setBackground(black);
                myDraw.setcolor2(black);
                break;
                 case 1: display2.setText("1");
                ch2.setBackground(brown);
                myDraw.setcolor2(brown);
                break;
                case 2: display2.setText("2");
                ch2.setBackground(red);
                myDraw.setcolor2(red);
                break;
                case 3: display2.setText("3");
                ch2.setBackground(orange);
                myDraw.setcolor2(orange);
                break;
             case 3: display2.setText("3");
                ch2.setBackground(orange);
                myDraw.setcolor2(orange);
                break;
             case 4: display2.setText("4");
                ch2.setBackground(yellow);
                myDraw.setcolor2(yellow);
                break;
             case 5: display2.setText("5");
                ch2.setBackground(green);
                myDraw.setcolor2(green);
                break;
            case 6: display2.setText("6");
                ch2.setBackground(blue);
                myDraw.setcolor2(blue);
                break;
             case 7: display2.setText("7");
                ch2.setBackground(violet);
                myDraw.setcolor2(violet);
                break;
            case 8: display2.setText("8");
                ch2.setBackground(gray);
                myDraw.setcolor2(gray);
                break;
            case 9: display2.setText("9");
                myDraw.setcolor2(white);
                break;
            }
    }}};
            string[] str4 = new string[10];
            str4[0]= "Black";
              str3[0]= "black";
    str3[1]= "brown";
    str3[2]= "red";
    str3[3]= "orange";
    str3[4]= "yellow";
    str3[5]= "green";
    str3[6]= "blue";
    str3[7]= "violet";
    str3[8]= "gray";
    str3[9]= "white";
    
    for(int x=0; x< str4.length; x++)
    {
        ch4.insert(str4[x], x);
    }
}
    Ch4.addItemListener(new itemListener(){
        public void itemStateChanged(ItemEvent arg0)
    {
        int select;
            select = ch4.getSelectedIndex();
            
            switch(select)
            {
                case 0: display2.setText("oomuint");
                ch2.setBackground(black);
                myDraw.setcolor2(black);
                break;
                 case 1: display2.setText("0oomuint");
                ch2.setBackground(brown);
                myDraw.setcolor2(brown);
                break;
                case 2: display2.setText("koomuint");
                ch2.setBackground(red);
                myDraw.setcolor2(red);
                break;
                case 3: display2.setText("okoomuint");
                ch2.setBackground(orange);
                myDraw.setcolor2(orange);
                break;
             case 3: display2.setText("00koomunit");
                ch2.setBackground(orange);
                myDraw.setcolor2(orange);
                break;
             case 4: display2.setText("Moommunit");
                ch2.setBackground(yellow);
                myDraw.setcolor2(yellow);
                break;
             case 5: display2.setText("0oomunnit");
                ch2.setBackground(green);
                myDraw.setcolor2(green);
                break;
            case 6: display2.setText("moomuint");
                ch2.setBackground(blue);
                myDraw.setcolor2(blue);
                break;
             case 7: display2.setText("omunit");
                ch2.setBackground(violet);
                myDraw.setcolor2(violet);
                break;
            case 8: display2.setText("-");
                ch2.setBackground(gray);
                myDraw.setcolor2(gray);
                break;
            case 9: display2.setText("-");
                myDraw.setcolor2(white);
                break;
            }
    }}};
    panel1.setBackground(color.white);
    panel2.setBackground(color.white);
    panel3.setBackground(color.white);
    
    panel1.setBorder(borderFactory.createLowerdbevelborder()};
    panel3.setBorder(borderFactory.createLowerdbevelborder()};
    
    panel1.setLayOUT( New Borderlayout());
    panel1.add( (new BorderLayout().NORTH,11);
               
    panel12.setLayout(new flowLayout());
    panel12.add(ch1);
    panel12.add(ch2);
    
    panel12.setLayout( new FlowLayout());
    panel12.add(ch1);
    panel12.add(ch2);
    panel12.add(ch3);
    panel12.add(ch4);
    
    panel1.add((new BorderLayout().SOUTH, panel12);
               
    panel13.add((new BorderLayout().CENTER, display1);
    panel13.add((new BorderLayout().CENTER, display2);
    panel13.add((new BorderLayout().CENTER, display3);
    panel13.add((new BorderLayout().CENTER, display4);
    
    jframe.getcontentpane().add( new BorderLayout().NORTH, panel1);
     jframe.getcontentpane().add( new BorderLayout().CENTER, panel1);
     jframe.getcontentpane().add( new BorderLayout().SOUTH, panel1);
     
     jframe.setBackground(Color.white);
     jframe.setvisible(true);
     }
     }
     
     class myDraw extends JPanel{
        private Color color1;
           private Color color2;
               private Color color3;
                   private Color color4;
                   
    public void paintcomponent(Graphics g)
    {
        g.setColor(color.white);
        g.fillrect(0,0, this.getwidth(),this.getHeight());
        
        this.repaint();
        
        g.setColor(color.LIGHT_GRAY);
        g.fillRoundRect(this.getWidth()/2-75, this.getHeight()/2-40, 150, 80, 20, 20);
        g.fillRoundRect(this.getWidth()/2-90, this.getHeight()/2-50, 90, 100, 15, 15);
        g.fillRoundRect(this.getWidth()/2+65, this.getHeight()/2-50, 30, 100, 15, 15);
        
        g.getColor(color1));
    g.fillRoundRect(this.getwIDTH()/2-25, THIS.GetHeight()/2-40,10,80, 10, 10);
         g.getColor(color2));
    g.fillRoundRect(this.getwIDTH()/2-20, THIS.GetHeight()/2-40,10,80, 10, 10);
    
         g.getColor(color3));
    g.fillRoundRect(this.getwIDTH()/2+18, THIS.GetHeight()/2-40,10,80, 10, 10);
         g.getColor(color4));
    g.fillRoundRect(this.getwIDTH()/2+45, THIS.GetHeight()/2-40,10,80, 10, 10);
    
    g.setColor(color.black);
    g.fillDrect(this.getwidth()/2-145, this.getHeight()/ 2,55,5, true);
     g.fillDrect(this.getwidth()/2+95, this.getHeight()/ 2,55,5, false);
      g.fillDrect(this.getwidth()/2+145, this.getHeight()/ 2,5,50, false);
       g.fillDrect(this.getwidth()/2-145, this.getHeight()/ 2,5,50, true);
     
     }
```

So, sind aber immer noch genügend Fehler drinnen, hängt wohl mit der beschreibung der panels und displays zsm.?


----------



## Deros (20. Mai 2012)

du scheinst noch nichtmal zu wissen wie man eine variable deklariert....also so ist der code echt unbrauchbar

ein variablenname darf kein leerzeichen enthalten
was ist JLabel1?
um mal ein paar beispiele zu sagen


----------



## Lls27 (20. Mai 2012)

das mit dem JLabel1 hab ich übersehen,
inweifern ist der noch brauchbar?


----------



## XHelp (20. Mai 2012)

Lls27 hat gesagt.:


> inweifern ist der noch brauchbar?


Naja, du scheinst irgendwas auf der Tastatur eingegeben zu haben in der Hoffnung, dass daraus vlt ein Programm entsteht: "JFrame j frame;", "new Resistor.frame();", "l1 = new Jlabel {"  Resistor Color Code Application"};", "case0:", "THIS.GetHeight()" etc etc etc.
Dadurch lässt sich eine Vermutung aufstellen, dass dir sämtliche Grundlagen fehlen, die du selber nachholen musst.
An dem bestehendem Code Kleinigkeiten verändern, damit es läuft, ist einfach nicht möglich, da die Kleinigkeiten zu groß sind.


----------



## Lls27 (20. Mai 2012)

Hm

Also ich hab mal hier gefragt und hab dieses Programm bekommen:


```
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import java.util.*;
import java.text.SimpleDateFormat;
 
public class ComboBoxIASB extends JFrame
{
    
    private JPanel contentPane;
    private JPanel panel;
    
    /**
     * Launch the application.
     */
    public static void main(String[] args)
    {
        EventQueue.invokeLater(new Runnable()
            {
                public void run()
                {
                    try
                    {
                        ComboBoxIASB frame = new ComboBoxIASB();
                        frame.setVisible(true);
                    } catch (Exception e)
                    {
                        e.printStackTrace();
                    }
                }
            });
    }
    
    /**
     * Create the frame.
     */
    public ComboBoxIASB()
    {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setBounds(100, 100, 450, 300);
        contentPane = new JPanel();
        contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
        contentPane.setLayout(new BorderLayout(0, 0));
        setContentPane(contentPane);
        
        JComboBox<Widerstand> comboBox = new JComboBox<Widerstand>();
        for(Widerstand w:Widerstand.values())
        {
            comboBox.addItem(w);
        }
        comboBox.addItemListener(new ItemListener(){
 
            @Override
            public void itemStateChanged(ItemEvent e)
            {
                if(e.getStateChange()==ItemEvent.SELECTED)
                {
                    Widerstand w=(Widerstand)e.getItem();
                    panel.setBackground(new Color(w.farbe));
                }
                
            }
            
        });
        contentPane.add(comboBox, BorderLayout.NORTH);
        
        panel = new JPanel();
        contentPane.add(panel, BorderLayout.SOUTH);
    }
    
    enum Widerstand
    {
      SCHWARZ("schwarz",0,0,-1,-1,0x0),
      BRAUN("braun",1, 1, 10, 1, 0x552020),
      ROSA("rot",99,99,99,99,0xFF0000);
      
    public final int farbe,ring1,ring2,ring3,ring4;
    public final String name;
     
    private Widerstand(String label,int r1,int r2, int r3, int r4, int f)
    {
      this.name=label;
      ring1=r1;
      ring2=r2;
      ring3=r3;
      ring4=r4;
      farbe=f;
    }
    @Override
    public String toString()
    {
    return name;
    }
    }
    
}
```

Ist diese Methode sinnvoller?


----------



## Marcinek (20. Mai 2012)

Frag doch den, der es gemacht hat?

Oder einfach starten...

Oder mal anfangen ein Buch zu lesen. Per raten wird das nix.


----------



## Lls27 (20. Mai 2012)

Buch schon gelesen.
Schon gestartet.
Aber ich werde einfach mal fragen.


----------

