1 14 package org.compiere.plaf; 15 16 import java.awt.BorderLayout ; 17 import java.awt.Color ; 18 import java.awt.Cursor ; 19 import java.awt.Dialog ; 20 import java.awt.Dimension ; 21 import java.awt.FlowLayout ; 22 import java.awt.Frame ; 23 import java.awt.GridBagConstraints ; 24 import java.awt.GridBagLayout ; 25 import java.awt.Insets ; 26 import java.awt.Toolkit ; 27 import java.awt.event.ActionEvent ; 28 import java.awt.event.ActionListener ; 29 import java.util.ResourceBundle ; 30 31 import javax.swing.DefaultComboBoxModel ; 32 import javax.swing.JButton ; 33 import javax.swing.JCheckBox ; 34 import javax.swing.JComboBox ; 35 import javax.swing.JDialog ; 36 import javax.swing.JEditorPane ; 37 import javax.swing.JLabel ; 38 import javax.swing.JList ; 39 import javax.swing.JOptionPane ; 40 import javax.swing.JPasswordField ; 41 import javax.swing.JRadioButton ; 42 import javax.swing.JScrollPane ; 43 import javax.swing.JSplitPane ; 44 import javax.swing.JTable ; 45 import javax.swing.JTextArea ; 46 import javax.swing.JTextField ; 47 import javax.swing.JTextPane ; 48 import javax.swing.JTree ; 49 import javax.swing.LookAndFeel ; 50 import javax.swing.UIManager ; 51 import javax.swing.WindowConstants ; 52 import javax.swing.border.TitledBorder ; 53 import javax.swing.plaf.metal.MetalLookAndFeel ; 54 import javax.swing.plaf.metal.MetalTheme ; 55 56 import org.compiere.swing.CButton; 57 import org.compiere.swing.CCheckBox; 58 import org.compiere.swing.CComboBox; 59 import org.compiere.swing.CLabel; 60 import org.compiere.swing.CPanel; 61 import org.compiere.swing.CTabbedPane; 62 import org.compiere.swing.CTextField; 63 import org.compiere.swing.CToggleButton; 64 import org.compiere.util.Ini; 65 import org.compiere.util.MiniBrowser; 66 import org.compiere.util.ValueNamePair; 67 68 import sun.awt.AppContext; 69 70 78 public class CompierePLAFEditor extends JDialog 79 implements ActionListener 80 { 81 85 public CompierePLAFEditor() 86 { 87 super(); 88 init(false); 89 } 91 95 public CompierePLAFEditor (boolean showExample) 96 { 97 super(); 98 init(showExample); 99 } 101 106 public CompierePLAFEditor(Dialog owner, boolean showExample) 107 { 108 super(owner, "", true); 109 init(showExample); 110 } 112 117 public CompierePLAFEditor(Frame owner, boolean showExample) 118 { 119 super(owner, "", true); 120 init(showExample); 121 } 123 124 125 129 private void init (boolean showExample) 130 { 131 try 132 { 133 jbInit(); 134 dynInit(); 135 136 example.setVisible(showExample); 138 CompierePLAF.showCenterScreen(this); 139 } 140 catch(Exception e) 141 { 142 System.err.println("CompierePLAFEditor.init"); 143 e.printStackTrace(); 144 } 145 } 148 149 private boolean m_setting = false; 150 151 private boolean m_colorTest = false; 152 153 static ResourceBundle s_res = ResourceBundle.getBundle("org.compiere.plaf.PlafRes"); 154 static Object [] s_columns = new Object [] {"-0-", "-1-", "-2-", "-3-", "-O-", "-l-"}; 155 static Object [][] s_data = new Object [][] { 156 {"-00-", "-01-", "-02-", "-03-", "-0O-", "-0l-"}, 157 {"-10-", "-11-", "-12-", "-13-", "-1O-", "-1l-"}, 158 {"-20-", "-21-", "-22-", "-23-", "-2O-", "-2l-"}, 159 {"-30-", "-31-", "-32-", "-33-", "-3O-", "-3l-"}, 160 {"-O0-", "-O1-", "-O2-", "-O3-", "-OO-", "-Ol-"}, 161 {"-l0-", "-l1-", "-l2-", "-l3-", "-lO-", "-ll-"}}; 162 static Object [] s_pos = new Object [] {"Top", "Left", "Bottom", "Right"}; 163 164 private CPanel mainPanel = new CPanel(new BorderLayout ()); 165 private CPanel northPanel = new CPanel(); 166 private CPanel southPanel = new CPanel(); 167 private CButton bOK = CompierePLAF.getOKButton(); 168 private CButton bCancel = CompierePLAF.getCancelButton(); 169 private CButton bHelp = new CButton(); 170 private GridBagLayout northLayout = new GridBagLayout (); 171 private CLabel lfLabel = new CLabel(); 172 private CComboBox lfField = new CComboBox(CompierePLAF.getPLAFs()); 173 private CLabel themeLabel = new CLabel(); 174 private CComboBox themeField = new CComboBox(CompierePLAF.getThemes()); 175 private CButton cButton = new CButton(); 176 private FlowLayout southLayout = new FlowLayout (); 177 private CButton rButton = new CButton(); 178 private CButton bSetColor = new CButton(); 179 private CCheckBox cDefault = new CCheckBox(); 180 private CComboBox blindField = new CComboBox(ColorBlind.COLORBLIND_TYPE); 181 private CLabel blindLabel = new CLabel(); 182 private BorderLayout mainLayout = new BorderLayout (); 183 private CTabbedPane example = new CTabbedPane(); 185 private CPanel jPanel1 = new CPanel(); 186 private TitledBorder exampleBorder; 187 private CPanel jPanel2 = new CPanel(); 188 private JLabel jLabel1 = new JLabel (); 189 private JTextField jTextField1 = new JTextField (); 190 private JCheckBox jCheckBox1 = new JCheckBox (); 191 private JRadioButton jRadioButton1 = new JRadioButton (); 192 private CButton jButton1 = new CButton(); 193 private CToggleButton jToggleButton1 = new CToggleButton(); 194 private CComboBox jComboBox1 = new CComboBox(s_columns); 195 private JTextArea jTextArea1 = new JTextArea (); 196 private JTextPane jTextPane1 = new JTextPane (); 197 private JEditorPane jEditorPane1 = new JEditorPane (); 198 private JPasswordField jPasswordField1 = new JPasswordField (); 199 private JList jList1 = new JList (s_columns); 200 private JSplitPane jSplitPane1 = new JSplitPane (); 201 private BorderLayout borderLayout1 = new BorderLayout (); 202 private JScrollPane jScrollPane1 = new JScrollPane (); 203 private JTree jTree1 = new JTree (); 204 private JScrollPane jScrollPane2 = new JScrollPane (); 205 private JTable jTable1 = new JTable (s_data, s_columns); 206 private GridBagLayout gridBagLayout1 = new GridBagLayout (); 207 private CPanel jPanelFlat = new CPanel(new CompiereColor(new Color (255,205,255), true)); 208 private CPanel jPanelGradient = new CPanel(new CompiereColor(new Color (233,210,210), new Color (217,210,233))); 209 private CPanel jPanelTexture = new CPanel(new CompiereColor(CompiereColor.class.getResource("vincent.jpg"), Color.lightGray, 0.7f)); 210 private CPanel jPanelLines = new CPanel(new CompiereColor(new Color (178,181,205), new Color (193,193,205), 1.0f, 5)); 211 private JButton jButtonFlat = new JButton (); 212 private CButton jButtonGardient = new CButton(); 213 private JButton jButtonTexture = new JButton (); 214 private CButton jButtonLines = new CButton(); 215 private JComboBox jComboBoxFlat = new JComboBox (s_pos); 216 private JTextField jTextFieldFlat = new JTextField (); 217 private JLabel jLabelFlat = new JLabel (); 218 private CComboBox jComboBoxGradient = new CComboBox(s_pos); 219 private CTextField jTextFieldGradient = new CTextField(); 220 private CLabel jLabelGradient = new CLabel(); 221 private JComboBox jComboBoxTexture = new JComboBox (s_pos); 222 private JTextField jTextFieldTexture = new JTextField (); 223 private JLabel jLabelTexture = new JLabel (); 224 private CComboBox jComboBoxLines = new CComboBox(s_pos); 225 private CTextField jTextFieldLines = new CTextField(); 226 private CLabel jLabelLines = new CLabel(); 227 private CCheckBox jCheckBoxLines = new CCheckBox(); 228 private JCheckBox jCheckBoxTexture = new JCheckBox (); 229 private CCheckBox jCheckBoxGradient = new CCheckBox(); 230 private JCheckBox jCheckBoxFlat = new JCheckBox (); 231 232 236 private void jbInit() throws Exception 237 { 238 this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); 239 this.setTitle(s_res.getString("LookAndFeelEditor") + " " + CompierePLAF.VERSION); 240 mainPanel.setLayout(mainLayout); 241 mainLayout.setHgap(5); 242 mainLayout.setVgap(5); 243 jTextFieldFlat.setColumns(10); 244 jTextFieldGradient.setColumns(10); 245 jTextFieldTexture.setColumns(10); 246 jTextFieldLines.setColumns(10); 247 jCheckBoxLines.setText("jCheckBox"); 248 jCheckBoxTexture.setText("jCheckBox"); 249 jCheckBoxGradient.setText("jCheckBox"); 250 jCheckBoxFlat.setText("jCheckBox"); 251 jPanelGradient.setToolTipText("Indented Level 1"); 252 jPanelTexture.setToolTipText("Indented Level 2"); 253 jPanelLines.setToolTipText("Indented Level 1"); 254 this.getContentPane().add(mainPanel, BorderLayout.CENTER); 255 CompiereColor.setBackground(this); 256 lfLabel.setText(s_res.getString("LookAndFeel")); 258 lfField.addActionListener(this); 259 themeLabel.setText(s_res.getString("Theme")); 260 themeField.addActionListener(this); 261 cButton.setText(s_res.getString("EditCompiereTheme")); 262 cButton.addActionListener(this); 263 rButton.setText(s_res.getString("Reset")); 264 rButton.addActionListener(this); 265 cDefault.setText(s_res.getString("SetDefault")); 266 cDefault.addActionListener(this); 267 bSetColor.setText(s_res.getString("SetDefaultColor")); 268 bSetColor.addActionListener(this); 269 blindLabel.setText(s_res.getString("ColorBlind")); 270 blindField.addActionListener(this); 271 bOK.addActionListener(this); 273 bCancel.addActionListener(this); 274 bHelp.addActionListener(this); 275 northPanel.setLayout(northLayout); 277 southPanel.setLayout(southLayout); 278 southLayout.setAlignment(FlowLayout.RIGHT); 279 exampleBorder = new TitledBorder (s_res.getString("Example")); 281 example.setBorder(exampleBorder); 282 283 jLabel1.setText("jLabel"); 284 jTextField1.setText("jTextField"); 285 jCheckBox1.setText("jCheckBox"); 286 jRadioButton1.setText("jRadioButton"); 287 jButton1.setText("jButton"); 288 jToggleButton1.setText("jToggleButton"); 289 jTextArea1.setText("jTextArea"); 290 jTextPane1.setText("jTextPane"); 291 jEditorPane1.setText("jEditorPane"); 292 jPasswordField1.setText("jPasswordField"); 293 jPanel2.setLayout(borderLayout1); 294 jPanel1.setLayout(gridBagLayout1); 295 jScrollPane1.setPreferredSize(new Dimension (100, 200)); 296 jScrollPane2.setPreferredSize(new Dimension (100, 200)); 297 jButtonFlat.setText("Confirm"); 298 jButtonGardient.setText("Input"); 299 jButtonTexture.setText("Message"); 300 jButtonLines.setText("Error"); 301 jTextFieldFlat.setText("jTextField"); 302 jLabelFlat.setText("jLabel"); 303 jTextFieldGradient.setText("jTextField"); 304 jLabelGradient.setText("jLabel"); 305 jTextFieldTexture.setText("jTextField"); 306 jLabelTexture.setText("jLabel"); 307 jTextFieldLines.setText("jTextField"); 308 jLabelLines.setText("jLabel"); 309 mainPanel.add(northPanel, BorderLayout.NORTH); 310 northPanel.add(lfLabel, new GridBagConstraints (0, 0, 1, 1, 0.0, 0.0 311 ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets (12, 12, 5, 5), 0, 0)); 312 northPanel.add(lfField, new GridBagConstraints (1, 0, 1, 1, 0.0, 0.0 313 ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets (12, 0, 5, 12), 0, 0)); 314 northPanel.add(themeLabel, new GridBagConstraints (0, 1, 1, 1, 0.0, 0.0 315 ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets (0, 12, 5, 5), 0, 0)); 316 northPanel.add(themeField, new GridBagConstraints (1, 1, 1, 1, 0.0, 0.0 317 ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets (0, 0, 5, 12), 0, 0)); 318 northPanel.add(cButton, new GridBagConstraints (1, 2, 1, 1, 0.0, 0.0 319 ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets (5, 0, 5, 12), 0, 0)); 320 northPanel.add(rButton, new GridBagConstraints (0, 2, 1, 1, 0.0, 0.0 321 ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets (5, 12, 5, 5), 0, 0)); 322 northPanel.add(bSetColor, new GridBagConstraints (1, 3, 1, 1, 0.0, 0.0 323 ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets (5, 0, 5, 12), 0, 0)); 324 northPanel.add(cDefault, new GridBagConstraints (0, 3, 1, 1, 0.0, 0.0 325 ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets (5, 12, 5, 5), 0, 0)); 326 northPanel.add(blindField, new GridBagConstraints (1, 4, 1, 1, 0.0, 0.0 327 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets (5, 0, 5, 12), 0, 0)); 328 northPanel.add(blindLabel, new GridBagConstraints (0, 4, 1, 1, 0.0, 0.0 329 ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets (5, 12, 5, 5), 0, 0)); 330 mainPanel.add(southPanel, BorderLayout.SOUTH); 331 southPanel.add(bCancel, null); 332 southPanel.add(bOK, null); 333 mainPanel.add(example, BorderLayout.CENTER); 334 example.add(jPanel1, "JPanel"); 335 jPanel1.add(jTextPane1, new GridBagConstraints (2, 3, 1, 1, 0.0, 0.2 336 ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets (5, 5, 5, 5), 0, 0)); 337 jPanel1.add(jEditorPane1, new GridBagConstraints (1, 3, 1, 1, 0.0, 0.2 338 ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets (5, 5, 5, 5), 0, 0)); 339 jPanel1.add(jList1, new GridBagConstraints (1, 2, 1, 1, 0.0, 0.2 340 ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets (5, 5, 5, 5), 0, 0)); 341 jPanel1.add(jLabel1, new GridBagConstraints (0, 0, 1, 1, 0.0, 0.0 342 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets (5, 5, 5, 5), 0, 0)); 343 jPanel1.add(jTextField1, new GridBagConstraints (1, 0, 1, 1, 0.0, 0.0 344 ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets (5, 5, 5, 5), 0, 0)); 345 jPanel1.add(jCheckBox1, new GridBagConstraints (0, 1, 1, 1, 0.0, 0.0 346 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets (1, 1, 1, 1), 0, 0)); 347 jPanel1.add(jRadioButton1, new GridBagConstraints (1, 1, 1, 1, 0.0, 0.0 348 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets (5, 5, 5, 5), 0, 0)); 349 jPanel1.add(jButton1, new GridBagConstraints (2, 0, 1, 1, 0.0, 0.1 350 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets (5, 5, 5, 5), 0, 0)); 351 jPanel1.add(jToggleButton1, new GridBagConstraints (2, 1, 1, 1, 0.0, 0.1 352 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets (5, 5, 5, 5), 0, 0)); 353 jPanel1.add(jTextArea1, new GridBagConstraints (0, 3, 1, 1, 0.0, 0.2 354 ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets (5, 5, 5, 5), 0, 0)); 355 jPanel1.add(jComboBox1, new GridBagConstraints (0, 2, 1, 1, 0.0, 0.0 356 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets (5, 5, 5, 5), 0, 0)); 357 jPanel1.add(jPasswordField1, new GridBagConstraints (2, 2, 1, 1, 0.0, 0.0 358 ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets (5, 5, 5, 5), 0, 0)); 359 example.add(jPanel2, "JPanel"); 360 jPanel2.add(jSplitPane1, BorderLayout.CENTER); 361 jSplitPane1.add(jScrollPane1, JSplitPane.LEFT); 362 jSplitPane1.add(jScrollPane2, JSplitPane.RIGHT); 363 jPanelFlat.setName("FlatP"); 364 jPanelGradient.setName("GradientP"); 365 jPanelTexture.setName("TextureP"); 366 jPanelLines.setName("LineP"); 367 example.add(jPanelFlat, "jPanel Flat"); 368 jPanelFlat.add(jButtonFlat, null); 369 jPanelFlat.add(jComboBoxFlat, null); 370 example.add(jPanelGradient, "jPanel Gradient 1"); 371 jPanelGradient.add(jButtonGardient, null); 372 jPanelGradient.add(jComboBoxGradient, null); 373 jPanelGradient.add(jLabelGradient, null); 374 jPanelGradient.add(jTextFieldGradient, null); 375 example.add(jPanelTexture, "jPanel Texture 2"); 376 jPanelTexture.add(jButtonTexture, null); 377 jPanelTexture.add(jComboBoxTexture, null); 378 jPanelTexture.add(jLabelTexture, null); 379 jPanelTexture.add(jTextFieldTexture, null); 380 example.add(jPanelLines, "jPanel Lines 1"); 381 jPanelLines.add(jButtonLines, null); 382 jPanelLines.add(jComboBoxLines, null); 383 jPanelLines.add(jLabelLines, null); 384 jPanelLines.add(jTextFieldLines, null); 385 jScrollPane2.getViewport().add(jTable1, null); 386 jScrollPane1.getViewport().add(jTree1, null); 387 jPanelFlat.add(jLabelFlat, null); 388 jPanelFlat.add(jTextFieldFlat, null); 389 jPanelLines.add(jCheckBoxLines, null); 390 jPanelTexture.add(jCheckBoxTexture, null); 391 jPanelGradient.add(jCheckBoxGradient, null); 392 jPanelFlat.add(jCheckBoxFlat, null); 393 } 395 398 private void dynInit() 399 { 400 setLFSelection(); 401 jPanelGradient.setTabLevel(1); 403 jPanelTexture.setTabLevel(2); 404 jPanelLines.setTabLevel(1); 405 jComboBoxFlat.addActionListener(this); 407 jComboBoxGradient.addActionListener(this); 408 jComboBoxTexture.addActionListener(this); 409 jComboBoxLines.addActionListener(this); 410 jButton1.addActionListener(this); 412 jButtonFlat.addActionListener(this); 413 jButtonGardient.addActionListener(this); 414 jButtonTexture.addActionListener(this); 415 jButtonLines.addActionListener(this); 416 CompierePLAF.setPLAF(this); 418 } 420 423 private void setLFSelection() 424 { 425 m_setting = true; 426 ValueNamePair plaf = null; 428 LookAndFeel lookFeel = UIManager.getLookAndFeel(); 429 String look = lookFeel.getClass().getName(); 430 for (int i = 0; i < CompierePLAF.getPLAFs().length; i++) 431 { 432 ValueNamePair vp = CompierePLAF.getPLAFs()[i]; 433 if (vp.getValue().equals(look)) 434 { 435 plaf = vp; 436 break; 437 } 438 } 439 if (plaf != null) 440 lfField.setSelectedItem(plaf); 441 442 443 MetalTheme t = null; 445 ValueNamePair theme = null; 446 boolean metal = UIManager.getLookAndFeel() instanceof MetalLookAndFeel ; 447 themeField.setModel(new DefaultComboBoxModel (CompierePLAF.getThemes())); 448 if (metal) 449 { 450 theme = null; 451 AppContext context = AppContext.getAppContext(); 452 t = (MetalTheme )context.get("currentMetalTheme"); 453 if (t != null) 454 { 455 String lookTheme = t.getName(); 456 for (int i = 0; i < CompierePLAF.getThemes().length; i++) 457 { 458 ValueNamePair vp = CompierePLAF.getThemes()[i]; 459 if (vp.getName().equals(lookTheme)) 460 { 461 theme = vp; 462 break; 463 } 464 } 465 } 466 if (theme != null) 467 themeField.setSelectedItem(theme); 468 else 469 themeField.setSelectedIndex(0); 470 } 471 m_setting = false; 472 } 475 476 477 481 public void actionPerformed(ActionEvent e) 482 { 483 setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); 484 485 if (e.getSource() == bOK) 487 { 488 Ini.saveProperties(true); 489 dispose(); 490 } 491 else if (e.getSource() == bCancel) 493 { 494 dispose(); 495 } 496 else if (e.getSource() == bHelp) 497 { 498 new MiniBrowser("http://www.compiere.org/looks/help.html"); 499 } 500 501 else if (e.getSource() == lfField && !m_setting) 503 { 504 m_setting = true; CompierePLAF.setPLAF((ValueNamePair)lfField.getSelectedItem(), null, this); 507 setLFSelection(); 508 setBackgroundToTheme(); 509 CompierePLAF.setPLAF(this); m_setting = false; } 512 else if (e.getSource() == themeField && !m_setting) 514 { 515 Ini.setProperty(Ini.P_UI_THEME, themeField.getSelectedItem().toString()); 516 CompierePLAF.setPLAF((ValueNamePair)lfField.getSelectedItem(), (ValueNamePair)themeField.getSelectedItem(), this); 517 CompiereTheme.setTheme(); setBackgroundToTheme(); 519 CompierePLAF.setPLAF(this); } 521 522 else if (e.getSource() == cButton) 524 { 525 new CompiereThemeEditor(this); 526 setBackgroundToTheme(); 527 } 528 529 else if (e.getSource() == rButton) 531 { 532 CompierePLAF.reset(this); 533 setLFSelection(); 534 ColorBlind.setColorType(ColorBlind.NORMAL); 535 CompierePLAF.setPLAF(this); } 537 538 else if (e.getSource() == bSetColor) 540 { 541 CompiereColor cc = CompiereColorEditor.showDialog(this, CompierePanelUI.getDefaultBackground()); 542 CompierePanelUI.setDefaultBackground(cc); 543 CompierePLAF.updateUI(this); 544 Ini.setProperty(CompiereTheme.P_CompiereColor, cc.toString()); 545 } 546 else if (e.getSource() == cDefault) 548 { 549 CompierePanelUI.setSetDefault(cDefault.isSelected()); 550 CompierePLAF.updateUI(this); 551 } 552 else if (e.getSource() == blindField) 554 { 555 int sel = blindField.getSelectedIndex(); 556 if (sel != ColorBlind.getColorType()) 557 { 558 if (!m_colorTest) 560 { 561 m_colorTest = true; 562 int size = Toolkit.getDefaultToolkit().getColorModel().getPixelSize(); 563 if (size < 24) 564 JOptionPane.showMessageDialog(this, 565 "Your environment has only a pixel size of " + size 566 + ".\nTo see the effect, you need to have a pixel size of 24 (true color)", 567 "Insufficient Color Capabilities", 568 JOptionPane.ERROR_MESSAGE); 569 } 570 ColorBlind.setColorType(sel); 571 CompierePLAF.updateUI(this); 572 CompierePLAF.setPLAF(this); } 574 } 575 576 577 else if (e.getSource() == jComboBoxFlat || e.getSource() == jComboBoxGradient 579 || e.getSource() == jComboBoxTexture || e.getSource() == jComboBoxLines) 580 { 581 if (!m_setting) 582 { 583 m_setting = true; 584 int index = ((JComboBox )e.getSource()).getSelectedIndex(); 585 example.setTabPlacement(index+1); 586 jComboBoxFlat.setSelectedIndex(index); 587 jComboBoxGradient.setSelectedIndex(index); 588 jComboBoxTexture.setSelectedIndex(index); 589 jComboBoxLines.setSelectedIndex(index); 590 m_setting = false; 591 } 592 } 593 else if (e.getSource() == jButtonFlat) 595 JOptionPane.showConfirmDialog(this, "Confirm Dialog"); 596 else if (e.getSource() == jButtonGardient) 597 JOptionPane.showInputDialog(this, "Input Dialog"); 598 else if (e.getSource() == jButtonTexture) 599 JOptionPane.showMessageDialog(this, "Message Dialog"); 600 else if (e.getSource() == jButtonLines) 601 JOptionPane.showMessageDialog(this, "Message Dialog - Error", "Error", JOptionPane.ERROR_MESSAGE); 602 603 else if (e.getSource() == jButton1) 605 { 606 } 607 608 609 610 boolean metal = UIManager.getLookAndFeel() instanceof MetalLookAndFeel ; 612 themeField.setEnabled(metal); 613 themeLabel.setEnabled(metal); 614 615 boolean enable = metal 617 && CompiereLookAndFeel.NAME.equals(lfField.getSelectedItem().toString()) 618 && themeField.getSelectedItem() != null 619 && CompiereTheme.NAME.equals(themeField.getSelectedItem().toString()); 620 blindField.setEnabled(enable); 621 blindLabel.setEnabled(enable); 622 if (e.getSource() != blindField && !enable) 623 blindField.setSelectedIndex(0); 624 625 setCursor(Cursor.getDefaultCursor()); 627 } 629 632 private void setBackgroundToTheme() 633 { 634 boolean notFlat = UIManager.getLookAndFeel() instanceof MetalLookAndFeel 636 && CompiereLookAndFeel.NAME.equals(lfField.getSelectedItem().toString()) 637 && themeField.getSelectedItem() != null 638 && CompiereTheme.NAME.equals(themeField.getSelectedItem().toString()); 639 CompiereColor cc = new CompiereColor(CompiereTheme.secondary3, !notFlat); 640 CompierePanelUI.setDefaultBackground(cc); 641 Ini.setProperty(CompiereTheme.P_CompiereColor, cc.toString()); 642 CompierePLAF.updateUI(this); 643 } 645 646 650 public void dispose() 651 { 652 super.dispose(); 653 if (!isModal()) 654 System.exit(0); 655 } 657 } | Popular Tags |