Advertisement
8877omega_java

Untitled

Oct 5th, 2015
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.23 KB | None | 0 0
  1. package window_st;
  2.  
  3. import java.awt.BorderLayout;
  4. import java.awt.Color;
  5. import java.awt.Container;
  6. import java.awt.event.ActionEvent;
  7. import java.awt.event.ActionListener;
  8. import java.util.Random;
  9.  
  10. import javax.swing.JButton;
  11. import javax.swing.JFrame;
  12. import javax.swing.JLabel;
  13. import javax.swing.JMenu;
  14. import javax.swing.JMenuBar;
  15. import javax.swing.JMenuItem;
  16. import javax.swing.JPanel;
  17. import javax.swing.JScrollPane;
  18. import javax.swing.JTabbedPane;
  19. import javax.swing.JTextArea;
  20. import javax.swing.JTextField;
  21. import javax.swing.UIManager;
  22.  
  23.  
  24.  
  25.  
  26. public class GuiDisplay extends JFrame implements ActionListener{
  27. Container cp;
  28. JTextField text1;
  29. JTextField text2;
  30. JLabel label;
  31.  
  32. public static void main(String[] args){
  33. GuiDisplay frame = new GuiDisplay();
  34.  
  35. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  36. frame.setBounds(500, 500, 500, 500);
  37. frame.setTitle("swing.JFrame.test");
  38. frame.setVisible(true);
  39. frame.setBackground(Color.BLACK);
  40. UIManager.LookAndFeelInfo infos[] = UIManager.getInstalledLookAndFeels();
  41. JMenuBar menubar = new JMenuBar();
  42. JMenu menu = new JMenu("Setting");
  43. menubar.add(menu);
  44. JMenuItem menuitem1_1 = new JMenuItem("Display");
  45. menu.add(menuitem1_1);
  46. menuitem1_1.addActionListener(
  47. new ActionListener(){
  48. public void actionPerformed(ActionEvent e1) {
  49. display_set_menu();
  50. }
  51. }
  52. );
  53. frame.setJMenuBar(menubar);
  54.  
  55. putS("getClassName:");
  56.  
  57. for(int i = 0 ; i < infos.length ; i++){
  58. putS(infos[i].getClassName());
  59. }
  60.  
  61. putS("getName:");
  62.  
  63. for(int i = 0 ; i < infos.length ; i++){
  64. putS(infos[i].getName());
  65. }
  66. }
  67.  
  68. protected GuiDisplay(){
  69. JTabbedPane tabbedpane = new JTabbedPane();
  70. putS("Window visible(true,true)");
  71. text1 = new JTextField("", 20);
  72. text2 = new JTextField("", 30);
  73. JTextArea area = new JTextArea(3, 20);
  74. JScrollPane scrollpane = new JScrollPane(area, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
  75. JPanel p = new JPanel();
  76. area.setRows(15);
  77. area.setColumns(40);
  78. area.setBackground(Color.BLACK);
  79. area.setForeground(Color.WHITE);
  80. JButton button = new JButton("Run");
  81. button.addActionListener(this);
  82.  
  83.  
  84. JPanel tabPanel2 = new JPanel();
  85. tabPanel2.add(new JLabel("Command"));
  86. tabPanel2.add(text1);
  87. tabPanel2.add(p.add(button));
  88. tabPanel2.add(new JLabel("\nConsole"));
  89. tabPanel2.add(scrollpane);
  90. button.addActionListener(
  91. new ActionListener(){
  92. public void actionPerformed(ActionEvent e) {
  93. int javam;
  94. javam = 0;
  95. String ins, c1, c2, c3, c4, c5, c6, jc1, jc2;
  96. c1 = "run";
  97. c2 = "create";
  98. c3 = "create window";
  99. c4 = "mode on Java";
  100. c5 = "create text";
  101. c6 = "text ^p^";
  102. jc1 = "Math.random()";
  103. jc2 = "exit()";
  104. Random rnd = new Random();
  105.  
  106. @SuppressWarnings("unused")//未使用
  107. final int to;
  108. to = 5;
  109. double m;
  110.  
  111. try{
  112. ins = text1.getText();
  113. System.out.println(text1);
  114.  
  115. switch (javam){
  116. case 0:{if (c1.equals(ins)){
  117. area.append("¿Cp>>Cn:" + text1.getText() + "\n");
  118. }else if(c2.equals(ins)){
  119. area.append("!Cp>>Cn:" + text1.getText() + " <window|text>\n");
  120. }else if(c3.equals(ins)){
  121. JFrame frame = new JFrame("Cp window");
  122. frame.setBounds(100, 100, 200, 160);
  123. frame.setVisible(true);
  124. area.append("*Cp>>Cn:Window Create!\n");
  125. }else if(c4.equals(ins)){
  126. javam = 1;
  127. putI(javam);
  128. area.append("*Yat java:©Java Platform, Standard Edition (Java SE) \n"
  129. + " exit() to Standard mode.\n");
  130. }else if(c5.equals(ins)){
  131. area.append("*Ct>>Cn:" + "error:Not declared\n");
  132. }else if(c6.equals(ins)){
  133. int ran = rnd.nextInt(100) + 20;
  134. putI(ran);
  135. for (int i = 0; i < ran; i++){
  136. area.append("*Ct>>Cn:" + "^p^\n");
  137. }
  138. }else{
  139. /*coment outit put
  140. * switch(javam){
  141. case 0:{
  142. area.setForeground(Color.RED);
  143. area.append("!nomal error:String that is not expected\n"
  144. + "Error Type : Type String(text1.getText())\n\n");
  145. area.setForeground(Color.WHITE);
  146. */
  147. }
  148.  
  149. }
  150. case 1:{
  151. if(jc1.equals(ins)){
  152. m = Math.random();
  153. area.append("*Java>>Cn:Resalt{" + m + "}\n");
  154. }else if(jc2.equals(ins)){
  155. putS("Standard Mode");
  156. area.append("*Cp>>Cn:Standard Mode\n");
  157. javam = 0;
  158. putI(javam);
  159. }else{
  160.  
  161. }
  162. }
  163. }
  164. }finally{
  165.  
  166. }
  167. }
  168. }
  169. );
  170.  
  171. tabbedpane.addTab("commndline", tabPanel2);
  172. label = new JLabel();
  173. getContentPane().add(tabbedpane, BorderLayout.CENTER);
  174. }
  175.  
  176. @Override
  177. public void actionPerformed(ActionEvent e) {
  178. /*
  179. * overRide
  180. * メゾットスタブ
  181. */
  182.  
  183. }
  184.  
  185. //function
  186.  
  187. static public void display_set_menu( ){
  188. @SuppressWarnings("unused")
  189. class core{
  190. public void main(String args[]){
  191. GuiDisplay frame = new GuiDisplay();
  192.  
  193. frame.setBounds(500, 500, 500, 500);
  194. frame.setTitle("swing.JFrame.test");
  195. frame.setVisible(true);
  196. frame.setBackground(Color.BLACK);
  197. UIManager.LookAndFeelInfo infos[] = UIManager.getInstalledLookAndFeels();
  198. }
  199. }
  200. }
  201.  
  202.  
  203. static public void commandline_do(){
  204. //num
  205. }
  206.  
  207. static public void putS( String str){ //string型のprintln()
  208. System.out.println( str );
  209. }
  210.  
  211.  
  212. static public void putI( int val ){ //int型のprintln()
  213. System.out.println( val );
  214. }
  215. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement