How to change object background color on  java run time

Hi,
I create object loading program. my problem is run time i change object background color using color picker. i select any one color of color picker than submit. The selecting color not assign object background.
pls help me? How to run time change object background color?
here follwing code
import com.sun.j3d.loaders.objectfile.ObjectFile;
import com.sun.j3d.loaders.ParsingErrorException;
import com.sun.j3d.loaders.IncorrectFormatException;
import com.sun.j3d.loaders.Scene;
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.universe.*;
import javax.media.j3d.*;
import javax.vecmath.*;
import java.io.*;
import com.sun.j3d.utils.behaviors.vp.*;
import java.net.URL;
import java.net.MalformedURLException;
import java.awt.Graphics ;
import javax.swing.*;
public class ObjLoad1 extends Applet implements ActionListener
private boolean spin = false;
private boolean noTriangulate = false;
private boolean noStripify = false;
private double creaseAngle = 60.0;
private URL filename = null;
private SimpleUniverse u;
private BoundingSphere bounds;
private Panel cardPanel;
private Button Tit,sub;
private CardLayout ourLayout;
private BorderLayout bl;
Background bgNode;
BranchGroup objRoot;
List thelist;
Label l1;
public BranchGroup createSceneGraph()
BranchGroup objRoot = new BranchGroup();
TransformGroup objScale = new TransformGroup();
Transform3D t3d = new Transform3D();
t3d.setScale(0.7);
objScale.setTransform(t3d);
objRoot.addChild(objScale);
TransformGroup objTrans = new TransformGroup();
objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
objScale.addChild(objTrans);
int flags = ObjectFile.RESIZE;
if (!noTriangulate) flags |= ObjectFile.TRIANGULATE;
if (!noStripify) flags |= ObjectFile.STRIPIFY;
ObjectFile f = new ObjectFile(flags,(float)(creaseAngle * Math.PI / 180.0));
Scene s = null;
     try {
          s = f.load(filename);
     catch (FileNotFoundException e) {
     System.err.println(e);
     System.exit(1);
     catch (ParsingErrorException e) {
     System.err.println(e);
     System.exit(1);
     catch (IncorrectFormatException e) {
     System.err.println(e);
     System.exit(1);
     objTrans.addChild(s.getSceneGroup());
     bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
if (spin) {
     Transform3D yAxis = new Transform3D();
     Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE,0,0,4000,0,0,0,0,0);
     RotationInterpolator rotator = new RotationInterpolator(rotationAlpha,objTrans,yAxis,0.0f,(float) Math.PI*2.0f);
     rotator.setSchedulingBounds(bounds);
     objTrans.addChild(rotator);
//Background color setting
Color3f bgColor = new Color3f(100,200,230);
bgNode = new Background(bgColor);
bgNode.setApplicationBounds(bounds);
objRoot.addChild(bgNode);
return objRoot;
private void usage()
System.out.println("Usage: java ObjLoad1 [-s] [-n] [-t] [-c degrees] <.obj file>");
System.out.println("-s Spin (no user interaction)");
System.out.println("-n No triangulation");
System.out.println("-t No stripification");
System.out.println("-c Set crease angle for normal generation (default is 60 without");
System.out.println("smoothing group info, otherwise 180 within smoothing groups)");
System.exit(0);
} // End of usage
public void init() {
if (filename == null) {
try {
URL path = getCodeBase();
filename = new URL(path.toString() + "./galleon.obj");
catch (MalformedURLException e) {
     System.err.println(e);
     System.exit(1);
     //setLayout(new BorderLayout());
     //setLayout(new GridLayout(5,0));
     //setLayout(new CardLayout());
     //setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
Canvas3D c = new Canvas3D(config);
add(c);
BranchGroup scene = createSceneGraph();
u = new SimpleUniverse(c);
ViewingPlatform viewingPlatform = u.getViewingPlatform();
PlatformGeometry pg = new PlatformGeometry();
Color3f ambientColor = new Color3f(45,27,15);
AmbientLight ambientLightNode = new AmbientLight(ambientColor);
ambientLightNode.setInfluencingBounds(bounds);
pg.addChild(ambientLightNode);
Color3f light1Color = new Color3f(111,222,222);
Vector3f light1Direction = new Vector3f(1.0f, 1.0f, 1.0f);
Color3f light2Color = new Color3f(1.0f, 1.0f, 1.0f);
Vector3f light2Direction = new Vector3f(-1.0f, -1.0f, -1.0f);
DirectionalLight light1 = new DirectionalLight(light1Color, light1Direction);
light1.setInfluencingBounds(bounds);
pg.addChild(light1);
DirectionalLight light2 = new DirectionalLight(light2Color, light2Direction);
light2.setInfluencingBounds(bounds);
pg.addChild(light2);
viewingPlatform.setPlatformGeometry(pg);
viewingPlatform.setNominalViewingTransform();
if (!spin) {
OrbitBehavior orbit = new OrbitBehavior(c,OrbitBehavior.REVERSE_ALL);
BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0);
orbit.setSchedulingBounds(bounds);
viewingPlatform.setViewPlatformBehavior(orbit);     
u.addBranchGraph(scene);
     public ObjLoad1(String[] args) {
          if (args.length != 0) {
               for (int i = 0 ; i < args.length ; i++) {
                    if (args.startsWith("-")) {
                         if (args[i].equals("-s")) {
                              spin = true;
                         } else if (args[i].equals("-n")) {
                              noTriangulate = true;
                         } else if (args[i].equals("-t")) {
                              noStripify = true;
                         } else if (args[i].equals("-c")) {
                              if (i < args.length - 1) {
                                   creaseAngle = (new Double(args[++i])).doubleValue();
                              } else usage();
                         } else {
                              usage();
                    } else {
                         try {
                              if ((args[i].indexOf("file:") == 0) ||
                                        (args[i].indexOf("http") == 0)) {
                                   filename = new URL(args[i]);
                              else if (args[i].charAt(0) != '/') {
                                   filename = new URL("file:./" + args[i]);
                              else {
                                   filename = new URL("file:" + args[i]);
                         catch (MalformedURLException e) {
                              System.err.println(e);
                              System.exit(1);
public void actionPerformed(ActionEvent e)
     if (e.getSource() == Tit)
//Color Picker tool
          Color c1 = JColorChooser.showDialog(((Component)e.getSource()).getParent(),"Zaxis Color Picker", Color.blue);
          cardPanel.setBackground(c1);
          objRoot.removeChild(bgNode);
          int a = c1.getRed();
          int b = c1.getBlue();
          int c = c1.getBlue();
          System.out.println(a);
          System.out.println(b);
          System.out.println(c);
          Color3f ccc = new Color3f(a,b,c);
          bgNode.setApplicationBounds(bounds);
     objRoot.addChild(bgNode);
     else
          System.out.println("mathi");
public ObjLoad1()
Tit = new Button("BG Color");
sub = new Button("Object Color");
cardPanel = new Panel();
cardPanel.add(Tit);
cardPanel.add(sub);
//cardPanel.add(l1);
//cardPanel.add(thelist);
sub.addActionListener(this);
Tit.addActionListener(this);
// thelist.addActionListener(this);
//setLayout for applet to be BorderLayout
this.setLayout(new BorderLayout());
//button Panel goes South, card panels go Center
this.add(cardPanel, BorderLayout.SOUTH);
//this.add(cardPanel, BorderLayout.CENTER);     
this.setVisible(true);
public void destroy() {
public static void main(String[] args) {
     new MainFrame(new ObjLoad1(args),400, 400);

hi,
i am using setColor(Color3f color) method
like
if (e.getSource() == Tit)
          Color c1 = JColorChooser.showDialog(((Component)e.getSource()).getParent(),"Zaxis Color Picker", Color.blue);
          bgColor = new Color3f(c1);
          System.out.println(bgColor.get());
     bgNode.setColor(bgColor);
     bgNode.setApplicationBounds(bounds);
     objRoot.addChild(bgNode);
but error will be displayed
like
javax.media.j3d.CapabilityNotSetException: Background: no capability to set color
     at javax.media.j3d.Background.setColor(Background.java:307)
     at ObjLoad1.actionPerformed(ObjLoad1.java:230)
     at java.awt.Button.processActionEvent(Unknown Source)
     at java.awt.Button.processEvent(Unknown Source)
     at java.awt.Component.dispatchEventImpl(Unknown Source)
     at java.awt.Component.dispatchEvent(Unknown Source)
     at java.awt.EventQueue.dispatchEvent(Unknown Source)
     at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
     at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
     at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
     at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
     at java.awt.EventDispatchThread.run(Unknown Source)
pls help me

Similar Messages

  • How to change InputField background color using Java Code

    Hi,
    In my application use will enter some set of Cost Centers in a table and submits request.
    In return i will get a list of invalid cost centers which i need to display in a table with input field
    In that table all cost centers will displayed, but invalid cost centers should be highlighted or background color should some other color. like red or yellow.
    Is it possible using java code to change a input field color.
    Please help me.
    Thanks

    Hi,
        declare a error message in message pool and declare a method say "checkCostCenters " and in this method, u can check whether it is a valid cost center .. if it is invalid cost center , then throw the erro message using the below code :
    wdComponentAPI.getMessageManager().reportContextAttributeMessage(
                        inputfieldattibutePointer, IMessageProgramPlanComp.ur error message,
                        new Object[] );
    for getting pointer and label use the below code:
    IWDAttributePointer inputfieldPointer = URNODEELEMENTElement
                        .getAttributePointer(URNODEELEMENT.ATTRIBUTENAME);
              String inputfieldLabel = wdContext.nodeURVALUENODE.getNodeInfo()
                        .getAttribute(URNODELEMENT.ATTRIBUTE).getSimpleType()
                        .getFieldLabel();
    hope it helps..
    Thanks and Regards

  • How to change the background color of a single row

    Hi OTN,
    I am using JDeveloper 11.1.1.2 with ADF faces in view layer.My issue is How to change the background color of a single row in af:table ?.

    How to highlight ADF table row based on column value?
    Found by searching

  • How to change the background color of a desktop??

    any ideas how to change the background color of a desktop?? Now the default color is blue. I couldn't fine the API in JDesktopPane on doing that..
    JDesktopPane desktop = new JDesktopPane(); //(textArea);

    Try the method setBackground. For me it's work.

  • How to change the background color of a sequence?

    I'm using Premiere Pro CS5 on Win7 x64.  I've imported a JPEG that's a different size than my 1920 x 1080 frame.  The background of this JPEG is white, but the background of the sequence is black (by default), so the borders of the JPEG make it stand out.  I want the JPEG to blend into the sequence background by making the sequence background white.  How can I change the sequence background color?  Thanks.

    Jim and Ann are correct. I can see where someone used to After Effects might ask that question though because in AE you can change the background color of the composition. Same with Photoshop.
    However, I think it would confuse things if changing the background color were to be allowed in Premiere Pro. Black tells me something. I suppose white could tell me the same thing, but at this time it is not possible in Premiere Pro.

  • How to change the background color of  a Tab Canvas

    Hi All,
    I accidentally changed existing background color of a tab Canvas to ' gray' which is not matching with main canvas (which has default).
    How can I change background color to default. Please help me.
    -Thanks

    In the property palette of the tab page, click on the "Background Color" property and click the "Inherit" button on the top of the property palette, this will revert the value of the property to the default when the tab page was created which is <Unspecified>.
    But if your tab page has inherited the color from a property class it will revert to what was specified in the property class.
    Tony

  • How to change the Background color of a cell in JTable

    hi!
    Actually i want to change the background color of few cells in JTable
    is there any method to make this change in JTable ?
    and also is it possible to have 5 rows with single column and 5 rows with 3 columns in a single JTable

    i want to change the background color of few cells in JTableDepending on your requirements for the coloring of cells it may be easier to override the prepareRenderer() method of JTable:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=610474

  • How to change the background color of a cell in datagrid using flex3

    i want to change the background color of a cell.....how can i achieve this.....and also i want to know how a spacing cane be done between cells in a datagrid...plzzz help me???

    The only way I can see to do this is to use an item renderer for your cells.  This is really scruffy and would need tyding up, and maybe with a little more time could do better or someone else may have an idea but none the less this works.
    Define a custom component as below;
    This has logic to see what the value of the data is proveided by the dataprovider for the row, and if it matches the conditions in this case is equal to 5 sets the background color.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="88" height="26" dataChange="doColor()" borderColor="#000000" borderStyle="solid"
        backgroundAlpha="1">
        <mx:Script>
            <![CDATA[
                private function doColor():void {
                    if (data.value == 5) {
                        setStyle('backgroundColor', 0xcccccc);
                    } else {
                        setStyle('backgroundColor', 0xffffff);
            ]]>
        </mx:Script>
    </mx:Canvas>
    Now just apply the item renderer in the datagrid and that will do it.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"  xmlns:ns1="*">
        <mx:Script>
            <![CDATA[
                import mx.collections.ArrayCollection;
                [Bindable]
                private var ac:ArrayCollection = new ArrayCollection([
                    {value : 1},
                    {value : 2},
                    {value : 3},
                    {value : 4},
                    {value : 5},
                    {value : 6},
                    {value : 7},
                    {value : 8},
                    {value : 9},
                    {value : 10}
          ]]>
        </mx:Script>
        <mx:DataGrid x="40" y="36" width="408" height="193" dataProvider="{ac}">
            <mx:columns>
                <mx:DataGridColumn headerText="Column 1" dataField="value" itemRenderer="MyComp"/>
                <mx:DataGridColumn headerText="Column 2" dataField="col2"/>
                <mx:DataGridColumn headerText="Column 3" dataField="col3"/>
            </mx:columns>
        </mx:DataGrid>
    </mx:Application>
    I hope this helps
    Andrew

  • How to change the background color only for one HTML-Portlet?

    Hi all,
    I have created a HTML-Portlet in my root-page. The root page have a style: Main-Style.
    I want to change the background-color only for this one HTML-Portlet:
    <html>
    <header><title>Test</title></header>
    <body bgcolor="#999999">
    Test
    </body>
    </html>
    But this does not work...
    When I use the CSS, then it will change the background-color for the root-page too.
    Thans
    Leonid Pavlov

    could you try this
    <table bgcolor="#999999">
    <tr>
    <td>
    test
    </td>
    </tr>
    </table>
    I don't think you need <html><header><title>Test</title></header>
    <body></body></html> for your HTML-Portlet.

  • How to change the background color of a cell based on other cell background

    Hi,
    Sorry if this is a basic question - I am new to XML. I want to create a table column, with no data in it. I then want to change the background color of the column based on the background color of other columns. I.E.
    - If there are 3 or less cells in this row that are not green, color this cell green.
    - If there are 4 or less cells in this row that are not green, and 3 or less are not red, color this cell yellow.
    - If there are 4 or less cells in this row that are not green, and 3 or more are red, color this cell red.
    If there are 5 or more cells in this row that are not green, color this cell red.
    Many thanks for any assistance.

    Okay - I have this resolved.
    1. Create two variables (Yellow and Red):
    <?xdoxslt:set_variable($_XDOCTX, 'Yellow', 0)?>
    <?xdoxslt:set_variable($_XDOCTX, 'Red', 0)
    2. For each cell, set the background based on their individual traffic light criteria, and update the associated color variable by 1. By default the backgrd color is set to Yellow so I only have to check for the lower and upper bounds:
    <?choose:?>
    <?when:number(CHECKED_IN)<=1?>
    <?attribute@incontext:background-color;'Lime'?>
    <?end when?>
    <?when:number(CHECKED_IN)>3?>
    <?attribute@incontext:background-color;'Red'?>
    <?xdoxslt:set_variable($_XDOCTX, 'Red', xdoxslt:get_variable($_XDOCTX, 'Red') +1)?>
    <?end when?>
    <?otherwise?>
    <?xdoxslt:set_variable($_XDOCTX, 'Yellow', xdoxslt:get_variable($_XDOCTX, 'Yellow') +1 )?>
    <?end otherwise?>
    <?end choose
    3. I now want a cell that is Red if any of the cells in the row is red. Its yellow of there are 3 or more yellow cells in the row, and no reds. Otherwise its green. First, create an empty cell and make the default color green. Then add:
    <?if: number(xdoxslt:get_variable($_XDOCTX,'Red')) > 0?>
    <?attribute@incontext:background-color;'Red'?>
    <?end if?>
    <?if: number(xdoxslt:get_variable($_XDOCTX,'Yellow')) >= 3 and number(xdoxslt:get_variable($_XDOCTX,'Red')) = 0?>
    <?attribute@incontext:background-color;'Yellow'?>
    <?end if?>
    4. Finally, reset the variables for the next row:
    <?xdoxslt:set_variable($_XDOCTX, 'Yellow', 0)?>
    <?xdoxslt:set_variable($_XDOCTX, 'Red', 0)

  • How to change the background color ?

    Hi !
    I wonder if I could change the background color in my webpage http://web.mac.com/wiktorkidziak/iWeb/ (I mean the white part) using iWeb ?
    Regards,
    Wiktor

    Open the Page Inspector and use Page Background to change to whatever you want. You can also change the colour of the Browser Background in the same place.

  • How to change Object Stroke Color and fill Color?

    Hi to all
    i need to change fillcolor & stroke color of Object
    here i wrote code that tried but it is not
    myDoc = app.activeDocument;
    var dd = myDoc.colors.add({name:"PANTONE Black C", model:ColorModel.spot, colorValue:[0, 13, 49, 98]});
    app.findObjectPreferences= NothingEnum.NOTHING;
      app.changeObjectPreferences = NothingEnum.NOTHING;
      app.findObjectPreferences.fillColor = "Black";
      var myI1 = myDoc.findObject();   
       app.changeObjectPreferences.fillColor = "PANTONE Black C // here error throwing
        app.changeObject ();
    app.findObjectPreferences= NothingEnum.NOTHING;
      app.changeObjectPreferences = NothingEnum.NOTHING;
      app.findObjectPreferences.strokeColor = "Black";
      var myI2 = myDoc.findObject();   
       app.changeObjectPreferences.strokeColor = "PANTONE Black C // here error throwing
        app.changeObject ();
    Error is :  Invalid value for set property 'fillcolor' ,Expected Swatch, String or NothingEnum enumerator, but received "PANTONE Black C";
    pls help me...
    Thanks
    Thangaraj

    Hi scriptor,
    how to create find change query for object search
    pls tell me with script.
    here i attached one jpg file screen shot to understand my need
    Thanks
    Thangaraj

  • How to change the background color of a button when the button is emphasized

    Hi,
    I have a button that is in the "emphasized" state, I realized there is a default color "light blue" when the button is emphasized. is there any way I can change this default color? so if mu button goes to emphasized state I can control which color it should be
    I am using "Halo" for the theme, and I was not able to change the Focus color through the "Appearance Window" in Flash Builder 4
    any help would be appreciated

    Take a look at the accentColor flag of <s:Button>. It looks like you can do it there. But, it also looks like emphasized needs to be "true" and that you may need to interrupt the button's automatic update event... I've never tried to do this though. And, I imagine you only need to listen to button state changes if you want to dynamically control the emphasized color. If you just want to set a static value other than the default, it looks like setting emphasized to true and the uint of the accentColor will do the trick...

  • How to change the background color for lookup column options in sharepoint 2007

    Hi,
    I have a custom List with 10 fields,and in the edit form we want to display only 6 fields,
    So I have customized it with sharepoint designer 2007 ,designed a new custom edit form(Insert->ShaerPoint Controls->Custom List Form)
    We are using IE8 Browser,and the site has JQuery 1.8 loaded .
    The lookup columns is getting rendered as textbox and dropdown arrow image,instead of select html element.
    When we click on arrow image,its displaying the values magically,So I am unable to highlight the options with text "ABC" in yellow background color
    basically in the input textbox its storing all the lookup values as "ID|value "in choices attribute (I saw this in browser dev tools)
    I tried to set the textbox color everytime it loses focus using blur,however its always returning the previous value instead of current selected value.
    Is there any way we can achieve this,Any solutions/thoughts
    Thanks everyone..

    hi i bet you need to amend your jquery script to get onclick values and put it with like append HTML if you want to use Jquery.
    Also did you know you could use javascript in calculated column with type number?
    Check:
    http://sharepointwijzer.nl/sharepoint-blog/tech/icc-html-calculated-column-sharepoint-view
    Imposible is nothing

  • How to change the background color of a screen field

    Hi All,
    I have created a screen, in the output, the fields in the screen are having same color with the screen.
    My client want the fields to be in the gray color.
    For more clarification,
    Goto SE11, Enter any table name, Click on display
    In the next screen, observe the fields
    Name, Short text, Last changed, Status are in the same color with the screen. Where as their values...
    MARA, Material Master: General Data, etc are in the screen with gray background, I want in that way.
    Any hint...
    Thanks,
    Kal Chand

    hi
    As i understand, in your scree u have taken "pushbutton" instead of taking  "I/O field"
    So make ur fields to "I/O fields"
    Reward if it is helpful.
    Thanks
    Siva Kumar

Maybe you are looking for

  • Intereractive weather icon

    In the next iOS the weather icon should be interactive like the iCal icon, showing how warm it is instead of just saying 23*

  • U-Verse VOIP into house wiring: "Line-in-Use"

    All,       ATT converted our DSL to U-Verse high-speed Internet + VOIP 5 months ago. This included VOIP connection to original phone-wiring in the house (built in 1989), supporting 3 extensions.  All worked fine until last week, when all extensions s

  • Entity level validation suppressed in backend

    Hi, I am working on jdev 11.1.1.6, where I face a issues which is pretty much strange. I created a editable table from a view object datacontrol by dragging and dropping. This UI table consist of two columns with two LOVs providing them values. The e

  • Problem with the custom field - enabling

    hi, i am using one customer field in the shopping card header , and using BBP_DOC_CHECK_BADI to issue an error message if this field is left empty. but the problem comes after the error message is issues , this field becomes disabled , and the user h

  • Blacklist in S40v5? Nokia 6500

    Hello, i was wondering if there is an application for S40 platform to blacklist callers? Thank you.