Advertisement
8877omega_java

Untitled

Oct 5th, 2015
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.25 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.                     int ran = rnd.nextInt(100) + 20;
  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.                                      for (int i = 0; i < ran; i++){
  134.                                           area.append("*Ct>>Cn:" + "^p^\n");//コポォ
  135.                                      }
  136.                                }else{
  137.                                    /*coment outit put
  138.                                     * switch(javam){
  139.                                    case 0:{
  140.                                        area.setForeground(Color.RED);
  141.                                        area.append("!nomal error:String that is not expected\n"
  142.                                        + "Error Type : Type String(text1.getText())\n\n");
  143.                                        area.setForeground(Color.WHITE);
  144.                                    */
  145.                                  }
  146.  
  147.                                }
  148.                          case 1:{
  149.                          if(jc1.equals(ins)){
  150.                              m = Math.random();
  151.                              area.append("*Java>>Cn:Resalt{" + m + "}\n");
  152.                          }else if(jc2.equals(ins)){
  153.                              putS("Standard Mode");
  154.                              area.append("*Cp>>Cn:Standard Mode\n");
  155.                              javam = 0;
  156.                              putI(javam);
  157.                         }else{
  158.  
  159.                         }
  160.                       }
  161.                         }
  162.                   }finally{
  163.  
  164.                   }
  165.                 }
  166.             }
  167.         );
  168.  
  169.     tabbedpane.addTab("commndline", tabPanel2);
  170.     label = new JLabel();
  171.     getContentPane().add(tabbedpane, BorderLayout.CENTER);
  172.   }
  173.  
  174. @Override
  175. public void actionPerformed(ActionEvent e) {
  176.    /*
  177.     * overRide
  178.     * メゾットスタブ
  179.     */
  180.  
  181. }
  182.  
  183. //function
  184.  
  185.   static public void display_set_menu(  ){
  186.         @SuppressWarnings("unused")
  187.         class core{
  188.             public void main(String args[]){
  189.                 GuiDisplay frame = new GuiDisplay();
  190.  
  191.                 frame.setBounds(500, 500, 500, 500);
  192.                 frame.setTitle("swing.JFrame.test");
  193.                 frame.setVisible(true);
  194.                 frame.setBackground(Color.BLACK);
  195.                 UIManager.LookAndFeelInfo infos[] = UIManager.getInstalledLookAndFeels();
  196.             }
  197.       }
  198.   }
  199.  
  200.  
  201. static public void commandline_do(){
  202.     //num
  203. }
  204.  
  205. static public void putS( String str){   //string型のprintln()
  206.           System.out.println( str );
  207. }
  208.  
  209.  
  210. static public void putI( int val ){     //int型のprintln()
  211.     System.out.println( val );
  212. }
  213. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement