NTNUJAVA Virtual Physics Laboratory
Enjoy the fun of physics with simulations!
Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/

Information about this web site => Question related to Physics or physics related simulation => Topic started by: yliu on November 21, 2008, 01:23:04 pm



Title: How to change color to the cube_old?
Post by: yliu on November 21, 2008, 01:23:04 pm
Hi,

I am building a simple physics model, it will be much easier to see if I can change the color of the cube_old icon under 2D-Drawables section. Any help will be appreciated.

Regards,
Yang


Title: Re: How to change color to the cube_old?
Post by: Fu-Kwun Hwang on November 21, 2008, 09:10:31 pm
There is a "color" property for all the drawable element.
You should be able to change the color for the element from the popupped "color selection" panel.

You can define a variable with type "Object" if you want color change dynamically during run time:
For example: define variables with name "red,green,blue,color..." , type "Object"
and set
color=new java.awt.Color(r,g,b,t);
where r,g,b,t are value from 0-255 , corresponds to value for RED/GREEN/BLUE and transparent.
or set
 red=new java.awt.Color(255,0,0);
 green=new java.awt.Color(0,255,0);
 blue=new java.awt.Color(0,0,255);
and set color=red;  or color=green ...etc.


Title: Re: How to change color to the cube_old?
Post by: yliu on November 24, 2008, 12:07:25 pm
I thank you very much for your kind help. The color works very well.


Title: Re: How to change color to the cube_old?
Post by: yliu on November 24, 2008, 12:16:42 pm
I have another question, how to impose the position of buttons in a panel? I mean how to put the buttons where I want to, rather than following default rules (left, center or right). Thank you in advance  :D


Title: Re: How to change color to the cube_old?
Post by: lookang on November 24, 2008, 04:32:01 pm
Post:
http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=758.0

Example of my xml:
http://www.phy.ntnu.edu.tw/ntnujava/index.php?action=dlattach;topic=758.0;attach=375

you can check out my xml file, i normally explore the VBOX , HBOX, BORDERS, GRID and put panels inside them to get the desired look and feel for the applet.

as you can see in my example, i have menu at the top, display fields at the left, applet on the right, control buttons on the bottom.

i do agree it take time to get used to the interface, i normally copy and paste from another instant of a another applet to transfer "assets" to a new applet i am building/modifying etc.

welcome to applet making !


BTW you may want to start new threads for new questions for google bots to tag the links correctly for others to find help on EJS  ;D


Title: Re: How to change color to the cube_old?
Post by: Fu-Kwun Hwang on November 24, 2008, 07:47:20 pm
There is a property: "layout" for "Frame" or "Panel".
The default value is border so you can add element into left/right/center...etc.
You can change layout to horizontal box, vertical box, FlowLayout or GridLayout (Rows/Columns).

Try to change the "Layout" and find out what happened to the element added into the partent element.