java how to make a gui
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextArea;
public class Foo{
public static void main(String[] args) {
JFrame f = new JFrame("A JFrame");
f.setSize(250, 250);
f.setLocation(300,200);
final JTextArea textArea = new JTextArea(10, 40);
f.getContentPane().add(BorderLayout.CENTER, textArea);
final JButton button = new JButton("Click Me");
f.getContentPane().add(BorderLayout.SOUTH, button);
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
textArea.append("Button was clicked\n");
}
});
f.setVisible(true);
}
}
Also in Java:
- Bad notification for startForeground: java.lang.RuntimeException: invalid channel for service notification: Notification
- java nested loop
- java observable to observer stack overflow
- formatting an integer in java
- get current unix timestamp java
- java methods
- java stack methods
- java 8 stream group by example
- java jaxb unmarshall xml to map
- java
- read lines of file randomly java
- numberformatexception
- java - get open ports
- filesaver javafx
- reentrantreadwritelock java
- remove item from arraylist in java
- java stream to list
- how to exit a for loop in java
- how to make a loop in java
- 2 decimal places print format JAVA
- dictionary in java
- entre clavier java
- list java oracle
- how to get length of integer in java