TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
TheSabareesan Kandasamy
NA
3
1.2k
How Do I Redirect My Output From Console To Jtextarea Here?
Mar 30 2014 11:49 AM
//Kindly edit and post your code which satisfy my need. its an emergency.
import java.awt.*;
import javax.swing.*;
import java.io.*;
import java.util.*;
import javax.mail.*;
public class TextAreaDemoB extends JFrame
{
JTextArea _resultArea = new JTextArea(6, 35);
public TextAreaDemoB() throws Exception
{
String host = "pop.gmail.com";
String user = "
[email protected]
";
String password = "QWERTYASDFG";
Properties properties = System.getProperties();
Session session = Session.getDefaultInstance(properties, null);
Store store = session.getStore("pop3s");
store.connect(host, user, password);
Folder folder = store.getFolder("inbox");
folder.open(Folder.READ_ONLY);
Message[] message = folder.getMessages();
for (int i = 0; i < message.length; i++)
{
String myString = Integer.toString(i);
_resultArea.append(myString);
_resultArea.append("------------ Message " + (i + 1) + " ------------");
_resultArea.append("SentDate : " + message[i].getSentDate());
_resultArea.append("From : " + message[i].getFrom()[0]);
_resultArea.append("Subject : " + message[i].getSubject());
InputStream stream = message[i].getInputStream();
//The following loop must be changed to achieve my solution.can any1???????
do
{
//_resultArea.setText(();
char d=(char) stream.read();
String c=Character.toString(d);
//_resultArea.append(c);
System.out.println(c);
}
while (stream.available() != 0);
}
JScrollPane scrollingArea = new JScrollPane(_resultArea);
JPanel content = new JPanel();
content.setLayout(new BorderLayout());
content.add(scrollingArea, BorderLayout.CENTER);
this.setContentPane(content);
this.setTitle("TReadMails");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.pack();
}
//============================================================= main
public static void main(String[] args) throws Exception
{
JFrame win = new TextAreaDemoB();
win.setVisible(true);
}
}
Reply
Answers (
0
)
Program in JAVA
Access Log Files in JAVA?