Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2007

Tip: Looking for answers? Try searching our database.

couldn't output the output in gui window

Thread view: 
ram - 09 Oct 2007 15:56 GMT
this is the code , i want the code to output in gui window.i tried
JTextArea but couldn't
get output on window.suggest me what to use for this particular code
// Fig. 14.37: FileDemonstration.java
// Demonstrating the File class.

import java.lang.reflect.*;
import javax.swing.*;

public class Reverse extends JFrame
{

  public Reverse()
  {

    analyze();

  } // end Reverse constructor

//this method prints constructors of class
public static void printConstructors(Class cl)
{
  Constructor[] constructors = cl.getDeclaredConstructors();

  for (int i=0;i<constructors.length;i++)
  {
   Constructor c = constructors[i];
   String name = c.getName();
   System.out.print(Modifier.toString(c.getModifiers()));
   System.out.print("   "+ name + "(");

 //print parameter type
  Class[] paramTypes = c.getParameterTypes();
 for(int j=0;j< paramTypes.length ;j++)
 {
  if(j>0) System.out.print(",");
   System.out.print(paramTypes[j].getName());
  }
 System.out.println(");") ;
   }
}

//this method prints method of class
 public static void printMethods(Class cl)
{
Method[] methods = cl.getDeclaredMethods();

for(int i=0;i<methods.length;i++)
{
 Method m = methods[i];
Class retType = m.getReturnType();
 String name =m.getName();
//print modifiers, return type and method name

System.out.print(Modifier.toString(m.getModifiers()));
System.out.print("   "+ retType.getName() +" "+ name + "(");

 //print paramters type

Class[] paramTypes = m.getParameterTypes();
for(int j=0;j<paramTypes.length;j++)
{
 if(j>0) System.out.print(",  ");
 System.out.print(paramTypes[j].getName());
}
 System.out.println(");");
}
}

//this method prints fields of class

public static void printFields(Class cl)
{
Field[] fields = cl.getDeclaredFields();

for (int i=0; i< fields.length;i++)
{
 Field f = fields[i];
 Class type =f.getType();
 String name = f.getName();
 System.out.print(Modifier.toString(f.getModifiers()));
 System.out.println("   " + type.getName() + " " + name + ";");
}
}
public void analyze()
{
String name;

name = JOptionPane.showInputDialog
         ("class name (java.util.date)): ");

try
{

 //print class name and superclass name
Class cl = Class.forName(name);
Class supercl =cl.getSuperclass();
System.out.print("\nclass " + name);
if (supercl !=null && supercl != Object.class)
{
 System.out.print(" extends " + supercl.getName());
}
System.out.print("\n{\n");
printConstructors(cl);
System.out.println();
printMethods(cl);
System.out.println();
printFields(cl);
System.out.println("}");

 }

 catch( ClassNotFoundException e)  {e.printStackTrace();}
System.exit(0);

}//end of analyze

} // end class reverse
Andrew Thompson - 09 Oct 2007 17:12 GMT
>this is the code , i want the code to output in gui window.i tried
>JTextArea but couldn't
>get output on window.suggest me what to use for this particular code

Don't block the EDT*.  

* <http://www.google.com/search?q="block+the+EDT">

BTW.  Sentences should start with a single Upper Case
letter.  They should also include two space characters
after the full-stop, to make the text easier to read.  The
word 'I' is always Upper Case - *always*.

Signature

Andrew Thompson
http://www.athompson.info/andrew/



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.