Results 1 to 3 of 3

Thread: TextComponent class in java

  1. #1
    AllenBrown is offline Senior Member
    Join Date
    Dec 2009
    Posts
    240
    Rep Power
    3

    Default TextComponent class in java

    I just started learning concepts of java. I am unable to use TextComponent class. So please provide me any idea about how to use TextComponent class in java language. Thanks in advance.

  2. #2
    ScottWright is offline Senior Member
    Join Date
    Dec 2009
    Posts
    243
    Rep Power
    3

    Default

    Following code helps you to understand use of TextComponent class

    import java.awt.BorderLayout;
    import java.text.MessageFormat;
    java.awt.TextComponent

    public class TextDemo {
    public static void main(String[] arjjgs) throws Exception {
    final JTextArea textArea1 = new JTextArea();
    textArea.setText("text");
    JScrollPane jScrollPane1 = new JScrollPane(textArea);
    final MessageFormat header1 = new MessageFormat("My Header");
    final MessageFormat footer1 = new MessageFormat("My Footer");

    JPanel contentPane1 = new JPanel();
    contentPane.setLayout(new BorderLayout());
    contentPane.add(jScrollPane, BorderLayout.CENTER);

    JFrame frame1 = new JFrame();
    frame1.setTitle("Text-component Printing Demo");
    frame1.setSize(300, 200);
    frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLO SE);

    frame1.setContentPane(contentPane);
    frame1.setVisible(true);
    textArea.print(header1, footer1, true, null, null, true);
    }}


  3. #3
    BakerJones is offline Senior Member
    Join Date
    Dec 2009
    Posts
    244
    Rep Power
    3

    Default

    Following are methods of TextComponent class:

    • setCaretPosition(int pos1)

    • setText(String strg)

    • setSelectionStart(int selectionStrt1)

    • setSelectionEnd(int selectionEnd1)

    • setEditable(boolean bln)

Similar Threads

  1. Polygon class in JAVA
    By Shane Robinson in forum Programming
    Replies: 2
    Last Post: 07-04-2010, 06:21 AM
  2. TextComponent class in java
    By TorresScott in forum Programming
    Replies: 3
    Last Post: 06-18-2010, 01:43 PM
  3. Using MediaTracker class in JAVA
    By MyersGray in forum Programming
    Replies: 2
    Last Post: 04-01-2010, 02:02 PM
  4. FileWriter class in JAVA
    By Theodosia Goodman in forum Programming
    Replies: 2
    Last Post: 03-30-2010, 12:37 PM
  5. JSeparator class of java
    By PerryCollins in forum Programming
    Replies: 2
    Last Post: 02-17-2010, 01:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
SEO by SubmitEdge

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48