Processing Forum
package tooraw;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class TooRawMain extends JPanel implements ActionListener {
protected JButton renderButton;
public TooRawMain() {
renderButton = new JButton("Render");
renderButton.setText("Render");
renderButton.setToolTipText("Render the Selected Path as Raw Stream.");
renderButton.setActionCommand("render");
renderButton.addActionListener( this );
add( renderButton );
}
public static void createAndShowGUI() {
JFrame frame = new JFrame( "Main Frame" );
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
TooRawMain pane = new TooRawMain();
pane.setOpaque(true);
frame.setContentPane( pane );
frame.pack();
frame.setVisible(true);
}
public void actionPerformed(ActionEvent ae) {
if ( "render".equals( ae.getActionCommand() ) ) {
System.out.println("render command received");
renderButton.setText("doing");
PAppletRenderer.main( new String[] { "PAppletRenderer" } );
} else {
// do nothing
}
}
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
}
package tooraw;
import processing.core.PApplet;
public class PAppletRenderer extends PApplet {
public String thePath;
public PAppletRenderer( String path ) {
thePath = path;
}
@Override public void setup() {
System.out.println("running setup!");
size( 200,200 );
smooth();
}
@Override public void draw() {
System.out.println("running draw!");
background( 255, 10 );
rect( 20,20,160,160 );
text( thePath,10,10 );
}
public static void main(String args[]) {
PApplet.main(new String[] { "PAppletRenderer" });
}
}
I just want to know if what I'm trying to do is actually doable or not, and if it is doable, what am I doing wrong? Thanks for your answers :)