arcgissamples\cartography\propertypage\ValenceRendererPropertyPageUI.java
/* Copyright 2010 ESRI * * All rights reserved under the copyright laws of the United States * and applicable international laws, treaties, and conventions. * * You may freely redistribute and use this sample code, with or * without modification, provided you include the original copyright * notice and use restrictions. * * See the use restrictions. * */ package arcgissamples.cartography.propertypage; import java.awt.Color; import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JColorChooser; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.UIManager; import javax.swing.border.TitledBorder; import com.esri.arcgis.system.AoInitialize; import com.esri.arcgis.system.EngineInitializer; import com.esri.arcgis.system.esriLicenseProductCode; import com.esri.arcgis.system.esriLicenseStatus; public class ValenceRendererPropertyPageUI extends JFrame implements ActionListener { private JPanel jContentPane = null; private JPanel jPanel = null; public JLabel jLabel1 = null; public JLabel jLabel2 = null; public JLabel jLabel3 = null; public JLabel jLabel4 = null; public JLabel jLabel5 = null; public JLabel jLabel6 = null; private JTextField jTextField1 = null; private JTextField jTextField2 = null; private JTextField jTextField3 = null; private JTextField jTextField4 = null; private JButton jButton1 = null; private JButton jButton2 = null; private JButton jButton3 = null; private JButton jButton4 = null; static AoInitialize aoInit; Color bgColor0; Color bgColor1; Color bgColor2; Color bgColor3; /** * This is the default constructor */ public ValenceRendererPropertyPageUI() throws Exception { super(); initialize(); } /** * This method initializes this * @return void */ private void initialize() throws Exception { this.setSize(459, 263); this.setResizable(false); this.setContentPane(getJContentPane()); this.setTitle("Valence Property Page"); } /** * This method initializes jContentPane * @return javax.swing.JPanel */ private JPanel getJContentPane() throws Exception { if (jContentPane == null) { jContentPane = new JPanel(); jContentPane.setLayout(null); jContentPane.add(getJPanel(), null); } return jContentPane; } static { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { e.printStackTrace(); } } /** * This method initializes jPanel * @return javax.swing.JPanel */ private JPanel getJPanel() { if (jPanel == null) { jLabel6 = new JLabel(); jLabel6.setBounds(new Rectangle(35, 158, 58, 20)); jLabel6.setText("Color4"); jLabel5 = new JLabel(); jLabel5.setBounds(new Rectangle(34, 126, 59, 20)); jLabel5.setText("Color3"); jLabel4 = new JLabel(); jLabel4.setBounds(new Rectangle(33, 96, 60, 20)); jLabel4.setText("Color2"); jLabel3 = new JLabel(); jLabel3.setBounds(new Rectangle(32, 69, 60, 20)); jLabel3.setText("Color1"); jLabel2 = new JLabel(); jLabel2.setBounds(new Rectangle(122, 29, 70, 25)); jLabel2.setText("RGB Value"); jLabel1 = new JLabel(); jLabel1.setText("Color Name"); jLabel1.setBounds(new Rectangle(22, 29, 79, 26)); jPanel = new JPanel(); jPanel.setLayout(null); jPanel.setBounds(new Rectangle(42, 21, 384, 207)); TitledBorder titled = new TitledBorder("Display Colors"); jPanel.setBorder(titled); jPanel.add(jLabel1, null); jPanel.add(jLabel2, null); jPanel.add(jLabel3, null); jPanel.add(jLabel4, null); jPanel.add(jLabel5, null); jPanel.add(jLabel6, null); jPanel.add(getJTextField1(), null); jPanel.add(getJTextField2(), null); jPanel.add(getJTextField3(), null); jPanel.add(getJTextField4(), null); jPanel.add(getJButton1(), null); jPanel.add(getJButton12(), null); jPanel.add(getJButton3(), null); jPanel.add(getJButton4(), null); } return jPanel; } /** * This method initializes jTextField1 * @return javax.swing.JTextField */ public JTextField getJTextField1() { if (jTextField1 == null) { jTextField1 = new JTextField(); jTextField1.setBounds(new Rectangle(121, 67, 70, 24)); } return jTextField1; } /** * This method initializes jTextField2 * @return javax.swing.JTextField */ public JTextField getJTextField2() { if (jTextField2 == null) { jTextField2 = new JTextField(); jTextField2.setBounds(new Rectangle(122, 97, 70, 23)); } return jTextField2; } /** * This method initializes jTextField3 * @return javax.swing.JTextField */ public JTextField getJTextField3() { if (jTextField3 == null) { jTextField3 = new JTextField(); jTextField3.setBounds(new Rectangle(122, 128, 70, 24)); } return jTextField3; } /** * This method initializes jTextField4 * @return javax.swing.JTextField */ public JTextField getJTextField4() { if (jTextField4 == null) { jTextField4 = new JTextField(); jTextField4.setBounds(new Rectangle(122, 160, 69, 20)); } return jTextField4; } /** * This method initializes jButton1 * @return javax.swing.JButton */ private JButton getJButton1() { if (jButton1 == null) { jButton1 = new JButton(); jButton1.setBounds(new Rectangle(209, 68, 100, 23)); jButton1.setText("Change Color"); jButton1.addActionListener(this); } return jButton1; } /** * This method initializes jButton12 * @return javax.swing.JButton */ private JButton getJButton12() { if (jButton2 == null) { jButton2 = new JButton(); jButton2.setBounds(new Rectangle(210, 97, 99, 23)); jButton2.setText("Change Color"); jButton2.addActionListener(this); } return jButton2; } /** * This method initializes jButton3 * @return javax.swing.JButton */ private JButton getJButton3() { if (jButton3 == null) { jButton3 = new JButton(); jButton3.setBounds(new Rectangle(211, 126, 99, 23)); jButton3.setText("Change Color"); jButton3.addActionListener(this); } return jButton3; } /** * This method initializes jButton4 * @return javax.swing.JButton */ private JButton getJButton4() { if (jButton4 == null) { jButton4 = new JButton(); jButton4.setBounds(new Rectangle(211, 158, 99, 23)); jButton4.setText("Change Color"); jButton4.addActionListener(this); } return jButton4; } public void actionPerformed(ActionEvent e) { try { if (e.getSource() == jButton1) { bgColor0 = JColorChooser.showDialog(this, "Choose Color",getForeground()); jLabel3.setForeground(bgColor0); jTextField1.setText(new Integer(bgColor0.getRGB()).toString()); jTextField1.setEnabled(false); } else if (e.getSource() == jButton2) { bgColor1 = JColorChooser.showDialog(this, "Choose Color",getForeground()); jLabel4.setForeground(bgColor1); jTextField2.setText(new Integer(bgColor1.getRGB()).toString()); jTextField2.setEnabled(false); } else if (e.getSource() == jButton3) { bgColor2 = JColorChooser.showDialog(this, "Choose Color",getForeground()); jLabel5.setForeground(bgColor2); jTextField3.setText(new Integer(bgColor2.getRGB()).toString()); jTextField3.setEnabled(false); } else if (e.getSource() == jButton4) { bgColor3 = JColorChooser.showDialog(this, "Choose Color",getForeground()); jLabel6.setForeground(bgColor3); jTextField4.setText(new Integer(bgColor3.getRGB()).toString()); jTextField4.setEnabled(false); } } catch (Exception ex) { ex.printStackTrace(); } } public static void main(String[] args) throws Exception { EngineInitializer.initializeVisualBeans(); UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); initializeArcGISLicenses(); ValenceRendererPropertyPageUI thisClass; try { thisClass = new ValenceRendererPropertyPageUI(); thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); thisClass.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } static void initializeArcGISLicenses() { try { aoInit = new AoInitialize(); if (aoInit.isProductCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeArcView) == esriLicenseStatus.esriLicenseAvailable) aoInit.initialize(esriLicenseProductCode.esriLicenseProductCodeArcView); } catch (Exception e) {e.printStackTrace();} } }