Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

in creating project file from existing main files

 
harsimran kochar
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am trying to create a project file from existing main files , i create my project file(FixedDeposit) where other files are kept i want to add, and i use the option add existing file and add all the files i want to add. And i make the main of other files comment and try to call them in main of project but it is not working neither showing error nor exception. plzzzzzzzzz help
 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you trying to add in Eclipse.

Please post the code snippet on how you are invoking other classes from your project main class. Note that you don't want to comment main method of other classes you add to the project. Give some sample simple java files you are trying to call and the way you call.
 
harsimran kochar
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import java.awt.*;
import javax.swing.*;
//import javax.swing.JLabel;
import java.util.Vector;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.table.DefaultTableModel;
import java.sql.*;

class TRrelatn extends JFrame implements ActionListener{
Container c;
JLabel lTimePeriod,lRate,lheading;
JButton bAdd,bDelete,bExit,bUpdate,bFD,bDeleteAll,bNew;
JTextField tTimePeriod,tRate;
DefaultTableModel mTR;
JTable tTR;

TRrelatn(){
c=getContentPane();
setSize(Toolkit.getDefaultToolkit().getScreenSize());
setLayout(null);
setTitle("Time-Rate Relation");
c.setBackground(Color.GRAY);

lheading = new JLabel("Rate of Interests for FD");
lheading.setBounds(400,0,1100,150);
lheading.setFont(new Font(Font.SANS_SERIF,Font.BOLD,48));
c.add(lheading);

lTimePeriod = new JLabel("Time Period");
lTimePeriod.setBounds(50,200,100,50);
c.add(lTimePeriod);

lRate=new JLabel("Rate");
lRate.setBounds(50,300,100,50);
c.add(lRate);

tTimePeriod=new JTextField();
tTimePeriod.setBounds(150,215,100,30);
c.add(tTimePeriod);

tRate=new JTextField();
tRate.setBounds(150,315,100,30);
c.add(tRate);

String s[]={"Time Period","Rate%"};
mTR=new DefaultTableModel(s,0);
tTR=new JTable(mTR);
JScrollPane jspTR=new JScrollPane(tTR);
jspTR.setBounds(700,150,600,400);
c.add(jspTR);

bAdd=new JButton("Add");
bAdd.setBounds(50,500,100,50);
c.add(bAdd);
bAdd.addActionListener(this);

bUpdate=new JButton("Update");
bUpdate.setBounds(250,500,100,50);
c.add(bUpdate);

bExit=new JButton("Exit");
bExit.setBounds(150,600,100,50);
c.add(bExit);

bDelete=new JButton("Delete");
bDelete.setBounds(800,600,100,50);
c.add(bDelete);

bDeleteAll=new JButton("Delete All");
bDeleteAll.setBounds(1000,600,100,50);
c.add(bDeleteAll);

bFD=new JButton("FD");
bFD.setBounds(500,150,50,500);
c.add(bFD);

bNew=new JButton("New");
bNew.setBounds(350,600,100,50);
c.add(bNew);
bNew.addActionListener(this);

bFD.addActionListener(this);
fillTableTr();
setVisible(true);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
}

public void actionPerformed(ActionEvent ae){
Object o= ae.getSource();
if(o.equals(bAdd)){



try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbcdbcRIVER=Microsoft Access DRIVER (*.mdb);DBQ=trrelation.mdb");
PreparedStatement st=con.prepareStatement("insert into tr Values(?,?)");
st.setString(2,tRate.getText());
st.setString(1,(tTimePeriod.getText()));
int n= st.executeUpdate();
if(n>0)
{
JOptionPane.showMessageDialog(c,"saved");
}

con.close();

}
catch (Exception ex) {
System.out.println(ex.toString());
}
Vector v=new Vector();
v.add(tTimePeriod.getText());
v.add(tRate.getText());

mTR.addRow(v);

}
if(o.equals(bNew)){
tTimePeriod.setText(" ");
tRate.setText(" ");
}

if(o.equals(bFD)){
new FrmAdd();
}
}

void fillTableTr(){
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbcdbcRIVER=Microsoft Access Driver (*.mdb);DBQ=trrelation.mdb");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("Select * from tr");
while(rs.next()){

Vector v=new Vector();
v.add(rs.getString(1));
v.add(rs.getString(2));
mTR.addRow(v);
}
con.close();
}
catch(Exception ex){

}
}

}

class TimeRateRltn {


public static void main(String[] args) {
new TRrelatn();

}
}

 
harsimran kochar
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
as the class given is my one of class that i add in project and trying to call this in my project like this



public class FixedDeposit {

public static void main(String[] args) {


// new MyFrame();
// new FrmAdd();
new TRrelatn();
}
}
 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please use Code Tags

When I tried to run your class FixedDeposit I am able to successfully see a Time-Rate Relation frame. You are facing any compilation issues as such?

I commented this line of code though...

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic