📄 GosterSakla.java .java dosyası
⬇️ İndir
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class GosterSakla {
public GosterSakla() {
Color hardal = new Color(242, 203, 5);
Color mavi = new Color(4, 157, 217);
Color lila = new Color(143, 142, 191);
Color koyu = new Color(53, 64, 58);
JFrame frame = new JFrame("074 JPanel Goster Sakla");
frame.setLayout(null);
JPanel butonPaneli = new JPanel();
butonPaneli.setLayout(null);
butonPaneli.setBackground(koyu);
butonPaneli.setBounds(15, 15, 230, 400);
JButton hardal0 = new JButton("Hardali Sakla");
hardal0.setBounds(30, 50, 170, 30);
JButton hardal1 = new JButton("Hardali Göster");
hardal1.setBounds(30, 80, 170, 30);
JButton mavi0 = new JButton("Maviyi Sakla");
mavi0.setBounds(30, 150, 170, 30);
JButton mavi1 = new JButton("Maviyi Göster");
mavi1.setBounds(30, 180, 170, 30);
JButton lila0 = new JButton("Lilayi Sakla");
lila0.setBounds(30, 250, 170, 30);
JButton lila1 = new JButton("Lilayi Göster");
lila1.setBounds(30, 280, 170, 30);
JPanel bosPanel = new JPanel();
bosPanel.setLayout(null);
bosPanel.setBounds(260, 15, 725, 400);
JPanel hardalPanel = new JPanel();
hardalPanel.setLayout(null);
hardalPanel.setBackground(hardal);
hardalPanel.setBounds(260, 15, 725, 400);
JPanel maviPanel = new JPanel();
maviPanel.setLayout(null);
maviPanel.setBackground(mavi);
maviPanel.setBounds(260, 15, 725, 400);
JPanel lilaPanel = new JPanel();
lilaPanel.setLayout(null);
lilaPanel.setBackground(lila);
lilaPanel.setBounds(260, 15, 725, 400);
hardal0.addActionListener(new ActionListener () {
public void actionPerformed(ActionEvent e ) {
bosPanel.setVisible(true);
hardalPanel.setVisible(false);
maviPanel.setVisible(false);
lilaPanel.setVisible(false);
}
});
hardal1.addActionListener(new ActionListener () {
public void actionPerformed(ActionEvent e ) {
bosPanel.setVisible(false);
hardalPanel.setVisible(true);
maviPanel.setVisible(false);
lilaPanel.setVisible(false);
}
});
mavi0.addActionListener(new ActionListener () {
public void actionPerformed(ActionEvent e ) {
bosPanel.setVisible(true);
hardalPanel.setVisible(false);
maviPanel.setVisible(false);
lilaPanel.setVisible(false);
}
});
mavi1.addActionListener(new ActionListener () {
public void actionPerformed(ActionEvent e ) {
bosPanel.setVisible(false);
hardalPanel.setVisible(false);
maviPanel.setVisible(true);
lilaPanel.setVisible(false);
}
});
lila0.addActionListener(new ActionListener () {
public void actionPerformed(ActionEvent e ) {
bosPanel.setVisible(true);
hardalPanel.setVisible(false);
maviPanel.setVisible(false);
lilaPanel.setVisible(false);
}
});
lila1.addActionListener(new ActionListener () {
public void actionPerformed(ActionEvent e ) {
bosPanel.setVisible(false);
hardalPanel.setVisible(false);
maviPanel.setVisible(false);
lilaPanel.setVisible(true);
}
});
butonPaneli.add(hardal0);
butonPaneli.add(hardal1);
butonPaneli.add(mavi0);
butonPaneli.add(mavi1);
butonPaneli.add(lila0);
butonPaneli.add(lila1);
frame.add(butonPaneli);
frame.add(bosPanel);
frame.add(hardalPanel);
frame.add(maviPanel);
frame.add(lilaPanel);
frame.getContentPane().setBackground(new Color(2, 104, 115));
frame.setSize(1000, 450);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null);
frame.setResizable(false);
frame.setVisible(true);
}
}