Board index » jbuilder » how to call a class from a bottom??

how to call a class from a bottom??


2003-10-01 01:43:53 AM
jbuilder23
Hi...i need help..is my first time in java and i have to do something easy
but y dont knowk how... i have a class created that send information to the
serial port but i need in the UI press a bottom and send a byte ... how do
to call the class?? how define the variable to do that??? if some body can
write how to do (the source) i would be thanks
bye
 
 

Re:how to call a class from a bottom??

Eliot wrote:
Quote
Hi...i need help..is my first time in java and i have to do something easy
but y dont knowk how... i have a class created that send information to
the serial port but i need in the UI press a bottom and send a byte ...
how do to call the class?? how define the variable to do that??? if some
body can write how to do (the source) i would be thanks

bye
Calling a class is simple. Here is an example:
void jButton1_actionPerformed(ActionEvent e) {
NewClass nc= new NEwClass();
nc.doSomething();
}
That is pretty much it.
Make sure that your ActionEvents have been defined somehere in the init
code. In JBuilder, this is commonly done in the private void jbInit()
method:
Xample:
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
jButton1_actionPerformed(e);
}
});
jButton1.addActionListener(new MyClass_actionAdapter(this));