Guest User

Untitled

a guest
Apr 22nd, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 KB | None | 0 0
  1. /**
  2. * @(#)practiseSpeedTest.java
  3. *
  4. * practiseSpeedTest application
  5. *
  6. * @author
  7. * @version 1.00 2011/12/7
  8. */
  9. import javax.swing.*;
  10. import java.awt.*;
  11. import java.awt.event.*;
  12. public class practiseSpeedTest extends JPanel implements ActionListener{
  13. protected static final String a = "Username";
  14. protected static final String b = "Password";
  15. protected static final String c = "Enter";
  16.  
  17. public practiseSpeedTest{
  18. setLayout(new BorderLayout());
  19. JTextField username = new JTextField(50);
  20. username.setActionCommand(a);
  21. username.addActionListener(this);
  22.  
  23. JPasswordField password = new JPasswordField(32);
  24. password.setActionCommand(b);
  25. password.addActionListener(this);
  26.  
  27. JButton button = new JButton("Enter");
  28. button.setActionCommand(c);
  29. button.setActionListener(this);
  30.  
  31. JTextArea stuffWrite = new JTextArea();
  32. stuffWrite.setLineWrap(true);
  33. stuffWrite.setWrapStyleWord(true);
  34. JScrollPane scroll = new JScrollPane(stuffWrite);
  35. scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
  36. scroll.setPreferredSize(new Dimension(250, 250));
  37.  
  38. JLabel date= new JLabel(java.util.Calendar.getInstance().getTime());
  39. actionLabel.setBorder(BorderFactory.createEmptyBorder(10,0,0,0));
  40.  
  41. JLabel usernameL = new JLabel(a + ":");
  42. usernameL.setLabelFor(username);
  43. JLabel passwordL = new JLabel(b + ":");
  44. passwordL.setLabelFor(password);
  45. JLabel dateL = new JLabel(d + ":");
  46. dateL.setLabelFor(date);
  47.  
  48. JPanel panel = new JPanel();
  49. GridBagLayout grid = new GridBagLayout();
  50. GridBagConstraints d = new GridBagConstraints();
  51. panel.setLayout(grid);
  52.  
  53. JPanel top = new JPanel(new BorderLayout());
  54. top.add(username, BorderLayout.PAGE_START);
  55. top.add(password, BorderLayout.CENTER);
  56. top.add(button, BorderLayout.PAGE_END);
  57.  
  58. add(top);
  59.  
  60. JPanel center = new JPanel(new BorderLayout());
  61. center.add(date);
  62.  
  63. add(center);
  64.  
  65. JPanel bottom = new JPanel(new BorderLayout());
  66. bottom.add(stuffWrite);
  67.  
  68. add(bottom);
  69.  
  70.  
  71.  
  72. }
  73.  
  74.  
  75.  
  76. public static void main(String[] args) {
  77. SwingUtilities.invokeLater(new Runnable() {
  78. public void run() {
  79. //Turn off metal's use of bold fonts
  80. UIManager.put("swing.boldMetal", Boolean.FALSE);
  81. createAndShowGUI();
  82. }
  83. });
  84. }
  85. }
Add Comment
Please, Sign In to add comment