aspose file tools*
The moose likes Java in General and the fly likes in creating project file from existing main files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "in creating project file from existing main files" Watch "in creating project file from existing main files" New topic
Author

in creating project file from existing main files

harsimran kochar
Greenhorn

Joined: Sep 09, 2011
Posts: 14
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
Bartender

Joined: May 31, 2011
Posts: 1776
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

Joined: Sep 09, 2011
Posts: 14
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

Joined: Sep 09, 2011
Posts: 14
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
Bartender

Joined: May 31, 2011
Posts: 1776
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...

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: in creating project file from existing main files