Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.83 KB | None | 0 0
  1. public void selectModuleScreen() throws Exception
  2. {
  3. // construction of module selection GUI
  4.  
  5. select_module.removeAll();
  6. select_module.revalidate(); // ensuring dynamically generated content is refreshed
  7.  
  8. select_module.setVisible(true);
  9. select_assessment.setVisible(false); // ensuring correct window is displayed
  10. fb_sub_display.setVisible(false);
  11.  
  12. select_module.setPreferredSize(new Dimension(875, 600));
  13. select_module.setLayout(new BorderLayout(20, 20));
  14.  
  15. JLabel modlabel = null;
  16. JButton newuser = new JButton("<html>Add New User");
  17. //newuser.setMaximumSize(new Dimension(100, 60));
  18.  
  19. if (role.equals("1")) // admin
  20. {
  21. modlabel = new JLabel("<html><body>Signed in as admin " + username
  22. + ".<br>Modules available:</body></html>");
  23. }
  24. else if (role.equals("2")) // student
  25. {
  26. modlabel = new JLabel("<html><body>Signed in as user " + username
  27. + ".<br>You are taking the following modules:</body></html>");
  28. }
  29. else if (role.equals("3") || role.equals("4")) // module leader or teacher
  30. {
  31. modlabel = new JLabel("<html><body>Signed in as user " + username
  32. + ".<br>You are delivering the following modules:</body></html>");
  33. }
  34.  
  35.  
  36. select_module.add(modlabel, BorderLayout.PAGE_START);
  37.  
  38. select_module.add(Box.createRigidArea(new Dimension(30, 200)), BorderLayout.LINE_START);
  39.  
  40. final JList modList = new JList(modulesTaken());
  41. modList.setSize(200, 500);
  42.  
  43. MouseListener mouseListener = new MouseAdapter()
  44. {
  45. public void mouseClicked(MouseEvent e)
  46. {
  47. try
  48. {
  49. if (e.getClickCount() == 2) // double click
  50. {
  51. int index = modList.locationToIndex(e.getPoint());
  52. selectAssessmentScreen(modList.getSelectedValue().toString()); // passing moduleID
  53. }
  54. }
  55. catch(Exception exc)
  56. { System.out.println(exc); }
  57. }
  58. };
  59. modList.addMouseListener(mouseListener);
  60.  
  61. JScrollPane scrollPane = new JScrollPane(modList);
  62. scrollPane.setSize(new Dimension(200, 500));
  63.  
  64. select_module.add(scrollPane, BorderLayout.CENTER);
  65. JPanel side = new JPanel();
  66. JLabel explanation = new JLabel("<html><body>Welcome, " + userRole(role) + " " + username
  67. + ".<br><br>Feedback on homework assignments "
  68. + "may be<br>accessed through this interface.<br><br>"
  69. + "Select a module from the list by double-clicking it.</body></html>");
  70.  
  71. side.setLayout(new BoxLayout(side, BoxLayout.Y_AXIS));
  72. side.add(explanation);side.add(newuser);
  73. //newuser.setAlignmentX(Component.LEFT_ALIGNMENT);
  74. select_module.add(side, BorderLayout.LINE_END);
  75.  
  76. //select_module.add(explanation, BorderLayout.LINE_END);
  77. select_module.add(Box.createRigidArea(new Dimension(0, 50)), BorderLayout.PAGE_END);
  78. //select_module.add(newuser, BorderLayout.AFTER_LAST_LINE);
  79. container.add(select_module);
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement