Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- vimport javax.swing.*;
- import java.awt.Color;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.io.*;
- import java.util.*;
- public class WindowApplication extends JFrame implements ActionListener{
- private JTextField textField;
- private JFrame frame;//
- private JButton button;
- public WindowApplication() {
- setSize(320 , 240);
- setDefaultCloseOperation(EXIT_ON_CLOSE);
- setLocationRelativeTo(null);
- setBackground(Color.BLACK);
- button = new JButton("Change title");
- button.addActionListener(this);
- textField = new JTextField(20);
- getContentPane().add(textField);
- getContentPane().add(button);
- }
- @Override
- public void actionPerformed(ActionEvent arg0) {
- String text = textField.getText();
- setTitle(text);
- }
- public static void main(String[] args) {
- Work work = new Work();
- Thread t = new Thread(work);
- t.start();
- }
- }
- class Work implements Runnable{
- @Override
- public void run() {
- new WindowApplication().setVisible(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement