package gradertool.charts; import javax.swing.*; import java.awt.*; import java.awt.event.*; /** * Histogram GUI that represents section 2.6.1 of the requirements. * The histogram has a generic picture of the histogram and a check * box to allow +/- grading or not. The user cannot move the letter * grade bars because that would require more work than this milestone * required. * @author crahm */ public class Histogram extends JFrame { private boolean checkB; /** * Constructor for histogram GUI */ public Histogram() { Box whole = new Box(BoxLayout.Y_AXIS); Box filler = new Box(BoxLayout.X_AXIS); filler.setMaximumSize(new Dimension(500, 23)); Box image = new Box(BoxLayout.X_AXIS); Box checker = new Box(BoxLayout.X_AXIS); JLabel imLab = new JLabel(new ImageIcon("gradertool/charts/images/histo_proto.jpg")); imLab.setMaximumSize(new Dimension(620, 850)); image.add(imLab); checkB = false; JCheckBox check = new JCheckBox("Allow +/- Grades", checkB); check.addActionListener(new AllowCheckListener()); checker.add(filler); checker.add(check); checker.setMaximumSize(new Dimension(660, 23)); whole.add(image); whole.add(checker); add(whole); setSize(new Dimension(620, 850)); setTitle("Histogram--CPE 308"); setVisible(true); } /** * The ActionListener for when the check box is checked/un-checked. */ private class AllowCheckListener implements ActionListener { /** * Method that models the action that the check box performs. * The check box changes the histogram picture to allow +/- grades. * @param e the action event, in this case checking/un-checking */ public void actionPerformed(ActionEvent e) { if(!checkB) { checkB = true; System.out.println("Check box: checked"); } else { checkB = false; System.out.println("Check box: unchecked"); } } } }