Hello,
I found this code
Code:
import javax.swing.*;
import java.awt.*;
int gX,gY;
ta_scroll gui;
class ta_scroll{
private JFrame f; //Main frame
private JTextArea ta; // Text area
private JScrollPane sbrText; // Scroll pane for text area
private JButton btnQuit; // Quit Program
public ta_scroll(){ //Constructor
// Create Frame
f = new JFrame("Swing Demo");
f.setBounds(gX+50, gY+120, 200, 20); //set the f frame position according to main frame
f.removeNotify();f.setUndecorated(true);
// Create Scrolling Text Area in Swing
ta = new JTextArea("text ici", 5, 20); // définie la taille de la zone de texte
ta.setLineWrap(true);
sbrText = new JScrollPane(ta);
sbrText.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
}
public void launchFrame(){ // Create Layout
// Add text areato frame
f.add(sbrText);
//Display Frame
f.pack();
f.setVisible(true);
}
}
void setup(){
size(500,500);
}
void draw(){
gX=frame.getX();gY=frame.getY();println(gX);
if (frameCount==4){gui = new ta_scroll();gui.f.setAlwaysOnTop(true);gui.launchFrame();}
}
This work very well but it open the text area in a new frame.
I would like to edit a text in the main frame so i tried this
Code:
import javax.swing.*;
import java.awt.*;
JScrollPane sbrText; // Scroll pane for text area
JTextArea ta = new JTextArea("text ici", 5, 20); // définie la taille de la zone de texte
void setup()
{
size(500,500);
ta.setLineWrap(true);
sbrText = new JScrollPane(ta);
sbrText.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
}
void draw()
{
frame.add(sbrText);
//this.add(sbrText); //doesn't work either
//frame.pack(); //doesn't work here (reduce frame
}
but nothing apear in the frame.
I don't know why and what i must do to use this text editor in the processing frame
thanks for help me