package javatestswing; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.SwingUtilities; /** * * @web http://java-buddy.blogspot.com/ */ public class JavaTestSwing { public static void main(String[] args) { SwingUtilities.invokeLater(runJFrameLater); } static Runnable runJFrameLater = new Runnable() { @Override public void run() { MyJFrameWin myjFrameWindow; myjFrameWindow = new MyJFrameWin(); myjFrameWindow.setVisible(true); } }; public static class MyJFrameWin extends JFrame{ public MyJFrameWin(){ this.setTitle("java-buddy.blogspot.com"); this.setSize(300, 200); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton buttonExit = new JButton(" Exit "); buttonExit.addActionListener(new ActionListener(){ @Override public void actionPerformed(ActionEvent ae) { System.exit(0); } }); JButton buttonWithBorder = new JButton(" Button with RaisedBevelBorder "); //Add JPanel with Border JPanel jPanel = new JPanel(); jPanel.setBorder(BorderFactory.createRaisedBevelBorder()); jPanel.add(buttonWithBorder); JButton buttonNormal = new JButton(" Normal Button WITHOUT Border "); this.setLayout(new FlowLayout()); this.add(jPanel); this.add(buttonNormal); this.add(buttonExit); } } }
More border examples of created by BorderFactory.
No comments:
Post a Comment