FileDocCategorySizeDatePackage
DebugGraphicsPanel.javaAPI DocExample10526Sat Sep 12 03:01:00 BST 1998None

DebugGraphicsPanel

public class DebugGraphicsPanel extends JPanel
Debug Graphics!
version
1.4 02/02/98
author
Jeff Dinkins
author
Peter Korn (accessibility support)

Fields Summary
SwingSet
swing
JPanel
components
JButton
button
JRadioButton
radio
JCheckBox
check
JSlider
slider
JScrollBar
scrollbar
JSlider
flashSlider
JCheckBox
buttonCheckbox
JCheckBox
radioCheckbox
JCheckBox
checkboxCheckbox
JCheckBox
sliderCheckbox
JCheckBox
scrollbarCheckbox
DebugGraphicsListener
debugGraphicsListener
ChangeListener
sliderListener
Constructors Summary
public DebugGraphicsPanel(SwingSet swing)


       
	this.swing = swing;
	sliderListener = new ChangeListener() {
	    public void stateChanged(ChangeEvent e) {
		JSlider s = (JSlider)e.getSource();
		DebugGraphics.setFlashTime(s.getValue());
	    }
	};
	flashSlider.addChangeListener(sliderListener);
	

	setBorder(swing.emptyBorder5);
	setLayout(new BoxLayout(this, BoxLayout.X_AXIS));

	// *************** buttons ****************
	components = SwingSet.createVerticalPanel(true);
	components.setBorder(swing.emptyBorder10);

        button.setEnabled(false);
        radio.setEnabled(false);
        radio.setSelected(true);
        check.setEnabled(false);
        check.setSelected(true);
	
	// Add buttons to buttonPanel
	JPanel buttonPanel = swing.createHorizontalPanel(false);
	buttonPanel.setBorder(swing.etchedBorder10);
	buttonPanel.setAlignmentX(LEFT_ALIGNMENT);
	buttonPanel.setAlignmentY(TOP_ALIGNMENT);

	JLabel l = (JLabel) components.add(new JLabel("Buttons"));
	l.setFont(swing.boldFont);
	buttonPanel.add(button);
	buttonPanel.add(Box.createRigidArea(swing.hpad20));
	buttonPanel.add(radio);
	buttonPanel.add(Box.createRigidArea(swing.hpad20));
	buttonPanel.add(check);
	components.add(buttonPanel);
	components.add(Box.createRigidArea(swing.vpad20));

	// *************** slider ****************

        // slider.setEnabled(false);
	slider.setEnabled(false);
	slider.setPaintTicks(true);
	slider.setMinorTickSpacing(10);
	slider.setMajorTickSpacing(40);
	slider.getAccessibleContext().setAccessibleName("Sample slider");

	JPanel sliderPanel = new JPanel() {
	    public Dimension getMaximumSize() {
		return new Dimension(super.getMaximumSize().width, 60);
	    }
	};
	sliderPanel.setLayout(new BoxLayout(sliderPanel, BoxLayout.X_AXIS));
	sliderPanel.setBorder(swing.etchedBorder10);
	sliderPanel.setAlignmentX(LEFT_ALIGNMENT);
	sliderPanel.setAlignmentY(TOP_ALIGNMENT);

	l = (JLabel) components.add(new JLabel("Slider"));
	l.setFont(swing.boldFont);
	sliderPanel.add(slider);
	components.add(sliderPanel);
	components.add(Box.createRigidArea(swing.vpad20));

	// *************** scrollbar ****************

        scrollbar.setEnabled(false);
	scrollbar.getAccessibleContext().setAccessibleName("Sample scrollbarlider");

	JPanel scrollbarPanel = new JPanel() {
	    public Dimension getMaximumSize() {
		return new Dimension(super.getMaximumSize().width, 60);
	    }
	};
	scrollbarPanel.setLayout(new BoxLayout(scrollbarPanel, BoxLayout.Y_AXIS));
	scrollbarPanel.setBorder(swing.etchedBorder10);
	scrollbarPanel.setAlignmentX(LEFT_ALIGNMENT);
	scrollbarPanel.setAlignmentY(TOP_ALIGNMENT);

	JPanel box = swing.createHorizontalPanel(false);
	box.add(Box.createRigidArea(swing.hpad5));
	box.add(scrollbar);
	box.add(Box.createRigidArea(swing.hpad5));

	l = (JLabel) components.add(new JLabel("ScrollBar"));
	l.setFont(swing.boldFont);
	scrollbarPanel.add(Box.createRigidArea(swing.vpad5));
	scrollbarPanel.add(box);
	scrollbarPanel.add(Box.createRigidArea(swing.vpad5));
	components.add(scrollbarPanel);
	components.add(Box.createRigidArea(swing.vpad20));

	l = (JLabel) components.add(new JLabel("Note: the above components are intentionally disabled."));
	components.add(Box.createRigidArea(swing.vpad5));
	l = (JLabel) components.add(new JLabel("Choose a component checkbox at right, then click on"));
	l = (JLabel) components.add(new JLabel("the \"Repaint\" button to see debug graphics at work."));


	// ***** fill out the rest of the panel
	components.add(Box.createGlue());

	// *************** Create the debug graphics controls ****************
	JPanel controls = new JPanel() {
	    public Dimension getMaximumSize() {
		return new Dimension(300, super.getMaximumSize().height);
	    }
	};
	controls.setLayout(new BoxLayout(controls, BoxLayout.Y_AXIS));

	JPanel debugControls = swing.createHorizontalPanel(true);
	debugControls.setAlignmentY(TOP_ALIGNMENT);
	debugControls.setAlignmentX(LEFT_ALIGNMENT);

	JPanel leftColumn = swing.createVerticalPanel(false);
	leftColumn.setAlignmentX(LEFT_ALIGNMENT);
	leftColumn.setAlignmentY(TOP_ALIGNMENT);

	debugControls.add(leftColumn);
	debugControls.add(Box.createRigidArea(swing.hpad20));
	debugControls.add(Box.createRigidArea(swing.hpad20));

	controls.add(debugControls);

	// Display Options
	l = new JLabel("Use Debug Graphics On:");
	leftColumn.add(l);
	l.setFont(swing.boldFont);

 	buttonCheckbox.addItemListener(debugGraphicsListener);
	buttonCheckbox.setToolTipText("Turns DebugGraphics on or off.");
 	leftColumn.add(buttonCheckbox);

 	radioCheckbox.addItemListener(debugGraphicsListener);
	radioCheckbox.setToolTipText("Turns DebugGraphics on or off.");
 	leftColumn.add(radioCheckbox);

 	checkboxCheckbox.addItemListener(debugGraphicsListener);
	checkboxCheckbox.setToolTipText("Turns DebugGraphics on or off.");
 	leftColumn.add(checkboxCheckbox);

 	sliderCheckbox.addItemListener(debugGraphicsListener);
	sliderCheckbox.setToolTipText("Turns DebugGraphics on or off.");
 	leftColumn.add(sliderCheckbox);

 	scrollbarCheckbox.addItemListener(debugGraphicsListener);
	scrollbarCheckbox.setToolTipText("Turns DebugGraphics on or off.");
 	leftColumn.add(scrollbarCheckbox);

	// debug flashTime
	leftColumn.add(Box.createRigidArea(swing.vpad40));
	l = new JLabel("Debug Flash Interval:");
	l.setFont(swing.boldFont);
	leftColumn.add(l);
	leftColumn.add(flashSlider);
	flashSlider.setMaximumSize(new Dimension(150, 60));
	flashSlider.setPaintTicks(true);
	flashSlider.setMinorTickSpacing(5);
	flashSlider.setMajorTickSpacing(20);
	flashSlider.setToolTipText("Sets the sleep time between graphics operations, from 1 to 50 milliseconds");
	flashSlider.getAccessibleContext().setAccessibleName("Debug Flash Interval");

	// repaint button
	leftColumn.add(Box.createRigidArea(swing.vpad40));
 	JButton repaintButton = new JButton("Repaint");
	repaintButton.setToolTipText("Causes the selected components to be repainted using DebugGraphics.");
 	repaintButton.addActionListener(debugGraphicsListener);
 	leftColumn.add(repaintButton);
 	leftColumn.add(Box.createGlue());

	add(components);
	add(Box.createRigidArea(swing.hpad10));
 	add(controls);
    
Methods Summary
public voidresetAll()

	scrollbarCheckbox.setSelected(false);
	buttonCheckbox.setSelected(false);
	radioCheckbox.setSelected(false);
	sliderCheckbox.setSelected(false);
	checkboxCheckbox.setSelected(false);