Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @(#)practiseSpeedTest.java
- *
- * practiseSpeedTest application
- *
- * @author
- * @version 1.00 2011/12/7
- */
- import javax.swing.*;
- import java.awt.*;
- import java.awt.event.*;
- public class practiseSpeedTest extends JPanel implements ActionListener{
- protected static final String a = "Username";
- protected static final String b = "Password";
- protected static final String c = "Enter";
- public practiseSpeedTest{
- setLayout(new BorderLayout());
- JTextField username = new JTextField(50);
- username.setActionCommand(a);
- username.addActionListener(this);
- JPasswordField password = new JPasswordField(32);
- password.setActionCommand(b);
- password.addActionListener(this);
- JButton button = new JButton("Enter");
- button.setActionCommand(c);
- button.setActionListener(this);
- JTextArea stuffWrite = new JTextArea();
- stuffWrite.setLineWrap(true);
- stuffWrite.setWrapStyleWord(true);
- JScrollPane scroll = new JScrollPane(stuffWrite);
- scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
- scroll.setPreferredSize(new Dimension(250, 250));
- JLabel date= new JLabel(java.util.Calendar.getInstance().getTime());
- actionLabel.setBorder(BorderFactory.createEmptyBorder(10,0,0,0));
- JLabel usernameL = new JLabel(a + ":");
- usernameL.setLabelFor(username);
- JLabel passwordL = new JLabel(b + ":");
- passwordL.setLabelFor(password);
- JLabel dateL = new JLabel(d + ":");
- dateL.setLabelFor(date);
- JPanel panel = new JPanel();
- GridBagLayout grid = new GridBagLayout();
- GridBagConstraints d = new GridBagConstraints();
- panel.setLayout(grid);
- JPanel top = new JPanel(new BorderLayout());
- top.add(username, BorderLayout.PAGE_START);
- top.add(password, BorderLayout.CENTER);
- top.add(button, BorderLayout.PAGE_END);
- add(top);
- JPanel center = new JPanel(new BorderLayout());
- center.add(date);
- add(center);
- JPanel bottom = new JPanel(new BorderLayout());
- bottom.add(stuffWrite);
- add(bottom);
- }
- public static void main(String[] args) {
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- //Turn off metal's use of bold fonts
- UIManager.put("swing.boldMetal", Boolean.FALSE);
- createAndShowGUI();
- }
- });
- }
- }
Add Comment
Please, Sign In to add comment