Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how add new class

Status
Not open for further replies.

12345vishel

Programmer
May 29, 2003
2
IL
i have jbuilder8 .
i build application project .
i create a new class. let say class Board with function
get().
in class jframe i create variable Board b;
and i write for example b.get()

compiler say that error #300 method get not found in class......


HELP!!!!!!!!!!!!!!!!!!!!!!
 
Has the 'get()' method been declared public?

Can you post the code?
 
package taktiko;//jframe

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/

public class Frame1 extends JFrame {
JPanel contentPane;
BorderLayout borderLayout1 = new BorderLayout();


Board B=new Board(); ///new class

//Construct the frame
public Frame1() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
contentPane = (JPanel) this.getContentPane();
contentPane.setLayout(borderLayout1);
this.setSize(new Dimension(400, 300));
this.setTitle(&quot;Frame Title&quot;);
B.get();
B.gety();//sometime working sometime not !!!!!!!!!!!!
//
}
//Overridden so we can exit when window is closed
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
}
}
////////////////////////////////////////////////////
new class Board
package taktiko;

/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/

public class Board {
static private int x=9;
static private int y=9;
public Board() {

}

public int get() {
return x;
}
public int gety(){
return y;
}

}
 
try this (since your functions are returning value)

int x = B.get();
int y = B.gety();//sometime working sometime not !!!!!!!!!!!!

~za~
You can't bring back a dead thread!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top