HOW does it work?
the easiest way is to create a standard frame with the preset class JOptionPane.
- create a standard main-program setup
package JFrame;
public class printFrame {
void start () {
}
public static void main(String[] args) {
new printFrame().start();
}
}
a small example as that does not necessarily need a constructor
- import JOptionPane
import javax.swing.JOptionPane;
- add: JOptionPane.showMessageDialog(frame, message, title, messageOption);
in the start method
void start () {
JOptionPane.showMessageDialog(frame, message, title, messageOption);
}
- create the value for the variables | frame can be set null for default. An example is shown below:
String title = "OUTPUT WINDOW";
String message = "HELLOWORLD";
JFrame frame = null;
int messageOption = JOptionPane.INFORMATION_MESSAGE;
In this example we import the preset class JFrame, to work with a JFrame, frame.
Program
package JFrame;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
public class printFrame {
String title = "OUTPUT WINDOW";
String message = "HELLOWORLD";
JFrame frame = null;
int messageOption = JOptionPane.INFORMATION_MESSAGE;
void start () {
JOptionPane.showMessageDialog(frame, message, title, messageOption);
}
public static void main(String[] args) {
new printFrame().start();
}
}
OUTPUT
Synonym: GUI OUtPUT | JOptionPane OUTPUT | SWING OUTPUT | DISPLay output