Hi..I basically new wit java.
i have a program called Transfer.java..n when i press button caleed "start Transfer" it executes FileServer.java
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.Random;
import java.util.*;
import java.text.*;
import java.rmi.*;
class transfer extends JFrame implements ActionListener, Runnable
{
JButton btntrans,btnexit;
ImageIcon bc;
JLabel lbltitle ,label1;
JTextField text1;
Thread t;
public transfer()
{
setSize(800,570);
setTitle(" FILE TRANSFER ");
/*bc=new ImageIcon("1.jpg");*/
lbltitle= new JLabel(bc);
label1 = new JLabel();
label1.setFont(new Font("Serif", Font.BOLD, 28));
label1.setForeground(Color.black);
label1.setOpaque(true);
label1.setText("ip Address:");
text1 = new JTextField(20);
btntrans=new JButton(" Start Transfer");
btnexit=new JButton("Exit");
Container cp=getContentPane();
cp.setLayout(null);
//cp.setBackground(Color.white);
Insets ins=getInsets();
label1.setBounds(40,100,150,50);
text1.setBounds(200,100,280,50);
btntrans.setBounds(40,300,150,50);
btnexit.setBounds(40,400,150,50);
lbltitle.setBounds(0,0,850,570);
//lbltitle.setBounds(220,20,130,104);
btntrans.addActionListener(this);
btnexit.addActionListener(this);
text1.addActionListener(this);
cp.add(btntrans);
cp.add(btnexit);
cp.add(lbltitle);
cp.add(label1);
cp.add(text1);
//cp.setBackground(Color.blue);
}
public void run()
{
try
{
while(t.isAlive())
{
Thread.sleep(1000);
File f = new File("check/test.jpg");
if(f.exists())
{
String fname = f.getAbsolutePath();
FileInputStream instream = new FileInputStream(fname);
int insize = instream.available();
byte inBuf[] = new byte[insize];
int bytesread = instream.read(inBuf,0,insize);
instream.close();
}
}
}
catch(Exception e)
{
System.out.println(e);
}
}
public void actionPerformed(ActionEvent ae)
{
String value1=text1.getText();
if(ae.getSource() == btntrans)
{
try {
FileInterface fi = new FileImpl("FileServer");
Naming.rebind("//192.168.1.2/FileServer", fi);
}
catch(Exception e) {
System.out.println("FileServer: "+e.getMessage());
e.printStackTrace();
}
}
else
{
System.exit(0);
}
}
public static void main(String args[])
{
transfer t=new transfer();
t.show();
}
}
Now i need to take IP adress from user & pass it to Naming.rebind("//192.168.1.2/FileServer", fi); instead of 192.168.1.2.
the ip adress is stored in Value1.
how do i pass tht value to Naming.rebind("//192.168.1.2/FileServer", fi); * i need user input ip adress instead of 192.168.1.2.
thanx fr any kind of assistance in advance