Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Dictionary;
- import java.awt.BorderLayout;
- import java.awt.FlowLayout;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import javax.swing.*;
- /**
- *
- * @author HuyHung
- */
- public class GUI extends JFrame{
- private JPanel pn_all, pn_left, pn_right, pn_top;
- private JTextField tf_word;
- private JButton bt_search, bt_add, bt_edit, bt_delete, bt_save;
- private JList l_word;
- private DefaultListModel dlm_word = new DefaultListModel();
- private JLabel lb_icon;
- private JEditorPane edt_mean;
- //Creat GUI
- public GUI() throws Exception {
- this.setSize(600, 500);
- setLocation(250,10);
- setResizable(false);
- //Panel Tren cung
- JMenuBar mnb=new JMenuBar();
- JMenu mn_File=new JMenu("File");
- JMenuItem mni_e=new JMenuItem("Exit");
- mn_File.add(mni_e);
- JMenu mn_Help=new JMenu("Help");
- JMenuItem mni_h=new JMenuItem("About");
- mn_Help.add(mni_h);
- mnb.add(mn_File);
- mnb.add(mn_Help);
- lb_icon = new JLabel(new ImageIcon("Banner.png"));
- JPanel pn_tren = new JPanel(new FlowLayout());
- pn_tren.add(lb_icon,BorderLayout.CENTER);
- pn_top = new JPanel(new BorderLayout());
- pn_top.add(mnb,BorderLayout.NORTH);
- pn_top.add(pn_tren,BorderLayout.CENTER);
- //Panel Ben Trai
- pn_left = new JPanel(new BorderLayout());
- //Box gom textfied + button search,
- Box b_top = Box.createHorizontalBox();
- tf_word = new JTextField(15);
- b_top.add(tf_word);
- bt_search = new JButton("Search");
- b_top.add(bt_search);
- //Box gom button Add, Edit, Delete
- Box b_center = Box.createHorizontalBox();
- bt_add = new JButton("Add");
- b_top.add(bt_add);
- bt_edit = new JButton("Edit");
- b_top.add(bt_edit);
- bt_delete = new JButton("Delete");
- b_top.add(bt_delete);
- //Box gom JList
- Box b_bottom = Box.createVerticalBox();
- b_bottom.add(new JScrollPane(l_word =new JList(dlm_word)));
- pn_left.add(b_top,BorderLayout.NORTH);
- pn_left.add(b_bottom,BorderLayout.CENTER);
- pn_right = new JPanel(new BorderLayout());
- edt_mean = new JEditorPane();
- pn_right.add(edt_mean);
- Box b_bot = Box.createHorizontalBox();
- b_bot.add(pn_left);
- b_bot.add(pn_right);
- pn_all = new JPanel(new BorderLayout());
- pn_all.add(pn_top,BorderLayout.NORTH);
- pn_all.add(b_bot,BorderLayout.CENTER);
- add(pn_all);
- mni_h.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- JOptionPane.showMessageDialog(null, "====Code by Chang Che Hiep===");
- }
- });
- mni_e.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- System.exit(1);
- }
- });
- }
- public static void main(String[] args) throws Exception {
- GUI a = new GUI();
- a.setVisible(true);
- a.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- a.setTitle("Dictionary ver 1.0");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement