Advertisement
8877omega_java

Untitled

Oct 3rd, 2015
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.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.  
  9. import javax.swing.JButton;
  10. import javax.swing.JFrame;
  11. import javax.swing.JLabel;
  12. import javax.swing.JPanel;
  13. import javax.swing.JScrollPane;
  14. import javax.swing.JTabbedPane;
  15. import javax.swing.JTextArea;
  16. import javax.swing.JTextField;
  17. import javax.swing.UIManager;
  18.  
  19. public class GuiDisplay extends JFrame implements ActionListener{
  20.     Container cp;
  21.     JTextField text1;
  22.     JTextField text2;
  23.     JLabel label;
  24.  
  25.   public static void main(String[] args){
  26.     GuiDisplay frame = new GuiDisplay();
  27.  
  28.     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  29.     frame.setBounds(500, 500, 500, 500);
  30.     frame.setTitle("swing.JFrame.test");
  31.     frame.setVisible(true);
  32.     frame.setBackground(Color.BLACK);
  33.     UIManager.LookAndFeelInfo infos[] = UIManager.getInstalledLookAndFeels();
  34.  
  35.     System.out.println("getClassName:");
  36.  
  37.     for(int i = 0 ; i < infos.length ; i++){
  38.       System.out.println(infos[i].getClassName());
  39.     }
  40.  
  41.     System.out.println("getName:");
  42.  
  43.     for(int i = 0 ; i < infos.length ; i++){
  44.       System.out.println(infos[i].getName());
  45.     }
  46.   }
  47.  
  48.   GuiDisplay(){
  49.     JTabbedPane tabbedpane = new JTabbedPane();
  50.  
  51.     text1 = new JTextField("", 20);
  52.     text2 = new JTextField("", 30);
  53.     JTextArea area = new JTextArea(3, 20);
  54.     JScrollPane scrollpane = new JScrollPane(area, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
  55.     JPanel p = new JPanel();
  56.     area.setRows(15);
  57.     area.setColumns(40);
  58.     area.setBackground(Color.BLACK);
  59.     area.setForeground(Color.WHITE);
  60.     JButton button = new JButton("Run");
  61.     button.addActionListener(this);
  62.  
  63.  
  64.     JPanel tabPanel2 = new JPanel();
  65.     tabPanel2.add(new JLabel("Command"));
  66.     tabPanel2.add(text1);
  67.     tabPanel2.add(p.add(button));
  68.     tabPanel2.add(new JLabel("\nConsole"));
  69.     tabPanel2.add(scrollpane);
  70.     button.addActionListener(
  71.             new ActionListener(){
  72.                 public void actionPerformed(ActionEvent e) {
  73.                     int javam;
  74.                     javam = 0;
  75.                     String ins, c1, c2, c3, c4, jc1, jc2;
  76.                     c1 = "run";
  77.                     c2 = "create";
  78.                     c3 = "create window";
  79.                     c4 = "cm Java";
  80.                     jc1 = "Math.random()";
  81.                     jc2 = "exit()";
  82.                     double m;
  83.                     try{
  84.  
  85.                         ins = text1.getText();
  86.  
  87.                         if (javam == 0){
  88.                             if (c1.equals(ins)){
  89.                               area.append("¿Cp>>Cn:" + text1.getText() + "\n");
  90.                             }else if(c2.equals(ins)){
  91.                               area.append("!Cp>>Cn:" + text1.getText() + " <window|text>\n");
  92.                             }else if(c3.equals(ins)){
  93.                               JFrame frame = new JFrame("Cp window");
  94.                               frame.setBounds(100, 100, 200, 160);
  95.                               frame.setVisible(true);
  96.                               area.append("*Cp>>Cn:Window Create!\n");
  97.                             }else if(c4.equals(ins)){
  98.                                 javam =+ 1;
  99.                                 System.out.println(javam);
  100.                                 area.append("*Yat java:©Java Platform, Standard Edition (Java SE) \n"
  101.                                 + "             exit() to Standard mode.\n");
  102.                             }else{
  103.                                 area.setForeground(Color.RED);
  104.                                 area.append("!nomal error:String that is not expected\n"
  105.                                         + "Error Type : Type String(text1.getText())\n\n");
  106.                                 area.setForeground(Color.WHITE);
  107.                             }
  108.  
  109.                         }else if (javam == 1){
  110.                             if(jc1.equals(ins)){
  111.                                 m = Math.random();
  112.                                 area.append("*Java>>Cn:Resalt{" + m + "}");
  113.                             }else if(jc2.equals(ins)){
  114.                                 System.out.println("Standard Mode");
  115.                                 area.append("*Cp>>Cn:Standard Mode\n");
  116.                                 javam =- 1;
  117.                                 System.out.println(javam);
  118.                             }
  119.  
  120.                         }
  121.  
  122.                     }finally{
  123.  
  124.                     }
  125.  
  126.                 }
  127.  
  128.             }
  129.         );
  130.  
  131.     tabbedpane.addTab("commndline", tabPanel2);
  132.     label = new JLabel();
  133.     getContentPane().add(tabbedpane, BorderLayout.CENTER);
  134.   }
  135.  
  136.  
  137.  
  138. @Override
  139. public void actionPerformed(ActionEvent e) {
  140.     // TODO 自動生成されたメソッド・スタブ
  141.  
  142.     }
  143.  
  144.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement