Results 1 to 2 of 2
Thread: Help With Text Analayzer Program
- 03-05-2010, 12:59 AM #1
Member
- Join Date
- Mar 2010
- Posts
- 1
- Rep Power
- 0
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
- 03-05-2010, 05:17 AM #2
Similar Threads
-
Insert text records from text file into a DB
By nicedad in forum JDBCReplies: 8Last Post: 11-06-2009, 06:52 AM -
Neec a help in this program (printing RGB into text file)
By Hafsa Hosani in forum New To JavaReplies: 2Last Post: 03-24-2009, 12:35 PM -
how to use live validation with autocomplete in dojo text boxes in <s:text box>
By subashm28 in forum Suggestions & FeedbackReplies: 2Last Post: 01-23-2009, 04:09 PM -
find and replace text from a text file
By gezzel in forum New To JavaReplies: 2Last Post: 09-19-2008, 04:04 PM -
Unsupported Content-Type: text/html Supported ones are: [text/xml]
By luislopezco in forum Advanced JavaReplies: 0Last Post: 05-26-2008, 04:26 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks