Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void selectModuleScreen() throws Exception
- {
- // construction of module selection GUI
- select_module.removeAll();
- select_module.revalidate(); // ensuring dynamically generated content is refreshed
- select_module.setVisible(true);
- select_assessment.setVisible(false); // ensuring correct window is displayed
- fb_sub_display.setVisible(false);
- select_module.setPreferredSize(new Dimension(875, 600));
- select_module.setLayout(new BorderLayout(20, 20));
- JLabel modlabel = null;
- JButton newuser = new JButton("<html>Add New User");
- //newuser.setMaximumSize(new Dimension(100, 60));
- if (role.equals("1")) // admin
- {
- modlabel = new JLabel("<html><body>Signed in as admin " + username
- + ".<br>Modules available:</body></html>");
- }
- else if (role.equals("2")) // student
- {
- modlabel = new JLabel("<html><body>Signed in as user " + username
- + ".<br>You are taking the following modules:</body></html>");
- }
- else if (role.equals("3") || role.equals("4")) // module leader or teacher
- {
- modlabel = new JLabel("<html><body>Signed in as user " + username
- + ".<br>You are delivering the following modules:</body></html>");
- }
- select_module.add(modlabel, BorderLayout.PAGE_START);
- select_module.add(Box.createRigidArea(new Dimension(30, 200)), BorderLayout.LINE_START);
- final JList modList = new JList(modulesTaken());
- modList.setSize(200, 500);
- MouseListener mouseListener = new MouseAdapter()
- {
- public void mouseClicked(MouseEvent e)
- {
- try
- {
- if (e.getClickCount() == 2) // double click
- {
- int index = modList.locationToIndex(e.getPoint());
- selectAssessmentScreen(modList.getSelectedValue().toString()); // passing moduleID
- }
- }
- catch(Exception exc)
- { System.out.println(exc); }
- }
- };
- modList.addMouseListener(mouseListener);
- JScrollPane scrollPane = new JScrollPane(modList);
- scrollPane.setSize(new Dimension(200, 500));
- select_module.add(scrollPane, BorderLayout.CENTER);
- JPanel side = new JPanel();
- JLabel explanation = new JLabel("<html><body>Welcome, " + userRole(role) + " " + username
- + ".<br><br>Feedback on homework assignments "
- + "may be<br>accessed through this interface.<br><br>"
- + "Select a module from the list by double-clicking it.</body></html>");
- side.setLayout(new BoxLayout(side, BoxLayout.Y_AXIS));
- side.add(explanation);side.add(newuser);
- //newuser.setAlignmentX(Component.LEFT_ALIGNMENT);
- select_module.add(side, BorderLayout.LINE_END);
- //select_module.add(explanation, BorderLayout.LINE_END);
- select_module.add(Box.createRigidArea(new Dimension(0, 50)), BorderLayout.PAGE_END);
- //select_module.add(newuser, BorderLayout.AFTER_LAST_LINE);
- container.add(select_module);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement