Advertisement
Guest User

Untitled

a guest
Jun 15th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. package notesapplication;
  2.  
  3.  
  4.  
  5. import java.awt.BorderLayout;
  6. import java.awt.Dimension;
  7. import java.awt.event.ActionEvent;
  8. import java.sql.SQLException;
  9. import javax.swing.JFrame;
  10. import javax.swing.JLabel;
  11. import javax.swing.JMenu;
  12. import javax.swing.JMenuBar;
  13. import javax.swing.JMenuItem;
  14. import javax.swing.JOptionPane;
  15.  
  16. public class NotesApplication extends JFrame {
  17.  
  18. public NotesApplication() {
  19. setTitle("Notes");
  20. setLayout(new BorderLayout());
  21.  
  22. JMenuBar menubar = new JMenuBar();
  23. setJMenuBar(menubar);
  24.  
  25. JMenu fileMenu = new JMenu("file");
  26. menubar.add(fileMenu);
  27.  
  28. JMenuItem exitMenuItem = new JMenuItem("exit");
  29. fileMenu.add(exitMenuItem);
  30.  
  31. exitMenuItem.addActionListener((ActionEvent e) -> {
  32.  
  33. System.exit(0);
  34. });
  35.  
  36. JMenu setupMenu = new JMenu("setup");
  37. menubar.add(setupMenu);
  38. JMenuItem userMenuItem = new JMenuItem("user");
  39. setupMenu.add(userMenuItem);
  40. userMenuItem.addActionListener((ActionEvent e) -> {
  41. UsersDialog dialog;
  42. try {
  43. dialog = new UsersDialog();
  44. dialog.setVisible(true);
  45. } catch (SQLException ex) {
  46. JOptionPane.showMessageDialog(this, ex.getMessage());
  47. }
  48.  
  49.  
  50. });
  51.  
  52. JMenuItem setupMenuItem = new JMenuItem("setup");
  53.  
  54. JLabel label = new JLabel("Notes Application", JLabel.CENTER);
  55. label.setPreferredSize(new Dimension(500, 500));
  56. add(label, BorderLayout.CENTER);
  57. pack();
  58. setDefaultCloseOperation(EXIT_ON_CLOSE);
  59. }
  60.  
  61. public static void main(String[] args) {
  62. new NotesApplication().setVisible(true);
  63. }
  64.  
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement