Instantly share code, notes, and snippets.
Last active
March 4, 2020 17:26
-
Star
0
(0)
You must be signed in to star a gist -
Fork
0
(0)
You must be signed in to fork a gist
-
Save nugraha16/5149363 to your computer and use it in GitHub Desktop.
Membuat Hide/UnHide Menu di Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package newbieilmuDemo; | |
import java.awt.BorderLayout; | |
import java.awt.EventQueue; | |
import javax.swing.JFrame; | |
import javax.swing.JPanel; | |
import javax.swing.border.EmptyBorder; | |
import javax.swing.border.TitledBorder; | |
import javax.swing.JButton; | |
import javax.swing.JCheckBox; | |
import javax.swing.ImageIcon; | |
import javax.swing.border.LineBorder; | |
import java.awt.Color; | |
import java.awt.event.ActionListener; | |
import java.awt.event.ActionEvent; | |
import javax.swing.SwingConstants; | |
import javax.swing.JLabel; | |
import javax.swing.UIManager; | |
import com.jtattoo.plaf.fast.FastLookAndFeel; | |
//@Anugrah Bagus Susilo | |
public class menuHideUnHide extends JFrame { | |
private JPanel contentPane; | |
/** | |
* Launch the application. | |
*/ | |
public static void main(String[] args) { | |
EventQueue.invokeLater(new Runnable() { | |
public void run() { | |
try { | |
UIManager.setLookAndFeel(new FastLookAndFeel()); | |
menuHideUnHide frame = new menuHideUnHide(); | |
frame.setVisible(true); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
} | |
}); | |
} | |
/** | |
* Create the frame. | |
*/ | |
public menuHideUnHide() { | |
setTitle("::Sistem Informasi Sekolah::"); | |
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | |
setBounds(100, 100, 776, 434); | |
contentPane = new JPanel(); | |
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); | |
setContentPane(contentPane); | |
contentPane.setLayout(null); | |
JPanel panelUtama = new JPanel(); | |
panelUtama.setBorder(new TitledBorder(null, "::Panel Utama::", TitledBorder.LEADING, TitledBorder.TOP, null, null)); | |
panelUtama.setBounds(12, 12, 164, 379); | |
contentPane.add(panelUtama); | |
panelUtama.setLayout(null); | |
final JPanel panelMnuMaster = new JPanel(); | |
panelMnuMaster.setBounds(12, 45, 140, 115); | |
panelUtama.add(panelMnuMaster); | |
panelMnuMaster.setLayout(null); | |
JButton btnMasterSiswa = new JButton("Master Siswa"); | |
btnMasterSiswa.setMnemonic('M'); | |
btnMasterSiswa.setHorizontalAlignment(SwingConstants.LEFT); | |
btnMasterSiswa.setIcon(new ImageIcon("/home/newbieilmu/workspace/app.newbieilmu/src/icon/anggota.png")); | |
btnMasterSiswa.setBounds(0, 0, 140, 30); | |
panelMnuMaster.add(btnMasterSiswa); | |
JButton btnMasterGuru = new JButton("Master Guru"); | |
btnMasterGuru.setMnemonic('M'); | |
btnMasterGuru.setHorizontalAlignment(SwingConstants.LEFT); | |
btnMasterGuru.setIcon(new ImageIcon("/home/newbieilmu/workspace/app.newbieilmu/src/icon/customers.png")); | |
btnMasterGuru.setBounds(0, 26, 140, 30); | |
panelMnuMaster.add(btnMasterGuru); | |
JButton btnMasterMatpel = new JButton("Master MatPel"); | |
btnMasterMatpel.setMnemonic('M'); | |
btnMasterMatpel.setHorizontalAlignment(SwingConstants.LEFT); | |
btnMasterMatpel.setIcon(new ImageIcon("/home/newbieilmu/workspace/app.newbieilmu/src/icon/Agenda-1-16x16.png")); | |
btnMasterMatpel.setBounds(0, 55, 140, 30); | |
panelMnuMaster.add(btnMasterMatpel); | |
JButton btnMasterKelas = new JButton("Master Kelas"); | |
btnMasterKelas.setMnemonic('M'); | |
btnMasterKelas.setHorizontalAlignment(SwingConstants.LEFT); | |
btnMasterKelas.setIcon(new ImageIcon("/home/newbieilmu/workspace/app.newbieilmu/src/icon/konfigurasi_univ.png")); | |
btnMasterKelas.setBounds(0, 85, 140, 30); | |
panelMnuMaster.add(btnMasterKelas); | |
final JCheckBox chkMenuMaster = new JCheckBox("Menu Master"); | |
chkMenuMaster.setHorizontalAlignment(SwingConstants.LEFT); | |
chkMenuMaster.setHorizontalTextPosition(SwingConstants.RIGHT); | |
chkMenuMaster.setMnemonic('M'); | |
chkMenuMaster.setForeground(UIManager.getColor("Button.background")); | |
chkMenuMaster.setBackground(UIManager.getColor("Button.darkShadow")); | |
chkMenuMaster.addActionListener(new ActionListener() { | |
public void actionPerformed(ActionEvent arg0) { | |
if(chkMenuMaster.isSelected()==true){ | |
panelMnuMaster.setVisible(true); | |
} | |
else if(chkMenuMaster.isSelected()==false){ | |
panelMnuMaster.setVisible(false); | |
} | |
} | |
}); | |
chkMenuMaster.setBorderPaintedFlat(true); | |
chkMenuMaster.setBorderPainted(true); | |
chkMenuMaster.setBorder(new LineBorder(new Color(0, 0, 0))); | |
chkMenuMaster.setSelectedIcon(new ImageIcon("/home/newbieilmu/workspace/app.newbieilmu/src/icon/minus-root.png")); | |
chkMenuMaster.setRolloverSelectedIcon(new ImageIcon("/home/newbieilmu/workspace/app.newbieilmu/src/icon/minus-root.png")); | |
chkMenuMaster.setRolloverIcon(new ImageIcon("/home/newbieilmu/workspace/app.newbieilmu/src/icon/plus-root.png")); | |
chkMenuMaster.setIcon(new ImageIcon("/home/newbieilmu/workspace/app.newbieilmu/src/icon/plus-root.png")); | |
chkMenuMaster.setSelected(true); | |
chkMenuMaster.setBounds(12, 22, 140, 22); | |
panelUtama.add(chkMenuMaster); | |
JLabel label = new JLabel(""); | |
label.setIcon(new ImageIcon("/home/newbieilmu/Pictures/bgskul.png")); | |
label.setBounds(181, 12, 573, 376); | |
contentPane.add(label); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment