Advertisement
Guest User

Untitled

a guest
May 29th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.29 KB | None | 0 0
  1. package org.kabili;
  2.  
  3.  
  4. import javax.swing.*;
  5. import javax.swing.tree.*;
  6. import javax.imageio.*;
  7.  
  8. import org.kabili.sql.*;
  9. import org.kabili.sql.records.*;
  10.  
  11. import java.awt.*;
  12. import java.awt.event.ActionEvent;
  13. import java.awt.event.ActionListener;
  14. import java.util.Vector;
  15.  
  16. import java.io.*;
  17.  
  18. import org.jruby.embed.*;
  19.  
  20. /**
  21. *
  22. * @author Andrew Nagle
  23. *
  24. */
  25. public class MainGUI extends JPanel {
  26.  
  27. private static final long serialVersionUID = -7266491760673265140L;
  28. private final String dbFile = "Database.rb";
  29.  
  30. Database db;
  31. static JFrame frame;
  32.  
  33. Member currentMember;
  34.  
  35. JTabbedPane tabbedPane;
  36. JPanel contentPane;
  37. JList userList;
  38. JTree productTree;
  39. JList itemList;
  40.  
  41. JLabel toolbarUser, toolbarStatus;
  42.  
  43. JTextField fName = new JTextField("First name");
  44. JTextField lName = new JTextField("Last name");
  45. JTextField phoneNo = new JTextField("Phone");
  46. JTextField username = new JTextField("username");
  47.  
  48. JTextField productNo = new JTextField("Product Number");
  49. JTextField productName = new JTextField("Product Name");
  50. JTextArea productDesc = new JTextArea("test");
  51.  
  52. JTextField userLoginField;
  53. JPasswordField passLoginField;
  54.  
  55. /**
  56. *
  57. * @param args
  58. */
  59. public static void main(String[] args) {
  60. try {
  61. try {
  62. UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
  63. } catch (UnsupportedLookAndFeelException e) {
  64. UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
  65. } catch (ClassNotFoundException e) {
  66. UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
  67. }
  68. }catch (Exception e) {
  69. e.printStackTrace();
  70. }
  71.  
  72.  
  73. frame = new JFrame("Off The Floor Administrative Panel");
  74. frame.setContentPane(new MainGUI());
  75. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  76. //frame.setPreferredSize(new Dimension(320, 240));
  77. //frame.setSize(320, 240);
  78. frame.setResizable(false);
  79. frame.setVisible(true);
  80. frame.pack();
  81. }
  82.  
  83. /**
  84. *
  85. */
  86. private MainGUI() {
  87. try {
  88. ScriptingContainer container = new ScriptingContainer();
  89. // implemented by a Ruby class
  90. Object receiver = container.runScriptlet(PathType.CLASSPATH, dbFile);
  91. db = container.getInstance(receiver, Database.class);
  92. } catch (Exception e) {}
  93.  
  94. setLayout(new BorderLayout());
  95. contentPane = new JPanel();
  96. tabbedPane = new JTabbedPane();
  97.  
  98. tabbedPane.addTab("Users", getUserPanel());
  99.  
  100. tabbedPane.addTab("Products", getProductPanel());
  101.  
  102. tabbedPane.addTab("Cart", getCartPanel());
  103.  
  104. tabbedPane.addTab("Donations", getDonationPanel());
  105.  
  106. //tabbedPane.setSelectedIndex(2);
  107.  
  108. JToolBar toolbar = new JToolBar();
  109. toolbar.setLayout(new BorderLayout());
  110. toolbar.setFloatable(false);
  111. toolbar.add(toolbarUser = new JLabel(""), BorderLayout.WEST);
  112. toolbar.add(toolbarStatus = new JLabel("",JLabel.RIGHT), BorderLayout.EAST);
  113.  
  114. contentPane.add(getLoginPanel());
  115. if (db.isConnectionValid()) {
  116. toolbarStatus.setText("Connected");
  117. } else {
  118. toolbarStatus.setText("Not Connected");
  119. }
  120.  
  121. add(contentPane,BorderLayout.CENTER);
  122. add(toolbar,BorderLayout.SOUTH);
  123.  
  124.  
  125. }
  126.  
  127. /**
  128. *
  129. * @return
  130. */
  131. private JPanel getUserPanel() {
  132. JPanel panel = new JPanel();
  133. panel.setLayout(new BorderLayout());
  134. JPanel info = new JPanel();
  135.  
  136. userList = new JList();
  137. userList.setVisibleRowCount(5);
  138. userList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  139. //userList.setFixedCellHeight(15);
  140. //userList.setFixedCellWidth(110);
  141.  
  142. GroupLayout layout = new GroupLayout(info);
  143. info.setLayout(layout);
  144.  
  145. layout.setAutoCreateGaps(true);
  146. layout.setAutoCreateContainerGaps(true);
  147. JLabel l1 = new JLabel("Name:",JLabel.LEFT);
  148.  
  149. layout.setHorizontalGroup(
  150. layout.createSequentialGroup()
  151. .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
  152. .addComponent(l1)
  153. .addComponent(fName))
  154. .addComponent(lName)
  155. );
  156. layout.setVerticalGroup(
  157. layout.createSequentialGroup()
  158. .addComponent(l1)
  159. .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
  160. .addComponent(fName)
  161. .addComponent(lName))
  162. );
  163.  
  164. JScrollPane userScroller = new JScrollPane(userList,
  165. JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
  166. JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  167. userScroller.setPreferredSize(new Dimension(120,0));
  168.  
  169. panel.add(userScroller,BorderLayout.WEST);
  170.  
  171. panel.add(info);
  172.  
  173. panel.setPreferredSize(new Dimension(450, 300));
  174. return panel;
  175. }
  176.  
  177. /**
  178. *
  179. * @return
  180. */
  181. private JPanel getLoginPanel() {
  182. JPanel panel = new JPanel();
  183. panel.setLayout(new FlowLayout());
  184.  
  185. JPanel login = new JPanel();
  186. GroupLayout layout = new GroupLayout(login);
  187. login.setLayout(layout);
  188.  
  189. layout.setAutoCreateGaps(true);
  190. layout.setAutoCreateContainerGaps(true);
  191. JLabel welcome = new JLabel("Welcome!");
  192. welcome.setFont(welcome.getFont().deriveFont(welcome.getFont().getSize2D()+5).deriveFont(Font.BOLD));
  193.  
  194. JLabel l1 = new JLabel("Username:",JLabel.LEFT);
  195. JLabel l2 = new JLabel("Password:",JLabel.LEFT);
  196.  
  197. userLoginField = new JTextField();
  198. passLoginField =new JPasswordField();
  199.  
  200. Dimension uNameSize = userLoginField.getPreferredSize();
  201. uNameSize.width = 120;
  202. JButton proceed = new JButton("Login");
  203. JButton exit = new JButton("Exit");
  204. proceed.addActionListener(new LoginListener());
  205. userLoginField.addActionListener(new LoginListener());
  206. passLoginField.addActionListener(new LoginListener());
  207.  
  208. userLoginField.setPreferredSize(uNameSize);
  209. passLoginField.setPreferredSize(uNameSize);
  210.  
  211. layout.setHorizontalGroup(
  212. layout.createParallelGroup(GroupLayout.Alignment.CENTER)
  213. .addComponent(welcome)
  214. .addGroup(layout.createSequentialGroup()
  215. .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
  216. .addComponent(l1)
  217. .addComponent(l2))
  218. .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
  219. .addComponent(userLoginField)
  220. .addComponent(passLoginField))
  221. ).addGroup(layout.createSequentialGroup()
  222. .addComponent(proceed)
  223. .addComponent(exit))
  224. );
  225. layout.setVerticalGroup(
  226. layout.createSequentialGroup()
  227. .addComponent(welcome)
  228. .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
  229. .addComponent(l1)
  230. .addComponent(userLoginField))
  231. .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
  232. .addComponent(l2)
  233. .addComponent(passLoginField))
  234. .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
  235. .addComponent(proceed)
  236. .addComponent(exit))
  237. );
  238.  
  239. panel.add(login);
  240.  
  241. Dimension size = new Dimension((int)tabbedPane.getPreferredSize().getWidth(), (int)tabbedPane.getPreferredSize().getHeight());
  242.  
  243. panel.setPreferredSize(size);
  244. return panel;
  245. }
  246.  
  247. /**
  248. *
  249. * @return
  250. */
  251. private JPanel getProductPanel() {
  252. JPanel panel = new JPanel(new BorderLayout(4,4));
  253.  
  254.  
  255.  
  256. /* Start Product Tree */
  257. productTree = new JTree();
  258.  
  259. Vector<Department> dept = new Vector<Department>();
  260. dept.add(new Department(1,"Bedroom",0));
  261. dept.add(new Department(2,"Kitchen",0));
  262. dept.add(new Department(3,"Appliances",2));
  263. dept.add(new Department(4,"Living room",0));
  264. dept.add(new Department(5,"Sofas",4));
  265. dept.add(new Department(7,"Bathroom",0));
  266.  
  267. DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("Root Node");
  268. DefaultTreeModel treeModel = new DefaultTreeModel(rootNode);
  269.  
  270. productTree.setModel( treeModel );
  271.  
  272. productTree.setRootVisible(false);
  273. productTree.setEditable(true);
  274. productTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  275. productTree.setShowsRootHandles(true);
  276.  
  277. DefaultMutableTreeNode parentNode;
  278. DefaultMutableTreeNode node;
  279.  
  280. for(Department d : dept){
  281. TreeNode[] test = treeModel.getPathToRoot(
  282. new DefaultMutableTreeNode( new Department(d.getParent(),"",0)));
  283.  
  284. //treeModel.insertNodeInto(arg0, arg1, arg2);
  285. parentNode = (DefaultMutableTreeNode) test[test.length-1];
  286. node = new DefaultMutableTreeNode( d );
  287. addNodeToDefaultTreeModel( treeModel, parentNode, node );
  288. }
  289. /*
  290. parentNode = (DefaultMutableTreeNode) treeModel.getRoot();
  291. node = new DefaultMutableTreeNode( new Department(1,"Bedroom",0) );
  292. addNodeToDefaultTreeModel( treeModel, parentNode, node );
  293.  
  294. parentNode = (DefaultMutableTreeNode) treeModel.getRoot();
  295. node = new DefaultMutableTreeNode( new Department(2,"Kitchen",0) );
  296. addNodeToDefaultTreeModel( treeModel, parentNode, node );
  297.  
  298. parentNode = node;
  299. node = new DefaultMutableTreeNode( new Department(3,"Appliances",2) );
  300. addNodeToDefaultTreeModel( treeModel, parentNode, node );
  301.  
  302. TreeNode[] test = treeModel.getPathToRoot(new Department(2,"",0));
  303.  
  304. parentNode = (DefaultMutableTreeNode) treeModel.getRoot();
  305. node = new DefaultMutableTreeNode( new Department(4,"Living room",0) );
  306. addNodeToDefaultTreeModel( treeModel, parentNode, node );
  307.  
  308. parentNode = node;
  309. node = new DefaultMutableTreeNode( new Department(5,"Sofas",4) );
  310. addNodeToDefaultTreeModel( treeModel, parentNode, node );
  311.  
  312. parentNode = (DefaultMutableTreeNode) treeModel.getRoot();
  313. node = new DefaultMutableTreeNode( new Department(6,"Stoves",3) );
  314. addNodeToDefaultTreeModel( treeModel, parentNode, node );
  315.  
  316. parentNode = node;
  317. node = new DefaultMutableTreeNode( new Department(7,"Bathroom",0) );
  318. addNodeToDefaultTreeModel( treeModel, parentNode, node );
  319. */
  320.  
  321.  
  322. JScrollPane treeScroller = new JScrollPane(productTree,
  323. JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
  324. JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  325. treeScroller.setPreferredSize(new Dimension(120,0));
  326.  
  327. /* End Product Tree */
  328. /* Start Search bar */
  329.  
  330. JPanel searchBar = new JPanel();
  331. GroupLayout layout = new GroupLayout(searchBar);
  332. searchBar.setLayout(layout);
  333.  
  334.  
  335. JComboBox locationList = new JComboBox();
  336. //locationList.setSelectedIndex(0);
  337. locationList.setPreferredSize(new Dimension(120, locationList.getPreferredSize().height));
  338. JTextField searchTerms = new JTextField();
  339. JButton searchButton = new JButton("Search");
  340.  
  341. layout.setAutoCreateGaps(true);
  342.  
  343.  
  344. layout.setHorizontalGroup(
  345. layout.createSequentialGroup()
  346. .addComponent(locationList, GroupLayout.PREFERRED_SIZE,
  347. GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
  348. .addComponent(searchTerms)
  349. .addComponent(searchButton)
  350. );
  351. layout.setVerticalGroup(
  352. layout.createSequentialGroup()
  353. .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
  354. .addComponent(locationList, GroupLayout.PREFERRED_SIZE,
  355. GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
  356. .addComponent(searchTerms)
  357. .addComponent(searchButton))
  358. );
  359.  
  360.  
  361. /* End Search Bar */
  362.  
  363. JPanel products = new JPanel();
  364. GridLayout gl = new GridLayout(0,1);
  365. gl.setVgap(4);
  366. products.setLayout(gl);
  367.  
  368. if(db.isConnectionValid()) {
  369. Vector<Product> prods = db.getProducts(1);
  370. for (int i = 0; i < prods.size(); i++) {
  371. products.add(createProductPanel(prods.get(i)));
  372. }
  373. }
  374.  
  375.  
  376. for (int i = 0; i < 10; i++) {
  377. Image image = null;
  378. Product p;
  379. try {
  380. InputStream is = new BufferedInputStream(
  381. new FileInputStream("D:\\gem.jpg"));
  382. image = ImageIO.read(is);
  383. p = new Product(0,"Test Product #" + i, "",0, 0, image);
  384. products.add(createProductPanel(p));
  385. } catch (Exception e) {}
  386. }
  387.  
  388. JScrollPane productScroller = new JScrollPane(products,
  389. JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
  390. JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  391.  
  392. panel.add(treeScroller,BorderLayout.WEST);
  393. panel.add(productScroller, BorderLayout.CENTER);
  394. panel.add(searchBar, BorderLayout.NORTH);
  395. panel.setPreferredSize(new Dimension(450, 300));
  396. return panel;
  397. }
  398.  
  399. private static void addNodeToDefaultTreeModel( DefaultTreeModel treeModel, DefaultMutableTreeNode parentNode, DefaultMutableTreeNode node ) {
  400.  
  401. treeModel.insertNodeInto( node, parentNode, parentNode.getChildCount() );
  402.  
  403. if ( parentNode == treeModel.getRoot() ) {
  404. treeModel.nodeStructureChanged( (TreeNode) treeModel.getRoot() );
  405. }
  406. }
  407.  
  408.  
  409. /**
  410. * the cart panel will track the items that the users have requested
  411. *
  412. * @return
  413. */
  414. private JPanel getCartPanel() {
  415. JPanel cart = new JPanel(new BorderLayout(4,4));
  416. JPanel info = new JPanel();
  417.  
  418. itemList = new JList();
  419. itemList.setVisibleRowCount(5);
  420. itemList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  421.  
  422. GroupLayout layout = new GroupLayout(info);
  423. info.setLayout(layout);
  424.  
  425. layout.setAutoCreateGaps(true);
  426. layout.setAutoCreateContainerGaps(true);
  427. //JButton submit = new JButton("Submit");
  428. JLabel l1 = new JLabel("Product Number:",JLabel.LEFT);
  429. JLabel productNum = new JLabel("",JLabel.LEFT);
  430. JLabel l2 = new JLabel("Product Name:", JLabel.LEFT);
  431. JLabel productName = new JLabel("", JLabel.LEFT);
  432. JLabel l3 = new JLabel("Product Description:", JLabel.LEFT);
  433. JLabel productDesc = new JLabel("", JLabel.LEFT);
  434. JLabel l4 = new JLabel("Product Department:", JLabel.LEFT);
  435. JLabel productDept = new JLabel("", JLabel.LEFT);
  436. JLabel l5 = new JLabel("Product Location:", JLabel.LEFT);
  437. JLabel productLocation = new JLabel("", JLabel.LEFT);
  438.  
  439.  
  440. layout.setHorizontalGroup(
  441. layout.createSequentialGroup()
  442. .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
  443. .addComponent(l1)
  444. .addComponent(l2)
  445. .addComponent(l3)
  446. .addComponent(l4)
  447. .addComponent(l5))
  448. .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
  449. .addComponent(productNum)
  450. .addComponent(productName)
  451. .addComponent(productDesc)
  452. .addComponent(productDept)
  453. .addComponent(productLocation))
  454. //.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
  455. //.addComponent(submit))
  456. );
  457. layout.setVerticalGroup(
  458. layout.createSequentialGroup()
  459. .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
  460. .addComponent(l1)
  461. .addComponent(productNum))
  462. .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
  463. .addComponent(l2)
  464. .addComponent(productName))
  465. .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
  466. .addComponent(l3)
  467. .addComponent(productDesc))
  468. .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
  469. .addComponent(l4)
  470. .addComponent(productDept))
  471. .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
  472. .addComponent(l5)
  473. .addComponent(productLocation))
  474. //.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
  475. //.addComponent(submit))
  476. );
  477.  
  478.  
  479.  
  480. JScrollPane userScroller = new JScrollPane(itemList,
  481. JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
  482. JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  483. userScroller.setPreferredSize(new Dimension(120,0));
  484.  
  485. cart.add(userScroller,BorderLayout.WEST);
  486.  
  487. cart.add(info);
  488.  
  489.  
  490.  
  491.  
  492. cart.setPreferredSize(new Dimension(450, 300));
  493. return cart;
  494. }
  495.  
  496. private JPanel getDonationPanel() {
  497. JPanel donate = new JPanel(new BorderLayout(4,4));
  498. JPanel info = new JPanel();
  499.  
  500. itemList = new JList();
  501. itemList.setVisibleRowCount(5);
  502. itemList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  503.  
  504. GroupLayout layout = new GroupLayout(info);
  505. info.setLayout(layout);
  506.  
  507. layout.setAutoCreateGaps(true);
  508. layout.setAutoCreateContainerGaps(true);
  509. JLabel l1 = new JLabel("Product name:", JLabel.LEFT);
  510. JTextField productName = new JTextField();
  511. JLabel l2 = new JLabel("Product description:", JLabel.LEFT);
  512. JTextArea productDescription = new JTextArea();
  513.  
  514.  
  515. layout.setHorizontalGroup(
  516. layout.createSequentialGroup()
  517. .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
  518. .addComponent(l1)
  519. .addComponent(l2))
  520. .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
  521. .addComponent(productName)
  522. .addComponent(productDescription))
  523. );
  524. layout.setVerticalGroup(
  525. layout.createSequentialGroup()
  526. .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
  527. .addComponent(l1)
  528. .addComponent(productName))
  529. .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
  530. .addComponent(l2)
  531. .addComponent(productDescription))
  532. );
  533.  
  534. donate.add(info);
  535.  
  536. donate.setPreferredSize(new Dimension(450, 300));
  537. return donate;
  538. }
  539.  
  540.  
  541. private JPanel createProductPanel(Product prod) {
  542.  
  543. JPanel panel;
  544. JButton button1;
  545. JButton button2;
  546. JButton button3;
  547. JImage image;
  548. JLabel name;
  549. JLabel description;
  550.  
  551.  
  552. panel = new JPanel();
  553. GroupLayout layout = new GroupLayout(panel);
  554. panel.setLayout(layout);
  555. panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
  556.  
  557. button1 = new JButton(".");
  558. button2 = new JButton(".");
  559. button3 = new JButton(".");
  560.  
  561. // Setting the name allows us to determine which product
  562. // this button belongs to when an ActionListener is fired
  563. button1.setName("" + prod.getId());
  564. button2.setName("" + prod.getId());
  565. button3.setName("" + prod.getId());
  566.  
  567. image = new JImage(prod.getImage(), 80, 80);
  568. name = new JLabel(prod.getName());
  569. name.setFont(name.getFont().deriveFont(Font.BOLD));
  570.  
  571. description = new JLabel(prod.getDescription());
  572.  
  573. layout.setAutoCreateGaps(true);
  574. layout.setHorizontalGroup(
  575. layout.createSequentialGroup()
  576. .addComponent(image)
  577. .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED,
  578. 2, 2)
  579. .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
  580. .addComponent(name, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  581. .addComponent(description, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  582. .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
  583. .addComponent(button1)
  584. .addComponent(button2)
  585. .addComponent(button3))
  586. );
  587. layout.setVerticalGroup(
  588. layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
  589. .addComponent(image)
  590. .addGroup(layout.createSequentialGroup()
  591. .addComponent(name)
  592. .addComponent(description))
  593. .addGroup(layout.createSequentialGroup()
  594. .addComponent(button1)
  595. .addComponent(button2)
  596. .addComponent(button3))
  597. );
  598.  
  599. return panel;
  600.  
  601. }
  602.  
  603. /**
  604. * This inner class handles login related events.
  605. */
  606. class LoginListener implements ActionListener {
  607.  
  608. /**
  609. * Allows the user to login to the program.
  610. *
  611. * @param e the event object.
  612. */
  613. @Override
  614. public void actionPerformed(ActionEvent e) {
  615.  
  616. // FIXME: Remove this check before release
  617. if (db.isConnectionValid()) {
  618. currentMember = db.authMember(userLoginField.getText(), passLoginField.getPassword());
  619.  
  620. try {
  621. toolbarUser.setText("Logged in as: " + currentMember.getUserName());
  622. } catch (NullPointerException npe) {
  623. return;
  624. }
  625. } else {
  626. toolbarUser.setText("Logged in as: " + "Username");
  627. }
  628.  
  629. contentPane.removeAll();
  630. contentPane.add(tabbedPane);
  631. System.out.println("Fetching data");
  632. userList.setListData(db.getMembers());
  633. contentPane.repaint();
  634. frame.setVisible(true);
  635. frame.pack();
  636.  
  637. }
  638. }
  639.  
  640.  
  641. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement