home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / J A V A / Java Development Kit V1.2 / jdk12-win32(1).exe / data1.cab / demos / demo / jfc / Java2D / Controls.java < prev    next >
Encoding:
Java Source  |  1998-12-01  |  3.5 KB  |  111 lines

  1. /*
  2.  * @(#)Controls.java    1.16 98/09/21
  3.  *
  4.  * Copyright 1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15.  
  16. import java.awt.Component;
  17. import java.awt.Dimension;
  18. import java.awt.GridBagLayout;
  19. import java.awt.GridBagConstraints;
  20. import java.awt.Font;
  21. import javax.swing.JPanel;
  22. import javax.swing.JCheckBox;
  23. import javax.swing.JComboBox;
  24. import java.awt.event.ItemListener;
  25. import java.awt.event.ItemEvent;
  26. import javax.swing.border.TitledBorder;
  27. import javax.swing.border.EtchedBorder;
  28.  
  29.  
  30. /**
  31.  * Global Controls panel for changing graphic attributes of
  32.  * the demo surface.
  33.  */
  34. public class Controls extends JPanel implements ItemListener {
  35.  
  36.     public TextureChooser texturechooser;
  37.     public JCheckBox aliasCB, renderCB, toolBarCB;
  38.     public JCheckBox compositeCB, textureCB;
  39.     public JCheckBox verboseCB;
  40.     public JComboBox imgTypeCombo;
  41.  
  42.     private Font font = new Font("serif", Font.PLAIN, 10);
  43.  
  44.  
  45.     public Controls() {
  46.         setLayout(new GridBagLayout());
  47.         setBorder(new TitledBorder(new EtchedBorder(), "Global Controls"));
  48.  
  49.         aliasCB = createCheckBox("Anti-Aliasing", true, 0);
  50.         renderCB = createCheckBox("Rendering Quality", false, 1);
  51.         textureCB = createCheckBox("Texture", false, 2);
  52.         compositeCB = createCheckBox("AlphaComposite", false, 3);
  53.  
  54.         imgTypeCombo = new JComboBox();
  55.         imgTypeCombo.setPreferredSize(new Dimension(120, 18));
  56.         imgTypeCombo.setFont(font);
  57.         imgTypeCombo.addItem("Auto Screen");
  58.         imgTypeCombo.addItem("On Screen");
  59.         imgTypeCombo.addItem("Off Screen");
  60.         imgTypeCombo.addItem("INT_RGB");
  61.         imgTypeCombo.addItem("INT_ARGB");
  62.         imgTypeCombo.addItem("INT_ARGB_PRE");
  63.         imgTypeCombo.addItem("INT_BGR");
  64.         imgTypeCombo.addItem("3BYTE_BGR");
  65.         imgTypeCombo.addItem("4BYTE_ABGR");
  66.         imgTypeCombo.addItem("4BYTE_ABGR_PRE");
  67.         imgTypeCombo.addItem("USHORT_565_RGB");
  68.         imgTypeCombo.addItem("USHORT_555_RGB");
  69.         imgTypeCombo.addItem("BYTE_GRAY");
  70.         imgTypeCombo.addItem("USHORT_GRAY");
  71.         imgTypeCombo.addItem("BYTE_BINARY");
  72.         imgTypeCombo.setSelectedIndex(0);
  73.         imgTypeCombo.addItemListener(this);
  74.         Java2Demo.addToGridBag(this, imgTypeCombo, 0, 4, 1, 1, 0.0, 0.0);
  75.  
  76.         toolBarCB = createCheckBox("ToolBar", false, 5);
  77.         verboseCB = createCheckBox("Verbose", false, 6);
  78.  
  79.         texturechooser = new TextureChooser(0);
  80.         Java2Demo.addToGridBag(this, texturechooser, 0, 7, 1, 1, 1.0, 1.0);
  81.     }
  82.  
  83.  
  84.     private JCheckBox createCheckBox(String s, boolean b, int y) {
  85.         JCheckBox cb = new JCheckBox(s, b);
  86.         cb.setFont(font);
  87.         cb.setHorizontalAlignment(JCheckBox.LEFT);
  88.         cb.addItemListener(this);
  89.         Java2Demo.addToGridBag(this, cb, 0, y, 1, 1, 1.0, 1.0);
  90.         return cb;
  91.     }
  92.  
  93.  
  94.     public void itemStateChanged(ItemEvent e) {
  95.         Java2Demo.group[Java2Demo.tabbedPane.getSelectedIndex()].setup(true);
  96.     }
  97.  
  98.  
  99.     public Dimension getMinimumSize() {
  100.         return getPreferredSize();
  101.     }
  102.  
  103.     public Dimension getMaximumSize() {
  104.         return getPreferredSize();
  105.     }
  106.  
  107.     public Dimension getPreferredSize() {
  108.         return new Dimension(140,240);
  109.     }
  110. }
  111.