Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package gui;
- import java.awt.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import javax.swing.ButtonGroup;
- import javax.swing.JButton;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JPanel;
- import javax.swing.JRadioButton;
- import javax.swing.JScrollPane;
- import javax.swing.JTextArea;
- import javax.swing.JTextField;
- import javax.swing.SwingConstants;
- // An AWT GUI program inherits from the top-level container java.awt.Frame
- public class CreateRecord extends Frame implements ActionListener {
- // This class acts as KeyEvent Listener
- private JTextField name,company,release,playtime,version; // single-line TextField to receive tfInput key
- private JTextArea desc; // multi-line TextArea to taDisplay result
- private JButton submit,reset,menu;
- /** Constructor to setup the GUI */
- public CreateRecord() {
- JFrame frame = new JFrame("FrameDemo");
- frame.setLayout(new FlowLayout());
- frame.add(new JLabel("<html>Title of game:<br></html> ", SwingConstants.CENTER));
- name = new JTextField(60);
- frame.add(name);
- frame.add(new JLabel("<html>Company Name:<br></html> ", SwingConstants.CENTER));
- company = new JTextField(60);
- frame.add(company);
- frame.add(new JLabel("<html><br>Description</html>", SwingConstants.CENTER));
- desc = new JTextArea(5, 60);
- JScrollPane sp = new JScrollPane(desc);
- frame.add(sp);
- frame.add(new JLabel("<html>Year of release:</html> ", SwingConstants.CENTER));
- release = new JTextField(10);
- frame.add(release);
- frame.add(new JLabel("<html>Average Playtime in hours:<br></html> ", SwingConstants.CENTER));
- playtime = new JTextField(10);
- frame.add(playtime);
- frame.add(new JLabel("<html>Version:<br></html> ", SwingConstants.CENTER));
- version= new JTextField(10);
- frame.add(version);
- JRadioButton sonyT = new JRadioButton("True");
- sonyT.setSelected(true);
- JRadioButton sonyF = new JRadioButton("False");
- JRadioButton microT = new JRadioButton("True");
- sonyT.setSelected(true);
- JRadioButton microF = new JRadioButton("False");
- JRadioButton ninT = new JRadioButton("True");
- sonyT.setSelected(true);
- JRadioButton ninF = new JRadioButton("False");
- ButtonGroup sony = new ButtonGroup();
- sony.add(sonyF);
- sony.add(sonyT);
- ButtonGroup micro = new ButtonGroup();
- sony.add(microF);
- sony.add(microT);
- ButtonGroup nin = new ButtonGroup();
- sony.add(ninF);
- sony.add(ninT);
- frame.add(new JLabel("<html>Available sony<br></html> ", SwingConstants.CENTER));
- frame.add(sonyF);
- frame.add(sonyT);
- frame.add(new JLabel("<html>Available microsoft<br></html> ", SwingConstants.CENTER));
- frame.add(microF);
- frame.add(microT);
- frame.add(new JLabel("<html>Available microsoft<br></html> ", SwingConstants.CENTER));
- frame.add(ninF);
- frame.add(ninT);
- reset = new JButton("reset"); //submit button
- reset.addActionListener(this);
- frame.add(reset);
- submit = new JButton("Submit");
- submit.addActionListener(this);
- frame.add(submit);
- menu = new JButton("menu");
- menu.addActionListener(this);
- frame.add(menu);
- //submit button
- // setDefaultCloseOperation
- //set sizes and titles
- frame.setResizable(false);//stops resizing
- frame.setTitle("Classic Game Database"); //title of window
- frame.setSize(700, 500); //size of window
- frame.setVisible(true);
- }
- /** The entry main() method */
- public static void main(String[] args)
- {
- new CreateRecord();
- }
- @Override
- public void actionPerformed(ActionEvent act)
- {
- Object source = act.getSource();
- if (source == submit)
- {
- //validate + create
- }
- else if(source == reset)
- {
- System.out.println("act");
- name.setText("");
- company.setText("");
- release.setText("");
- version.setText("");
- playtime.setText("");
- desc.setText("");
- }
- else if(source == menu)
- {
- //go back to
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement