Advertisement
Guest User

Untitled

a guest
May 29th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.27 KB | None | 0 0
  1. import javax.swing.*;
  2.  
  3. public class Swinging extends JFrame {
  4.     JTextField username = new JTextField(10);
  5.     JPasswordField password = new JPasswordField(10);
  6.     JTextArea comments = new JTextArea(4,15);
  7.     JButton ok = new JButton("OK");
  8.     JButton cancel = new JButton("Cancel");
  9.     JLabel usernamelabel = new JLabel("Username");
  10.     JLabel passwordlabel = new JLabel("Password");
  11.     JScrollPane scroll = new JScrollPane(comments, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
  12.    
  13.    
  14.  
  15.     public Swinging(){
  16.         super("Button Frame");
  17.        
  18.         setSize(200,200);
  19.         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  20.         JPanel pane = new JPanel();
  21.         password.setEchoChar((char)248);
  22.        
  23.         pane.add(usernamelabel);
  24.         pane.add(username);
  25.         pane.add(passwordlabel);
  26.         pane.add(password);
  27.        
  28.         pane.add(scroll);
  29.         pane.add(ok);
  30.         pane.add(cancel);
  31.         add(pane);
  32.         setVisible(true);
  33.     }
  34.    
  35.     public static void main(String[] args){
  36.         Swinging f = new Swinging();
  37.         JOptionPane.showConfirmDialog(null, "Error reading a file, want to try again?", "Input Error",
  38.                 JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE);
  39.         JOptionPane.showMessageDialog(null, "an asteroid destroyed earth!", "Asteroid Destruction Alert",
  40.                 JOptionPane.WARNING_MESSAGE);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement