NTNUJAVA Virtual Physics LaboratoryEnjoy the fun of physics with simulations! Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/
January 23, 2019, 09:24:21 pm
 Welcome, Guest. Please login or register.Did you miss your activation email? 1 Hour 1 Day 1 Week 1 Month Forever Login with username, password and session length

 Home Help Search Login Register
Progress is impossible without change; and those who cannot change their minds cannot change anything. ..."George Bernard Shaw(1865-1950, Irish dramatist, essayist and critic, Nobel Prize for Literature 1925)"

 Pages: [1]   Go Down
 Author Topic: How to change color to the cube_old?  (Read 11065 times) 0 Members and 1 Guest are viewing this topic. Click to toggle author information(expand message area).
yliu
Newbie

Offline

Posts: 3

 « Embed this message on: November 21, 2008, 01:23:04 pm » posted from:Adelaide,South Australia,Australia

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
 Logged
Fu-Kwun Hwang
Hero Member

Offline

Posts: 3080

 « Embed this message Reply #1 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.
 Logged
yliu
Newbie

Offline

Posts: 3

 « Embed this message Reply #2 on: November 24, 2008, 12:07:25 pm » posted from:Adelaide,South Australia,Australia

I thank you very much for your kind help. The color works very well.
 Logged
yliu
Newbie

Offline

Posts: 3

 « Embed this message Reply #3 on: November 24, 2008, 12:16:42 pm » posted from:Adelaide,South Australia,Australia

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
 Logged
lookang
Hero Member

Offline

Posts: 1790

http://weelookang.blogspot.com

 « Embed this message Reply #4 on: November 24, 2008, 04:32:01 pm » posted from:Singapore,,Singapore

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
 « Last Edit: November 24, 2008, 04:34:36 pm by lookang » Logged
Fu-Kwun Hwang
Hero Member

Offline

Posts: 3080

 « Embed this message Reply #5 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.
 Logged
 Pages: [1]   Go Up
Progress is impossible without change; and those who cannot change their minds cannot change anything. ..."George Bernard Shaw(1865-1950, Irish dramatist, essayist and critic, Nobel Prize for Literature 1925)"