JFrame jf = new JFrame("Projekt");
CardLayout cardLay = new CardLayout();
JPanel panelMain = new JPanel(cardLay);
JPanel panels [] = new JPanel[5];
JButton start = new JButton("Str");
JButton suche = new JButton("Srch");
JButton playlists = new JButton("PL");
JButton meinProfil = new JButton("MP");
JButton aboFr = new JButton("A & F");
JButton startBtns1 [] = new JButton[10];
Dimension dim = new Dimension (325, 475);
Color co = new Color(205, 133, 63);
public DasFrame() {
jf.setTitle("Projekt");
jf.setVisible(true);
jf.setSize(325, 475);
jf.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
jf.setLocationRelativeTo(null);
jf.setResizable(true);
jf.setLayout(new BorderLayout());
// Panel mit den Buttons erstellen
JPanel panelBtn = new JPanel(new FlowLayout());
panelBtn.add(start);
panelBtn.add(suche);
panelBtn.add(playlists);
panelBtn.add(meinProfil);
panelBtn.add(aboFr);
jf.add(panelBtn, BorderLayout.SOUTH);
//panel mit cardLayout hinzufügen
jf.add(panelMain);
//btns panelwechsel
start.addActionListener((ActionEvent e) -> cardLay.first(panelMain));
suche.addActionListener((ActionEvent e) -> cardLay.next(panelMain));
playlists.addActionListener((ActionEvent e) -> cardLay.next(panelMain));
meinProfil.addActionListener((ActionEvent e) -> cardLay.previous(panelMain));
aboFr.addActionListener((ActionEvent e) -> cardLay.previous(panelMain));
//panels für das CardLayout
for(int i=0;i<5;i++){
panels[i] = new JPanel();
panels[i].setBackground(co);
panels[i].setPreferredSize(dim);
panelMain.add(panels[i]);
}
//erstes Label für die Startseite (panels[0])
JLabel startLabels[] = new JLabel[3];
startLabels[0] = new JLabel("Diese Woche angesagt:\n");
startLabels[0].setPreferredSize(new Dimension(200, 55));
Font schrift = (startLabels[0].getFont().deriveFont(Font.PLAIN, 50));
startLabels[0].setForeground(Color.WHITE);
panels[0].add(startLabels[0]);
//erstes Panel für die Startseite
JPanel startPanels[] = new JPanel[3];
startPanels[0] = new JPanel();
startPanels[0].setLayout(new FlowLayout());
startPanels[0].setBackground(co);
startPanels[0].setPreferredSize(new Dimension(100, 60));
//scrollpane fürs panel
JScrollPane jspStart[] = new JScrollPane[3];
jspStart[0] = new JScrollPane();
jspStart[0].setBackground(co);
jspStart[0].setPreferredSize(new Dimension(100,60));
jspStart[0].setPreferredSize(dim);
jspStart[0].setHorizontalScrollBarPolicy
(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
//knöpfe für das erste Panel
for(int i=0;i<10;i++){
startBtns1[i] = new JButton(i + ".");
startBtns1[i].setPreferredSize(new Dimension(50, 50));
startPanels[0].add(startBtns1[i]);
}
//panels dem jFrame adden
jspStart[0].setViewportView(startPanels[0]);
panels[0].add(jspStart[0]);
// jspStart[0].setBorder(null);
// jf.repaint();
jf.pack();
jf.setVisible(true);