Results 1 to 3 of 3
Thread: console and JTesxtField
- 12-09-2008, 01:40 PM #1
console and JTesxtField
I wrote a Program which as an inputtake the file path in the Console and open it.
now I have tried to take the input from a window with (Swing, apt oder Gui) :Java Code:public void readTheFile()throws IOException{ Start frame = new Start();// next step "open the start() class" InputStreamReader inStream = new InputStreamReader(System.in); BufferedReader stdin = new BufferedReader(inStream); String fileName; System.out.println("Please give your path"); fileName = stdin.readLine(); File file = new File(fileName);
but it doesn't funtion !! what am I doing Wrong??:confused:Java Code:public class Start extends JFrame implements ActionListener{ public Start() { JFrame.setDefaultLookAndFeelDecorated(true); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setTitle("Input Window "); frame.setLayout(new GridLayout(3, 2)); frame.add(new JLabel("Please give your path:")); final JTextField textfield = new JTextField(16); textfield.addActionListener(this); frame.add(textfield); JButton button1 = new JButton("GO!"); frame.add(button1); button1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String text = textfield.getText(); } });
- 12-09-2008, 02:41 PM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Do you get any error messages, if so please copy-paste here to see.
- 12-10-2008, 08:36 AM #3
Similar Threads
-
How to get input from Console
By karma in forum New To JavaReplies: 8Last Post: 08-13-2010, 09:32 PM -
how to take input from console in jsp
By veena in forum New To JavaReplies: 1Last Post: 05-06-2008, 04:39 AM -
Console Progress Bar
By new_2_java in forum New To JavaReplies: 1Last Post: 02-16-2008, 02:18 AM -
Console doesn't appear!
By PeteMarsh in forum New To JavaReplies: 2Last Post: 12-17-2007, 05:41 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks