How to Highlight Text in a ControlP5 Textfield?

I start to see why they didn’t include javafx in Processing

It really is not that difficult; the authors just failed to include the javafx.controls module, even though they did include three other modules: JavaFX Unable to add modules to Processing IDE - #3 by svan (read the entire thread)

However, the last error that you described is due to something else. I have no idea why they don’t want to support JavaFX controls. They really are good controls and were initially intended to supplant Swing.

Addendum:

Speaking of Swing, have you looked at JTextField?

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

javax.swing.JFrame frame;
java.awt.Canvas canvas;

final int _wndW = 400;
final int _wndH = 300;

void buildWnd() {
  JTextField txtFld = new JTextField("");
  txtFld.setBounds(50, 40, 280, 30);
  txtFld.setBackground(Color.WHITE);
  frame.add(txtFld);
  // **** Action **** //
  txtFld.addActionListener( new ActionListener() {
    void actionPerformed(ActionEvent actionEvent) {
      // Do something;
    }
  }
  );
  txtFld.repaint(); // To make it visible after export application.
}

void setup() {
  frame = (javax.swing.JFrame) ((processing.awt.PSurfaceAWT.SmoothCanvas) surface.getNative()).getFrame();
  canvas = (processing.awt.PSurfaceAWT.SmoothCanvas) ((processing.awt.PSurfaceAWT)surface).getNative();
  frame.setBounds(500, 300, _wndW, _wndH);
  frame.remove(canvas);

  javax.swing.SwingUtilities.invokeLater(()-> {
    buildWnd(); // Builds components on EventDispatchThread
  }
  );
}

1 Like