Send System.Out to Jframe / Jtext area

outputing to Jframe or TextArea

Page 1 of 1

3 Replies - 5322 Views - Last Post: 21 October 2007 - 10:39 AM Rate Topic: -----

#1 codeninja  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 44
  • Joined: 16-February 07

Send System.Out to Jframe / Jtext area

Post icon  Posted 21 October 2007 - 09:48 AM

I would like to know the best strategy for taking programs previously written for the console, and setting them to output in a Gui window.

I have this program being executed by a main class when the user clicks a Button, but it is still running in the console. I need to direct its output to a window instead of the console.

Ideas???


import java.util.Hashtable;
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
import java.util.*;


public class ComicFire {
	
	
	
	public  void RunMe(){
		
		Hashtable quality = new Hashtable();
		
		float price1 = 3.00F;
		quality.put("mint", price1);
		float price2 = 2.00F;
		quality.put("near mint", price2);
		float price3 = 1.50F;
		quality.put("very fine", price3);
		float price4 = 1.00F;
		quality.put("fine", price4);
		float price5 = .75F;
		quality.put("good", price5);
		float price6 = .25F;
		quality.put("poor", price6);
		
		ComicOld[] comix = new ComicOld[3];
		comix[0] = new ComicOld("Amazing Spider Man", "1A", "very fine", 9240.00F);
		comix[0].setPrice((Float) quality.get(comix[0].condition));
		comix[1] = new ComicOld("Amazing Spider Man", "1A", "mint", 1.00F);
		comix[1].setPrice((Float) quality.get(comix[1].condition));
		comix[2] = new ComicOld("Amazing Spider Man", "1A", "poor", 2.00F);
		comix[2].setPrice((Float) quality.get(comix[2].condition));
		
		for(int i = 0; i < comix.length; i++){
		
			System.out.println("Title:" + comix[i].title);
			System.out.println("Issue:" + comix[i].issueNumber);
			System.out.println("Condition:" + comix[i].condition);
	 		System.out.println("Price: $" + comix[i].price );
			
			
		}
			
		}
		
		
		
	}
	
class ComicOld{
	
	String title;
	String issueNumber;
	String condition;
	float basePrice;
	float price;
	
	public ComicOld(String inTitle, String inIssueNumber, String inCondition, float inBasePrice){
		
		title = inTitle;
		issueNumber = inIssueNumber;
		condition = inCondition;
		basePrice = inBasePrice;
		
		
		
	}
	
	public void setPrice(float factor){
	price= basePrice * factor;	
	}
	
}












________________________

Thanks codeninaja

Is This A Good Question/Topic? 0
  • +

Replies To: Send System.Out to Jframe / Jtext area

#2 PennyBoki  Icon User is offline

  • system("revolution");
  • member icon

Reputation: 53
  • View blog
  • Posts: 2,334
  • Joined: 11-December 06

Re: Send System.Out to Jframe / Jtext area

Posted 21 October 2007 - 10:00 AM

well you can use a text area, or textfields or labels ... So you need a window the JFrame thing. but before you go any further I suggest you read this entry of Martyr2's blog:

Tips on Converting from Console to GUI

I am sure you'll find it very useful, also take a look at the tutorials or the snippets for some GUI programs.
Was This Post Helpful? 0
  • +
  • -

#3 codeninja  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 44
  • Joined: 16-February 07

Re: Send System.Out to Jframe / Jtext area

Posted 21 October 2007 - 10:24 AM

Good advice from the link.

I guess my confusion is should I let this program run and then try and put the output into the frame or.....do something I know how to do.... send the output to a text file and then read it into the GUI.

I can do that ironically.

Capturing the output seems like less work, but if I am capturing output what am I LISTENING for? What component do I grab? I think that is where I am lost. After reading the advice he gave that seems to be my dark area.

Thanks for joining in the convo.




View PostPennyBoki, on 21 Oct, 2007 - 10:00 AM, said:

well you can use a text area, or textfields or labels ... So you need a window the JFrame thing. but before you go any further I suggest you read this entry of Martyr2's blog:

Tips on Converting from Console to GUI

I am sure you'll find it very useful, also take a look at the tutorials or the snippets for some GUI programs.

Was This Post Helpful? 0
  • +
  • -

#4 PennyBoki  Icon User is offline

  • system("revolution");
  • member icon

Reputation: 53
  • View blog
  • Posts: 2,334
  • Joined: 11-December 06

Re: Send System.Out to Jframe / Jtext area

Posted 21 October 2007 - 10:39 AM

well you can always use a button, like when a button is clicked update the window.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1