Solved

Display README file

Posted on 2001-06-15
1
162 Views
Last Modified: 2010-03-31
Can any one give me a short sample app. where you pop-up larger (scrollable) document in a separate text window.
0
Comment
Question by:aljehin
1 Comment
 
LVL 3

Accepted Solution

by:
superschlonz earned 20 total points
ID: 6197194
The following application shows the first argument as title of the window and
the second as the text.

public TextFrame extends JFrame
{
  JTextField textfield = new JTextField();
  public TextFrame()
  {
    enableEvents(AWTEvent.WINDOW_EVENT_MASK);
    getContentPane().setLayout( new BorderLayout() );
    JScrollPane sp = new JScrollPane();
    sp.getViewport().add( textfield, null );
    getContentPane().add( sp, BorderLayout.CENTER );
  }
  public void show( String title, String text )
  {
    setTitle( title );
    textfield.setText( text );
    setVisible( true );
  }
  protected void processWindowEvent(WindowEvent e)
  {
    if(e.getID() == WindowEvent.WINDOW_CLOSING)
    {
      super.processWindowEvent(e);
      System.exit(0);
    }
  }
  public static void main( String args[] )
  {
    TextFrame tf = new TextFrame();
    tf.show( args[0], args[1] );
  }
}
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now