Drawing an empty table
in
Contributed Library Questions
•
1 month ago
How do I create an empty table like editor using processing. What I want to create is a Table with two columns
If someone enters text in column 1 row 1, a value is displayed in column 2, row 1. See an example below.
Example:
Let's say i want to count number of words in each line in and display the count in the adjacent column. User presses enter and a new row is created
(line) (count)
This is Processing Forum 4
How is everyone 3
User will write something... count gets displayed here..
How do i achieve this?
Any help will be greatly appreciated. I tried to achieve the above using textArea but I couldn't process text line by line.
Below is my code
- String text="";
- String value="";
- public void textarea1_change1(GTextArea source, GEvent event) { //_CODE_:textarea1:331610:
- String textAreaText= source.getText();
- String[] lines=textAreaText.split("\n");
- process(lines[lines.length-1]);
- }
- public void textarea2_change1(GTextArea source, GEvent event) {
- }
- synchronized public void win_draw1(GWinApplet appc, GWinData data) {
- appc.background(230);
- }
- public void process(String text){
- String[] words=text.split(" ");
- if(words!=null){
- textarea2.setText(words.length()); // if I use setText the previous value will be erased.
- }
- }
- public void createGUI(){
- G4P.messagesEnabled(false);
- G4P.setGlobalColorScheme(GCScheme.BLUE_SCHEME);
- G4P.setCursor(ARROW);
- if(frame != null)
- frame.setTitle("Sketch Window");
- textarea1 = new GTextArea(this, 2, 3, 528, 595, G4P.SCROLLBARS_NONE);
- textarea1.setOpaque(true);
- textarea1.addEventHandler(this, "textarea1_change1");
- textarea2 = new GTextArea(this, 533, 4, 267, 596, G4P.SCROLLBARS_NONE);
- textarea2.setLocalColorScheme(GCScheme.CYAN_SCHEME);
- textarea2.setOpaque(true);
- textarea2.addEventHandler(this, "textarea2_change1");
- }
1