Created
January 1, 2014 01:56
-
-
Save resarahadian/8204178 to your computer and use it in GitHub Desktop.
Membuat Round Edge JFrame
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
import java.awt.EventQueue; | |
import java.awt.geom.RoundRectangle2D; | |
import javax.swing.JFrame; | |
import javax.swing.JPanel; | |
import javax.swing.UIManager; | |
import javax.swing.border.EmptyBorder; | |
import javax.swing.JButton; | |
import java.awt.event.ActionListener; | |
import java.awt.event.ActionEvent; | |
import javax.swing.ImageIcon; | |
import javax.swing.JLabel; | |
import java.awt.Font; | |
@SuppressWarnings("serial") | |
public class frameJFrame extends JFrame | |
{ | |
private JPanel contentPane; | |
private JButton btnClose; | |
private JButton btnMax; | |
private JButton btnMin; | |
private JLabel lblWall; | |
private JLabel lblText; | |
/** | |
* Create the frame. | |
*/ | |
public frameJFrame() | |
{ | |
setResizable(false); | |
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | |
setBounds(100, 100, 564, 355); | |
setUndecorated(true); | |
contentPane = new JPanel(); | |
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); | |
setContentPane(contentPane); | |
contentPane.setLayout(null); | |
lblText = new JLabel("Round Edge JFrame"); | |
lblText.setBounds(175, 0, 161, 25); | |
contentPane.add(lblText); | |
lblText.setFont(new Font("Comic Sans MS", Font.BOLD, 16)); | |
btnMin = new JButton(""); | |
btnMin.setBounds(420, 0, 44, 25); | |
contentPane.add(btnMin); | |
btnMin.setIcon(new ImageIcon("/home/resa/Aplikasi Java/SwingJava/src/shapedJFrame/minimize.png")); | |
btnMax = new JButton(""); | |
btnMax.setBounds(463, 0, 44, 25); | |
contentPane.add(btnMax); | |
btnMax.setIcon(new ImageIcon("/home/resa/Aplikasi Java/SwingJava/src/shapedJFrame/maximize.png")); | |
btnClose = new JButton(""); | |
btnClose.setBounds(506, 0, 52, 25); | |
contentPane.add(btnClose); | |
btnClose.setIcon(new ImageIcon("/home/resa/Aplikasi Java/SwingJava/src/shapedJFrame/close.png")); | |
lblWall = new JLabel(""); | |
lblWall.setIcon(new ImageIcon("/home/resa/Aplikasi Java/SwingJava/src/shapedJFrame/wall.jpg")); | |
lblWall.setBounds(0, 0, 564, 355); | |
contentPane.add(lblWall); | |
btnClose.addActionListener(new ActionListener() { | |
public void actionPerformed(ActionEvent act) | |
{ | |
System.exit(0); | |
} | |
}); | |
btnMax.addActionListener(new ActionListener() { | |
public void actionPerformed(ActionEvent act) | |
{ | |
if(getExtendedState() == NORMAL) | |
{ | |
setExtendedState(MAXIMIZED_BOTH); | |
} | |
else | |
{ | |
setExtendedState(NORMAL); | |
} | |
} | |
}); | |
btnMin.addActionListener(new ActionListener() { | |
public void actionPerformed(ActionEvent act) | |
{ | |
setState(ICONIFIED); | |
} | |
}); | |
setShape(new RoundRectangle2D.Double(0,0,getWidth(),getHeight(),20,40)); | |
setLocationRelativeTo(null); | |
} | |
/** | |
* Launch the application. | |
*/ | |
public static void main(String[] args) { | |
EventQueue.invokeLater(new Runnable() { | |
public void run() { | |
try { | |
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); | |
frameJFrame frame = new frameJFrame(); | |
frame.setVisible(true); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment