FileDocCategorySizeDatePackage
GlobalControls.javaAPI DocExample5497Wed Aug 08 15:13:48 BST 2001None

GlobalControls

public class GlobalControls extends JPanel implements ItemListener, ChangeListener
Global Controls panel for changing graphic attributes of the demo surface.

Fields Summary
static String[]
screenNames
static JComboBox
screenCombo
public TextureChooser
texturechooser
public JCheckBox
aliasCB
public JCheckBox
renderCB
public JCheckBox
toolBarCB
public JCheckBox
compositeCB
public JCheckBox
textureCB
public JSlider
slider
public Object
obj
private Font
font
Constructors Summary
public GlobalControls()



      
        setLayout(new GridBagLayout());
        setBorder(new TitledBorder(new EtchedBorder(), "Global Controls"));

        aliasCB = createCheckBox("Anti-Aliasing", true, 0);
        renderCB = createCheckBox("Rendering Quality", false, 1);
        textureCB = createCheckBox("Texture", false, 2);
        compositeCB = createCheckBox("AlphaComposite", false, 3);

        screenCombo = new JComboBox();
        screenCombo.setPreferredSize(new Dimension(120, 18));
        screenCombo.setLightWeightPopupEnabled(true);
        screenCombo.setFont(font);
        for (int i = 0; i < screenNames.length; i++) {
            screenCombo.addItem(screenNames[i]);
        } 
        screenCombo.addItemListener(this);
        Java2Demo.addToGridBag(this, screenCombo, 0, 4, 1, 1, 0.0, 0.0);

        toolBarCB = createCheckBox("Tools", false, 5);

        slider = new JSlider(JSlider.HORIZONTAL, 0, 200, 30);
        slider.addChangeListener(this);
        TitledBorder tb = new TitledBorder(new EtchedBorder());
        tb.setTitleFont(font);
        tb.setTitle("Anim delay = 30 ms");
        slider.setBorder(tb);
        slider.setMinimumSize(new Dimension(80,46));
        Java2Demo.addToGridBag(this, slider, 0, 6, 1, 1, 1.0, 1.0);

        texturechooser = new TextureChooser(0);
        Java2Demo.addToGridBag(this, texturechooser, 0, 7, 1, 1, 1.0, 1.0);
    
Methods Summary
private javax.swing.JCheckBoxcreateCheckBox(java.lang.String s, boolean b, int y)

        JCheckBox cb = new JCheckBox(s, b);
        cb.setFont(font);
        cb.setHorizontalAlignment(JCheckBox.LEFT);
        cb.addItemListener(this);
        Java2Demo.addToGridBag(this, cb, 0, y, 1, 1, 1.0, 1.0);
        return cb;
    
public java.awt.DimensiongetPreferredSize()

        return new Dimension(135,260);
    
public voiditemStateChanged(java.awt.event.ItemEvent e)

        if (Java2Demo.tabbedPane.getSelectedIndex() != 0) {
            obj = e.getSource();
            int index = Java2Demo.tabbedPane.getSelectedIndex()-1;
            Java2Demo.group[index].setup(true);
            obj = null;
        }
    
public voidstateChanged(javax.swing.event.ChangeEvent e)

        int value = slider.getValue();
        TitledBorder tb = (TitledBorder) slider.getBorder();
        tb.setTitle("Anim delay = " + String.valueOf(value) + " ms");
        int index = Java2Demo.tabbedPane.getSelectedIndex()-1;
        DemoGroup dg = Java2Demo.group[index];
        JPanel p = dg.getPanel();
        for (int i = 0; i < p.getComponentCount(); i++) {
            DemoPanel dp = (DemoPanel) p.getComponent(i);
            if (dp.tools != null && dp.tools.slider != null) {
                dp.tools.slider.setValue(value);
            }
        } 
        slider.repaint();