Hi,

as the enclosed code snippet shows, the background of a non-editable  
ULCTextComponent
cannot be visually changed by setBackground(Color col).

So my questions:

1) Is there a way to manipulate the background color of a non-editable  
ULCTextComponent ?

2) How can the default background color of a noneditable ULCTextComponent be 
determined (on the serverside) ?


Thanks a lot
-- Christoph

import com.ulcjava.base.application.*;
import com.ulcjava.base.application.util.*;
import com.ulcjava.base.application.event.*;
import com.ulcjava.base.development.DevelopmentRunner;

import javax.swing.UIManager;

/**
 * The code snippet shows that for non-editable ULCTextComponents the 
background color cannot be visually changed
 * by setBackground(Color col):
 *
 * 1) How can the background color of a non-editable ULCTextComponent be 
changed ?
 *
 * 2) How can the default background color of a noneditable ULCTextComponent be 
determined (on the serverside) ?
 *
 * Version: ULC 6.0.4, java 1.5
 *
 * Thanks for your support.
 * --Christoph  , 24.05.2006
 */

public class Test extends AbstractApplication {

  ULCFrame frame = new ULCFrame("Code snippet - Display only Fields and 
Background Color");
  ULCBoxPane rootBox = new ULCBoxPane(true) ;

  ULCBoxPane txtBox  = new ULCBoxPane();
  ULCTextField txtField1 = new ULCTextField();
  ULCTextField txtField2 = new ULCTextField();

  ULCButton  button1        = new ULCButton("Toggle Background Color of Input 
Field");
  ULCButton  button2   = new ULCButton("Toggle Background Color of Display 
Field");

  public void start() {
    frame.setDefaultCloseOperation(ULCFrame.TERMINATE_ON_CLOSE);
    frame.setSize(new Dimension(800, 600));
    frame.add(rootBox);
    rootBox.add(ULCBoxPane.BOX_EXPAND_CENTER, txtBox);
    rootBox.add(ULCBoxPane.BOX_EXPAND_EXPAND, new ULCFiller());

    // text Box 
-------------------------------------------------------------------------------------------
    txtBox.setColumns(2);
    txtBox.setRows(2);
    txtBox.setBorder(BorderFactory.createTitledBorder("Display only Fields and 
Background Color"));

    txtBox.add(ULCBoxPane.BOX_LEFT_CENTER, button1);  
txtBox.add(ULCBoxPane.BOX_EXPAND_CENTER, txtField1);
    txtBox.add(ULCBoxPane.BOX_LEFT_CENTER, button2);  
txtBox.add(ULCBoxPane.BOX_EXPAND_CENTER, txtField2);

    final Color highlight = Color.yellow;

    final Color backgroundColor1 = txtField1.getBackground();

    button1.addActionListener(new IActionListener() {
      public void actionPerformed(ActionEvent e) {
        if (txtField1.getBackground() == backgroundColor1) 
txtField1.setBackground(highlight);
        else txtField1.setBackground(backgroundColor1);
        txtField1.setText( txtField1.getBackground().toString() );
      }
    });

    txtField2.setEditable(false);
    final Color backgroundColor2 = txtField2.getBackground();

    button2.addActionListener(new IActionListener() {
      public void actionPerformed(ActionEvent e) {
        if (txtField2.getBackground() == backgroundColor2) 
txtField2.setBackground(highlight);
        else txtField2.setBackground(backgroundColor2);
        txtField2.setText( txtField2.getBackground().toString() );
      }
    });

    // 
------------------------------------------------------------------------------------------------------
    frame.setVisible(true);
  }

  public static final String METAL   = 
"javax.swing.plaf.metal.MetalLookAndFeel";
  public static final String MOTIF   = 
"com.sun.java.swing.plaf.motif.MotifLookAndFeel";
  public static final String WINDOWS = 
"com.sun.java.swing.plaf.windows.WindowsLookAndFeel";

  public static void main(String[] args) {
    try {
      UIManager.setLookAndFeel(WINDOWS);
    }
    catch (Exception ex) {}
    DevelopmentRunner.setApplicationClass(Test.class);
    DevelopmentRunner.main(args);
  }

}

Reply via email to