Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package window_st;
- import java.awt.BorderLayout;
- import java.awt.Color;
- import java.awt.Container;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import javax.swing.JButton;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JPanel;
- import javax.swing.JScrollPane;
- import javax.swing.JTabbedPane;
- import javax.swing.JTextArea;
- import javax.swing.JTextField;
- import javax.swing.UIManager;
- public class GuiDisplay extends JFrame implements ActionListener{
- Container cp;
- JTextField text1;
- JTextField text2;
- JLabel label;
- public static void main(String[] args){
- GuiDisplay frame = new GuiDisplay();
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.setBounds(500, 500, 500, 500);
- frame.setTitle("swing.JFrame.test");
- frame.setVisible(true);
- frame.setBackground(Color.BLACK);
- UIManager.LookAndFeelInfo infos[] = UIManager.getInstalledLookAndFeels();
- System.out.println("getClassName:");
- for(int i = 0 ; i < infos.length ; i++){
- System.out.println(infos[i].getClassName());
- }
- System.out.println("getName:");
- for(int i = 0 ; i < infos.length ; i++){
- System.out.println(infos[i].getName());
- }
- }
- GuiDisplay(){
- JTabbedPane tabbedpane = new JTabbedPane();
- text1 = new JTextField("", 20);
- text2 = new JTextField("", 30);
- JTextArea area = new JTextArea(3, 20);
- JScrollPane scrollpane = new JScrollPane(area, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
- JPanel p = new JPanel();
- area.setRows(15);
- area.setColumns(40);
- area.setBackground(Color.BLACK);
- area.setForeground(Color.WHITE);
- JButton button = new JButton("Run");
- button.addActionListener(this);
- JPanel tabPanel2 = new JPanel();
- tabPanel2.add(new JLabel("Command"));
- tabPanel2.add(text1);
- tabPanel2.add(p.add(button));
- tabPanel2.add(new JLabel("\nConsole"));
- tabPanel2.add(scrollpane);
- button.addActionListener(
- new ActionListener(){
- public void actionPerformed(ActionEvent e) {
- int javam;
- javam = 0;
- String ins, c1, c2, c3, c4, jc1, jc2;
- c1 = "run";
- c2 = "create";
- c3 = "create window";
- c4 = "cm Java";
- jc1 = "Math.random()";
- jc2 = "exit()";
- double m;
- try{
- ins = text1.getText();
- if (javam == 0){
- if (c1.equals(ins)){
- area.append("¿Cp>>Cn:" + text1.getText() + "\n");
- }else if(c2.equals(ins)){
- area.append("!Cp>>Cn:" + text1.getText() + " <window|text>\n");
- }else if(c3.equals(ins)){
- JFrame frame = new JFrame("Cp window");
- frame.setBounds(100, 100, 200, 160);
- frame.setVisible(true);
- area.append("*Cp>>Cn:Window Create!\n");
- }else if(c4.equals(ins)){
- javam =+ 1;
- System.out.println(javam);
- area.append("*Yat java:©Java Platform, Standard Edition (Java SE) \n"
- + " exit() to Standard mode.\n");
- }else{
- area.setForeground(Color.RED);
- area.append("!nomal error:String that is not expected\n"
- + "Error Type : Type String(text1.getText())\n\n");
- area.setForeground(Color.WHITE);
- }
- }else if (javam == 1){
- if(jc1.equals(ins)){
- m = Math.random();
- area.append("*Java>>Cn:Resalt{" + m + "}");
- }else if(jc2.equals(ins)){
- System.out.println("Standard Mode");
- area.append("*Cp>>Cn:Standard Mode\n");
- javam =- 1;
- System.out.println(javam);
- }
- }
- }finally{
- }
- }
- }
- );
- tabbedpane.addTab("commndline", tabPanel2);
- label = new JLabel();
- getContentPane().add(tabbedpane, BorderLayout.CENTER);
- }
- @Override
- public void actionPerformed(ActionEvent e) {
- // TODO 自動生成されたメソッド・スタブ
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement