Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- public class Swinging extends JFrame {
- JTextField username = new JTextField(10);
- JPasswordField password = new JPasswordField(10);
- JTextArea comments = new JTextArea(4,15);
- JButton ok = new JButton("OK");
- JButton cancel = new JButton("Cancel");
- JLabel usernamelabel = new JLabel("Username");
- JLabel passwordlabel = new JLabel("Password");
- JScrollPane scroll = new JScrollPane(comments, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
- public Swinging(){
- super("Button Frame");
- setSize(200,200);
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- JPanel pane = new JPanel();
- password.setEchoChar((char)248);
- pane.add(usernamelabel);
- pane.add(username);
- pane.add(passwordlabel);
- pane.add(password);
- pane.add(scroll);
- pane.add(ok);
- pane.add(cancel);
- add(pane);
- setVisible(true);
- }
- public static void main(String[] args){
- Swinging f = new Swinging();
- JOptionPane.showConfirmDialog(null, "Error reading a file, want to try again?", "Input Error",
- JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE);
- JOptionPane.showMessageDialog(null, "an asteroid destroyed earth!", "Asteroid Destruction Alert",
- JOptionPane.WARNING_MESSAGE);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement