This is Interesting: Free Magazines for Graphics designers and webmasters
Home > Archive > VRML > August 2004 > help!! EAI vrml...
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
help!! EAI vrml...
|
|
|
| hi, i m new to EAI java applet, my first question is how to call a method
inside applet file? inside public start?
second,when we click on a button, the event will raise inside public
boolean action(Event event),but if the button is outside the file, that
means in another file, i want to get the event from second file and send
it to main file, is it possible??
| |
| Muaddib 2004-08-06, 7:17 pm |
| I don't I understand what you are asking. Could you attach pseudocode
or the two .java files? Are you looking to make two seperate applets?
or one applet with two classes ( i.e. two files )?
If this is the case, then the key is to make your main applet implement
ActionListener, and have the second class which creates the button (?)
add the applet as an actionlistener.
e.g.
public class MainApplet extends Applet implements ActionListener {
public MainApplet() {
new SecondClass( this );
}
}
public class SecondClass {
public SecondClass( MainApplet mainApplet ) {
Button button = new Button( "Click Me" );
button.addActionListener( mainApplet );
}
}
--
-------------------------------------------------------
VRSpace - An open source, modular, cross-platform,
multi-user vrml system with persistent shared objects.
Check out the Nexus at http://www.vrspace.org/
-------------------------------------------------------
| |
| apple 2004-08-08, 11:14 pm |
| i mean i want to create an object like sphere inside vrml scene, then
moving it through srollbar x,y,z axis (in java applet), but i want to
separate these axis in different interface (button in Main.java and
scrollbar function in Virtual.java).the return value get from scrollbar
and send to Main.java.
i have done nearly can work just don't know where to put the code:
float getValue=Tengah.putKatak();
if i put inside Main.java like below
public boolean handleEvent(Event event) {
if ((event.target instanceof Scrollbar))
float getValue=Tengah.putKatak();
i cant get the return value because the scrollbar event is in
Virtual.java.
sorry, if my question too funny..this is only my first EAI program..
thanks for ur reply.
| |
| Muaddib 2004-08-09, 12:16 pm |
| This requires code similar to what I last posted. Here is a modified
version:
public class MainApplet extends Applet implements AdjustmentListener {
public MainApplet() {
new ClassWithScrollbar( this );
}
public void adjustmentValueChanged(AdjustmentEvent e) {
int adjustmenet = e.getValue();
// Perform EAI calls here to set the new location of the sphere
}
}
public class ClassWithScrollbar {
public ClassWithScrollbar( MainApplet mainApplet ) {
Scollbar scollbar = new Scrollbar();
scollbar.addAdjustmentListener( mainApplet );
}
}
--
-------------------------------------------------------
VRSpace - An open source, modular, cross-platform,
multi-user vrml system with persistent shared objects.
Check out the Nexus at http://www.vrspace.org/
-------------------------------------------------------
| |
|
| i still blur..
here is part of my program..
(MainVirtual.java)
public class MainVirtual extends Applet{
Virtual a=null;
public void start(){
browser=Browser.getBrowser(this);
add(TransScrollbar[0]=new Scrollbar());
add(TransScrollbar[1]=new Scrollbar());
add(TransScrollbar[2]=new Scrollbar());
add(buttonSphere=new Button());}
public boolean handleEvent(Event event)
{ if(event.target instanceof Scrollbar)
{ float [] transVal=new float[3];
transVal[0]=(float)TransScrollbar[0].getValue();
:
:
a.set_translation.setValue(transVal);
return true;}
return super.handleEvent(event);
}
void initial(){
float[] val;
val=a.translation_changed.getValue();
TransScrollbar[0].setValue((int)val[0]);}
}
(Virtual.java)
public class Virtual extends object implements EventOutObserver{
Virtual(MainVirtual parent,int which){
// add children here (create sphere)
set_translation=(EventInSFVec3f)
transform.getEventIn ("translation");
translation_changed=(EventOutSFVec3f)
transform.getEventOut("translation");}
public void callback(){//make which sphere is current}
}
(X_axis.java)
public class X_axis extends applet{
public float x;
public void start(){
add(TransScrollbar=new Scrollbar());}
public boolean handleEvent(Event event){
if(event.target instanceof Scrollbar){
x=(float)TransScrollbar.getValue();
return true;}
return super.handleEvent(event);}
i want to create new scrollbar in X_axis.java and return the x value to
varialble transVal[0] in MainVirtual, so where should i put the code
transVal[0]=a.x;
| |
| Muaddib 2004-08-10, 11:20 pm |
| ok, it seems that you did in fact want to have two seperate applets, on
the same page speaking to each other. Consider, using a class as the
communicator between the two:
public class Communicator {
public static Communicator c;
public MainVirtual listener;
static {
c = new Communicator();
}
public boolean handleEvent(Event event){
listener.handleEvent( event );
}
}
> (MainVirtual.java)
> public class MainVirtual extends Applet{
> public void start() {
...
Communicator c = Communicator.c;
c.listener = this;
}
> (X_axis.java)
> public class X_axis extends applet{
Communicator c;
> public void start() {
...
c = Communicator.c;
}
> public boolean handleEvent(Event event){
...
c.handleEvent( event );
}
--
-------------------------------------------------------
VRSpace - An open source, modular, cross-platform,
multi-user vrml system with persistent shared objects.
Check out the Nexus at http://www.vrspace.org/
-------------------------------------------------------
| |
|
|
|
| i still blur..
here is part of my program..
(MainVirtual.java)
public class MainVirtual extends Applet{
Virtual a=null;
public void start(){
browser=Browser.getBrowser(this);
add(TransScrollbar[0]=new Scrollbar());
add(TransScrollbar[1]=new Scrollbar());
add(TransScrollbar[2]=new Scrollbar());
add(buttonSphere=new Button());}
public boolean handleEvent(Event event)
{ if(event.target instanceof Scrollbar)
{ float [] transVal=new float[3];
transVal[0]=(float)TransScrollbar[0].getValue();
:
:
a.set_translation.setValue(transVal);
return true;}
return super.handleEvent(event);
}
void initial(){
float[] val;
val=a.translation_changed.getValue();
TransScrollbar[0].setValue((int)val[0]);}
}
(Virtual.java)
public class Virtual extends object implements EventOutObserver{
Virtual(MainVirtual parent,int which){
// add children here (create sphere)
set_translation=(EventInSFVec3f)
transform.getEventIn ("translation");
translation_changed=(EventOutSFVec3f)
transform.getEventOut("translation");}
public void callback(){//make which sphere is current}
}
(X_axis.java)
public class X_axis extends applet{
public float x;
public void start(){
add(TransScrollbar=new Scrollbar());}
public boolean handleEvent(Event event){
if(event.target instanceof Scrollbar){
x=(float)TransScrollbar.getValue();
return true;}
return super.handleEvent(event);}
i want to create new scrollbar in X_axis.java and return the x value to
varialble transVal[0] in MainVirtual, so where should i put the code
transVal[0]=a.x;
| |
|
| i mean i want to create an object like sphere inside vrml scene, then
moving it through srollbar x,y,z axis (in java applet), but i want to
separate these axis in different interface (button in Main.java and
scrollbar function in Virtual.java).the return value get from scrollbar
and send to Main.java.
i have done nearly can work just don't know where to put the code:
float getValue=Tengah.putKatak();
if i put inside Main.java like below
public boolean handleEvent(Event event) {
if ((event.target instanceof Scrollbar))
float getValue=Tengah.putKatak();
i cant get the return value because the scrollbar event is in
Virtual.java.
sorry, if my question too funny..this is only my first EAI program..
thanks for ur reply.
| |
| Muaddib 2004-08-16, 4:16 am |
| ok, it seems that you did in fact want to have two seperate applets, on
the same page speaking to each other. Consider, using a class as the
communicator between the two:
public class Communicator {
public static Communicator c;
public MainVirtual listener;
static {
c = new Communicator();
}
public boolean handleEvent(Event event){
listener.handleEvent( event );
}
}
> (MainVirtual.java)
> public class MainVirtual extends Applet{
> public void start() {
...
Communicator c = Communicator.c;
c.listener = this;
}
> (X_axis.java)
> public class X_axis extends applet{
Communicator c;
> public void start() {
...
c = Communicator.c;
}
> public boolean handleEvent(Event event){
...
c.handleEvent( event );
}
--
-------------------------------------------------------
VRSpace - An open source, modular, cross-platform,
multi-user vrml system with persistent shared objects.
Check out the Nexus at http://www.vrspace.org/
-------------------------------------------------------
| |
| apple 2004-08-17, 12:17 pm |
| hey, thanks.. i got it..
|
|
|
| | Copyright 2003 - 2008 forum4designers.com Software forum Computer Hardware reviews |
|