Advertisement
Guest User

Untitled

a guest
Mar 31st, 2015
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.42 KB | None | 0 0
  1. package gui;
  2.  
  3. import java.awt.*;
  4. import java.awt.event.ActionEvent;
  5. import java.awt.event.ActionListener;
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13. import javax.swing.ButtonGroup;
  14. import javax.swing.JButton;
  15. import javax.swing.JFrame;
  16. import javax.swing.JLabel;
  17. import javax.swing.JPanel;
  18. import javax.swing.JRadioButton;
  19. import javax.swing.JScrollPane;
  20. import javax.swing.JTextArea;
  21. import javax.swing.JTextField;
  22. import javax.swing.SwingConstants;
  23.  
  24.  
  25. // An AWT GUI program inherits from the top-level container java.awt.Frame
  26. public class CreateRecord extends Frame implements ActionListener {
  27. // This class acts as KeyEvent Listener
  28.  
  29. private JTextField name,company,release,playtime,version; // single-line TextField to receive tfInput key
  30. private JTextArea desc; // multi-line TextArea to taDisplay result
  31. private JButton submit,reset,menu;
  32. /** Constructor to setup the GUI */
  33. public CreateRecord() {
  34.  
  35. JFrame frame = new JFrame("FrameDemo");
  36. frame.setLayout(new FlowLayout());
  37. frame.add(new JLabel("<html>Title of game:<br></html> ", SwingConstants.CENTER));
  38. name = new JTextField(60);
  39. frame.add(name);
  40. frame.add(new JLabel("<html>Company Name:<br></html> ", SwingConstants.CENTER));
  41. company = new JTextField(60);
  42. frame.add(company);
  43. frame.add(new JLabel("<html><br>Description</html>", SwingConstants.CENTER));
  44. desc = new JTextArea(5, 60);
  45. JScrollPane sp = new JScrollPane(desc);
  46. frame.add(sp);
  47. frame.add(new JLabel("<html>Year of release:</html> ", SwingConstants.CENTER));
  48. release = new JTextField(10);
  49. frame.add(release);
  50. frame.add(new JLabel("<html>Average Playtime in hours:<br></html> ", SwingConstants.CENTER));
  51. playtime = new JTextField(10);
  52. frame.add(playtime);
  53. frame.add(new JLabel("<html>Version:<br></html> ", SwingConstants.CENTER));
  54. version= new JTextField(10);
  55. frame.add(version);
  56.  
  57. JRadioButton sonyT = new JRadioButton("True");
  58. sonyT.setSelected(true);
  59. JRadioButton sonyF = new JRadioButton("False");
  60.  
  61. JRadioButton microT = new JRadioButton("True");
  62. sonyT.setSelected(true);
  63. JRadioButton microF = new JRadioButton("False");
  64.  
  65. JRadioButton ninT = new JRadioButton("True");
  66. sonyT.setSelected(true);
  67. JRadioButton ninF = new JRadioButton("False");
  68.  
  69. ButtonGroup sony = new ButtonGroup();
  70. sony.add(sonyF);
  71. sony.add(sonyT);
  72.  
  73. ButtonGroup micro = new ButtonGroup();
  74. sony.add(microF);
  75. sony.add(microT);
  76.  
  77. ButtonGroup nin = new ButtonGroup();
  78. sony.add(ninF);
  79. sony.add(ninT);
  80.  
  81.  
  82.  
  83.  
  84. frame.add(new JLabel("<html>Available sony<br></html> ", SwingConstants.CENTER));
  85. frame.add(sonyF);
  86. frame.add(sonyT);
  87.  
  88. frame.add(new JLabel("<html>Available microsoft<br></html> ", SwingConstants.CENTER));
  89. frame.add(microF);
  90. frame.add(microT);
  91.  
  92. frame.add(new JLabel("<html>Available microsoft<br></html> ", SwingConstants.CENTER));
  93. frame.add(ninF);
  94. frame.add(ninT);
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101. reset = new JButton("reset"); //submit button
  102. reset.addActionListener(this);
  103. frame.add(reset);
  104. submit = new JButton("Submit");
  105. submit.addActionListener(this);
  106. frame.add(submit);
  107. menu = new JButton("menu");
  108. menu.addActionListener(this);
  109. frame.add(menu);
  110. //submit button
  111.  
  112. // setDefaultCloseOperation
  113. //set sizes and titles
  114.  
  115. frame.setResizable(false);//stops resizing
  116. frame.setTitle("Classic Game Database"); //title of window
  117. frame.setSize(700, 500); //size of window
  118. frame.setVisible(true);
  119. }
  120.  
  121. /** The entry main() method */
  122. public static void main(String[] args)
  123. {
  124. new CreateRecord();
  125. }
  126.  
  127. @Override
  128. public void actionPerformed(ActionEvent act)
  129. {
  130.  
  131. Object source = act.getSource();
  132. if (source == submit)
  133. {
  134. //validate + create
  135.  
  136. }
  137. else if(source == reset)
  138. {
  139. System.out.println("act");
  140. name.setText("");
  141. company.setText("");
  142. release.setText("");
  143. version.setText("");
  144. playtime.setText("");
  145. desc.setText("");
  146.  
  147. }
  148. else if(source == menu)
  149. {
  150. //go back to
  151. }
  152.  
  153. }
  154.  
  155.  
  156. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement