I want to create a window with height smaller than the minimum allowed by Processing. Is this possible?

JFrame is a Swing component; it is what they call a ‘window’. You would then add other Swing components to this window. If you add very many you would need to use a separate thread, which is not difficult to do. You would have to do your own event handling of frame components and Processing’s draw() function would no longer work, because you would not be using the default Processing frame (window). I don’t know how many frame components your app needs; the posted example is basically just a window with a band running across it. Below is another very basic demo adding a button to a JFrame. There is a more extensive example of Swing components in the Gallery: https://discourse.processing.org/t/swing-components-in-default-processingwindow/35483 . In your case you would not be using the default Processing window as shown there, but be using an actual JFrame (adding components is the same).

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

void setup() {
  surface.setVisible(false);
  JFrame frame = new JFrame("JFrame Demo");
  frame.setBounds(500,300,300,100);
  JButton btn = new JButton("Press me.");
  btn.setBounds(30,30,100,30);
  frame.add(btn);
  frame.setLayout(null); // Need this or btn takes up entire window
  frame.setVisible(true);
  ActionListener actionListener = new ActionListener() {
    public void actionPerformed(ActionEvent actionEvent) {
      println("JFrame btn hit.");
    }
  };
  btn.addActionListener(actionListener);
}
2 Likes