Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.FlowLayout;
- import java.awt.GridLayout;
- import javax.swing.JButton;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JPanel;
- import javax.swing.JScrollPane;
- import javax.swing.JTextArea;
- import javax.swing.JTextField;
- import javax.swing.border.EtchedBorder;
- import javax.swing.border.TitledBorder;
- public class EmployeeUserInterface extends JFrame {
- private static final int FRAME_WIDTH = 600;
- private static final int FRAME_HEIGHT = 650;
- private static final int AREA_ROWS = 4;
- private static final int AREA_COLUMNS = 10; // Create a non static integer
- private static final int FIELD_WIDTH = 10;
- private JLabel eId, eTelephone, eName, eYears;
- private JTextField eIdField, eTelephoneField, eNameField, eYearsField;
- private JButton buttonPrevious, buttonNext, buttonDisplayAll, buttonExit;
- private JTextArea employeeRecords;
- public EmployeeUserInterface() {
- setTitle("Employee Record Browser");
- employeeRecords = new JTextArea(AREA_ROWS, AREA_COLUMNS);
- employeeRecords.setEditable(false);
- createTextField();
- createPanel();
- createButton();
- setSize(FRAME_WIDTH, FRAME_HEIGHT);
- }
- private void createTextField() {
- eId = new JLabel("Employee Identification");
- eIdField = new JTextField(FIELD_WIDTH);
- eIdField.setText("Test");
- eIdField.setEnabled(false);
- eTelephone = new JLabel("Telephone Number");
- eTelephoneField = new JTextField(FIELD_WIDTH);
- eTelephoneField.setText("Test");
- eName = new JLabel("Employee Name");
- eNameField = new JTextField(FIELD_WIDTH);
- eNameField.setText("Test");
- eYears = new JLabel("Years of Work");
- eYearsField = new JTextField(FIELD_WIDTH);
- eYearsField.setText("Test");
- }
- private void createButton() {
- buttonPrevious = new JButton("<< Previous");
- buttonNext = new JButton(">> Next");
- buttonDisplayAll = new JButton("Display All");
- buttonExit = new JButton("Exit");
- }
- private void createPanel() {
- JPanel panel = new JPanel();
- panel.setLayout(new GridLayout(2, 1));
- JPanel currentRecordPanel = new JPanel();
- currentRecordPanel.setBorder(new TitledBorder(new EtchedBorder(), "Current Records"));
- currentRecordPanel.setLayout(new FlowLayout());
- currentRecordPanel.add(eId);
- currentRecordPanel.add(eIdField);
- JScrollPane scrollPane = new JScrollPane(employeeRecords);
- scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
- scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
- JPanel allRecordPanel = new JPanel();
- allRecordPanel.setBorder(new TitledBorder(new EtchedBorder(), "All Records"));
- allRecordPanel.add(scrollPane);
- /*JPanel buttonPanel = new JPanel();
- buttonPanel.setLayout(new FlowLayout());
- buttonPanel.add(buttonPrevious);
- buttonPanel.add(buttonNext);
- buttonPanel.add(buttonDisplayAll);
- buttonPanel.add(buttonExit);*/
- panel.add(currentRecordPanel);
- panel.add(allRecordPanel);
- //panel.add(buttonPanel);
- add(panel);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement