Results 1 to 2 of 2
  1. #1
    Woofman is offline Member
    Join Date
    Mar 2010
    Posts
    1
    Rep Power
    0

    Default Help With Text Analayzer Program

    I am trying to create a text analyzer program and i am having real trouble doing so. I have been given the skeleton code and i have tried to create this program myself but i cant seem to do so

    import java.awt.*;
    import java.awt.event.*;

    import javax.swing.*;


    public class text_analysis extends JPanel implements ActionListener {

    JPanel board; // Panel for buttons
    JPanel canvas; // Panel for drawing on
    JPanel text; // Panel for the text
    JButton Analyze;
    JButton Reset;
    JTextArea textinput;
    JScrollPane areaScrollPane;

    public text_analysis() {

    super(true); // Call constructor of parent

    // Standard layout (flow)
    setLayout(new FlowLayout());

    // Set up two panels, control board and canvas
    board = new JPanel(true);
    canvas = new JPanel (true);
    text = new JPanel(new BorderLayout());
    board.setPreferredSize(new Dimension(200, 40));
    canvas.setPreferredSize(new Dimension(400, 300));
    board.setBorder(BorderFactory.createLineBorder(Col or.black));
    canvas.setBorder(BorderFactory.createLineBorder(Co lor.blue));

    // Create buttons and attach listeners


    Analyze = new JButton("Analyze");
    Analyze.addActionListener(this);


    ;
    Reset = new JButton ("Reset");
    Reset.addActionListener(this);


    ;
    //Create an editor pane.
    textinput = new JTextArea();
    textinput.setLineWrap(true);
    textinput.setWrapStyleWord(true);
    areaScrollPane = new JScrollPane(textinput);
    areaScrollPane.setVerticalScrollBarPolicy(
    JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    areaScrollPane.setPreferredSize(new Dimension(250, 250));
    areaScrollPane.setBorder(
    BorderFactory.createCompoundBorder(
    BorderFactory.createCompoundBorder(
    BorderFactory.createTitledBorder("Text Input"),
    BorderFactory.createEmptyBorder(5,5,5,5)),
    areaScrollPane.getBorder()));
    text.add(areaScrollPane,BorderLayout.CENTER);

    add(canvas);
    add(board);
    board.add(Analyze);
    board.add(Reset);
    add(text, BorderLayout.LINE_START);

    }

    public void actionPerformed(ActionEvent e) {
    // Called when a button is pressed
    // Set current working colour, depending on button

    //Graphics g1 = canvas.getGraphics();
    String input = textinput.getText();
    System.out.println(input);


    }

    public static void main(String[] args) {
    // Create a text_analysis entity
    text_analysis b = new text_analysis();

    // Set up outer frame, and its exit behaviour
    JFrame frame = new JFrame("Text Analysis");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E);

    // Set the main content frame to be the Blob,
    // size the frame (pack) and make it visible
    frame.setContentPane(b);
    frame.pack();
    frame.setVisible(true);


    }
    };


    What i have to do is program it so that it analyzes enterred text and produces an output listing how many words of a length there are. It must also be able to be reset to its original state by the reset button

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

    Default

    Quote Originally Posted by Woofman View Post
    I am trying to create a text analyzer program and i am having real trouble doing so.
    <snip/>
    What i have to do is program
    Yup. So go ahead and do just that.

    db

Similar Threads

  1. Replies: 8
    Last Post: 11-06-2009, 06:52 AM
  2. Neec a help in this program (printing RGB into text file)
    By Hafsa Hosani in forum New To Java
    Replies: 2
    Last Post: 03-24-2009, 12:35 PM
  3. Replies: 2
    Last Post: 01-23-2009, 04:09 PM
  4. find and replace text from a text file
    By gezzel in forum New To Java
    Replies: 2
    Last Post: 09-19-2008, 04:04 PM
  5. Replies: 0
    Last Post: 05-26-2008, 04:26 PM

Posting Permissions

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