Snippets

Ettar Java Fabrik GUI

Created by Ettar last modified
import javax.swing.*;

public class abhaengigkeit extends JPanel{
    public abhaengigkeit(){
        setLayout(new BoxLayout(this,BoxLayout.Y_AXIS));
        JLabel lblTest = new JLabel("Test");
        setSize((800/3)-10,50);
        add(lblTest);
    }
}
import javax.swing.*;

public class erzeugnis extends JPanel{
    public erzeugnis(String name, Double herstellungskosten, double verkaufswert){
        setSize((800/3)-10,50);
        setLayout(new BoxLayout(this,BoxLayout.Y_AXIS));
        String tmp;
        tmp = "Name: " + name;
        JLabel lblName = new JLabel(tmp);
        tmp = "Herstellungskosten: " + herstellungskosten;
        JLabel lblKosten = new JLabel(tmp);
        tmp = "Verkaufswert: " + verkaufswert;
        JLabel lblValue = new JLabel(tmp);
        add(lblName);
        add(lblKosten);
        add(lblValue);
    }
}
import javax.swing.*;

public class itemPanel extends JPanel{
    public itemPanel(){
        erzeugnis e = new erzeugnis("Banane",1.0,3.0);
        maschine m = new maschine("Erzeuger","Bananenpflücker",30.0);
        abhaengigkeit a = new abhaengigkeit();

        int calc = (800-m.getWidth()-e.getWidth()-a.getWidth())/2;


        setLayout(new BoxLayout(this,BoxLayout.X_AXIS));

        add(m);
        add(Box.createHorizontalStrut(50));
        add(e);
        add(Box.createHorizontalStrut(50));
        add(a);

    }
}
import javax.swing.*;

public class maschine extends JPanel{
    public maschine(String typ, String name, double kosten){
        setSize((800/3)-10,50);
        setLayout(new BoxLayout(this,BoxLayout.Y_AXIS));
        String tmp;
        tmp = "Typ: " + typ;
        JLabel lblName = new JLabel(tmp);
        tmp = "Name: " + name;
        JLabel lblKosten = new JLabel(tmp);
        tmp = "Kosten: " + kosten;
        JLabel lblValue = new JLabel(tmp);
        add(lblName);
        add(lblKosten);
        add(lblValue);
    }
}
import javax.swing.*;

public class outerPanel extends JPanel{
    public outerPanel(){
        setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
        setSize(800,50);
        itemPanel iP = new itemPanel();

        add(iP);
    }
}

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.