import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
public class Fenster {
JFrame frame1;
JButton bnewproduct;
JButton bdproduct;
JButton bexport;
JButton bsearch;
public void setButtonSize(JButton a) {
a.setPreferredSize(new Dimension(150, 25)); //Einheitsgröße für alle Buttons
}
public void setTfSize(JTextField a) {
a.setPreferredSize(new Dimension(150, 25)); //Einheitsgröße für alle Textfelder
}
public Fenster() {
this.frame1 = new JFrame("Hardware Verwaltungs System");
frame1.setSize(800, 600);
frame1.setResizable(false);
frame1.setLocationRelativeTo(null);
frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.bnewproduct = new JButton("Produkt hinzufügen");
bnewproduct.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent action) {
JFrame frame2 = new JFrame("Produkt hinzufügen");
frame2.setSize(400,300);
JTextField tfTyp = new JTextField();
tfTyp.setTfSize();
frame2.setVisible(true);
}
});
this.bdproduct = new JButton("Produkt löschen");
this.bsearch = new JButton("Produkt suchen");
this.bexport = new JButton("Liste exportieren");
setButtonSize(bnewproduct);
setButtonSize(bdproduct);
setButtonSize(bsearch);
setButtonSize(bexport);
JPanel cbutton1 = new JPanel(new FlowLayout()); //FlowLayout für Button "Produkt hinzufügen"
cbutton1.add(bnewproduct);
JPanel cbutton2 = new JPanel(new FlowLayout()); //FlowLayout für Button "Produkt löschen"
cbutton2.add(bdproduct);
JPanel cbutton3 = new JPanel(new FlowLayout()); //FlowLayout für Button "Produkt suchen"
cbutton3.add(bsearch);
JPanel cbutton4 = new JPanel(new FlowLayout()); //FlowLayout für Button "Liste exportieren"
cbutton4.add(bexport);
Box boxleft = new Box(BoxLayout.Y_AXIS); //Box für Komponenten links
boxleft.add(cbutton1);
boxleft.add(cbutton2);
boxleft.add(cbutton3);
boxleft.add(cbutton4);
Box boxright = new Box(BoxLayout.Y_AXIS); //Box für Komponenten rechst
JPanel containerl = new JPanel(new FlowLayout()); //FlowLayout für Komponenten links
containerl.setPreferredSize(new Dimension(180, 580));
containerl.add(boxleft);
JPanel containerr = new JPanel(new FlowLayout()); //FlowLayout für Komponenten rechts
containerr.setPreferredSize(new Dimension(620, 580));
containerr.add(boxright);
Box container1 = new Box(BoxLayout.X_AXIS); //Haupcontainer
container1.add(containerl);
container1.add(containerr);
JTabbedPane tabbedPane = new JTabbedPane();
tabbedPane.addTab("Übersicht", container1);
frame1.add(tabbedPane);
frame1.setVisible(true);
}
public static void main(String[] args) {
new Fenster();
}
}