Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-13-2008, 03:07 AM
Member
 
Join Date: Dec 2007
Posts: 34
saytri is on a distinguished road
problem
I have a problem, where i need to call the ReadDataFileToPanel class into the GQ class. I tried to use the method setVisible but its not working. Here are the two classes:

Class that contains the dialog:

Code:
import java.awt.BorderLayout; import java.io.DataInputStream; import java.io.File; import java.io.FileInputStream; import javax.swing.JDialog; import javax.swing.JTextArea; public class ReadDataFileToPanel { private JTextArea textArea; public ReadDataFileToPanel() { super(); try{ JDialog dialog = new JDialog(); dialog.getContentPane().setLayout(new BorderLayout(10, 10)); String record = null; File file = new File("players.txt"); FileInputStream fileInput = new FileInputStream(file); DataInputStream dis = new DataInputStream(fileInput); String string = dis.readLine(); textArea = new JTextArea(); while(string != null){ textArea.append(string + "\n"); string = dis.readLine(); textArea.setEditable(false); } dialog.getContentPane().add(BorderLayout.CENTER, textArea); dialog.setTitle("Scores"); dialog.setSize(400, 300); dialog.setVisible(true); }catch (Exception e){ e.printStackTrace(); } } public static void main(String[] args){ new ReadDataFileToPanel(); } }

And this is part of the code found in another class (class called GQ) where i have to call the ReadDataFileToPanel:


Code:
try { BufferedWriter out; String text = JOptionPane.showInputDialog(null, "Enter your name"); out = new BufferedWriter(new FileWriter("players.txt",true)); out.write(text); out.write(" "); out.write(String.valueOf(count)); out.newLine(); out.close(); }catch(IOException e){ System.out.println("There was a problem:" + e); } ReadDataFileToPanel scorelist = new ReadDataFileToPanel (); // i think i wrote a wrong command over here. scorelist.setVisible(true); }

Thanks for taking time to read and help. :-)

Last edited by saytri : 01-13-2008 at 07:17 PM.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can we add JCheckBox array into JTextArea? nancyhung AWT / Swing 1 02-17-2008 02:07 AM
JTextArea setting newtojava7 New To Java 1 01-29-2008 04:57 AM
How to add a shortcut key from JTextArea sukatoa Advanced Java 2 01-28-2008 10:39 AM
Jtextarea and scroll ziniestro AWT / Swing 2 06-01-2007 05:59 PM


All times are GMT +3. The time now is 01:22 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org