def data_item(check_code):
    if(check_code == 'A'):
        return  "滷肉飯"

    elif(check_code == 'B'):
        return "火鍋"
    elif(check_code == 'C'):
        return  "薯條"

input_value = input("請選擇套餐(A,B,C):")
print("今天我想來點>>>%s" %(data_item(input_value)))
print("隨便來點答案吧")


print(data_item('A'))

前面def 定義data_item裡面的程式

後面縮排 代表執行主程式

文章標籤

羽 發表在 痞客邦 留言(0) 人氣()


package Projectaccount;

import javax.swing.*;
import java.awt.*;
import static java.awt.SystemColor.scrollbar;
import java.awt.event.*;
import java.awt.TextArea;
import java.awt.event.TextEvent;
import java.util.Scanner;

     public class Try0913 extends JFrame{
    JFrame frame;     
    JPanel panel,inpanel,paypanel;
    JLabel inputFieldLabel, outputFieldLabel; 
    JTextField inputField,inputField2,inputField3, outputField,
//    b
               bField,b2Field,b3Field,b4Field
//c    
              ,cField;       
    JButton inputButton;
    
     public Try0913() {
        super("視窗事件範例");//為什麼子類別可以繼承這個範例?這範例從哪來的?
        initApp();
    }
     
     public void initApp() {
        frame = new JFrame();
        panel = new JPanel();
        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
        inpanel = new JPanel();
        paypanel = new JPanel();
        inputFieldLabel = new JLabel("aaaa");

        inputField = new JTextField("aaa1");
        inputField.addActionListener(new inputButtonActionListener());
        
        inputField2 = new JTextField("aaa2");
        inputField2.addActionListener(new inputButtonActionListener());
        
        inputField3 = new JTextField("aaa3");
        inputField3.addActionListener(new inputButtonActionListener());
        
        outputField = new JTextField("aaab");
        inputButton = new JButton("aaaac");
        inputButton.addActionListener(new inputButtonActionListener());

        outputFieldLabel = new JLabel("bbbbb");
       
        bField = new JTextField("bbb1");
        bField.addActionListener(new inputButtonActionListener());
        
        b2Field = new JTextField("bbb2");
        b2Field.addActionListener(new inputButtonActionListener());
        
        b3Field = new JTextField("bbb3");
        b3Field.addActionListener(new inputButtonActionListener());
        
        b4Field = new JTextField("bbb4");
        b4Field.addActionListener(new inputButtonActionListener());
        
        cField = new JTextField();
        
        
        
        frame.add(panel).setSize(500,500);
        panel.setLayout(new GridLayout(6,6));
        panel.add(inputFieldLabel).setSize(500,100);
        panel.add(inpanel).setSize(500,200);
        panel.add(outputFieldLabel).setSize(500,100);
        panel.add(bField);
        panel.add(b2Field);
        panel.add(b3Field);
        panel.add(b4Field);
        panel.add(cField);
        
        inpanel.add(inputField);
        inpanel.add(inputField2);
        inpanel.add(inputField3);
        inpanel.add(outputField);
        inpanel.add(inputButton);
        
        
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(500,500);
        frame.getContentPane().add(panel);
        frame.setVisible(true);
        
     }
       private class inputFieldActionListener implements ActionListener {
        public void actionPerformed(ActionEvent e) {
            changeOutputText();
        }
    }
       private class inputField2ActionListener implements ActionListener {
        public void actionPerformed(ActionEvent e) {
            changeOutputText();
        }
    }
       
        private class inputField3ActionListener implements ActionListener {
        public void actionPerformed(ActionEvent e) {
            changeOutputText();
        }
    }
        
       private class inputButtonActionListener implements ActionListener {
        public void actionPerformed(ActionEvent e) {
            changeOutputText();
    
        }
       private class bField3ActionListener implements ActionListener {
       public void actionPerformed(ActionEvent e) {
            changeOutputText();
        }
      }
       private class b2Field3ActionListener implements ActionListener {
       public void actionPerformed(ActionEvent e) {
            changeOutputText();
        }
      }
       private class b3Field3ActionListener implements ActionListener {
       public void actionPerformed(ActionEvent e) {
            changeOutputText();
        }
      }
       private class b4Field3ActionListener implements ActionListener {
       public void actionPerformed(ActionEvent e) {
            changeOutputText();
        }
      }
       private class cFieldActionListener implements ActionListener {
       public void actionPerformed(ActionEvent e) {
            changeOutputText();
        }
      }
       
    }
       
         public void changeOutputText() {
        String inputfield_str = inputField.getText();
        String inputfield2_str = inputField2.getText();
        String inputfield3_str = inputField3.getText();
        
        int value = Integer.parseInt(inputfield_str);
        int value2 = Integer.parseInt(inputfield2_str);
        int value3 = Integer.parseInt(inputfield3_str);
        int value4;
        value4= value+value2+value3;
        String answer = String.valueOf(value4);
        outputField.setText(answer);
// bb
        String bfield_str =  bField.getText();
        String bfield2_str = b2Field.getText();
        String bfield3_str = b3Field.getText();
        
        int bvalue = Integer.parseInt(bfield_str);
        int bvalue2 = Integer.parseInt(bfield2_str);
        int bvalue3 = Integer.parseInt(bfield3_str);
        int bvalue4;
        
        bvalue4 = bvalue+bvalue2+bvalue3;
        String banswer = String.valueOf(bvalue4);
        b4Field.setText(banswer);
        
        int cvalue;
        cvalue = value4+bvalue4;
        String canswer = String.valueOf(cvalue);
        cField.setText(canswer);  
         }
     
     
     
    public static void main(String[] args) {
    Try0913 app = new  Try0913();
    }
    
}
 

羽 發表在 痞客邦 留言(0) 人氣()


package 中華隊數據_亂玩的;
import java.awt.FlowLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class NewJPanel_0816 {

    public static void main(String[] args) {
              JFrame n2=new JFrame();//建立一個視窗
          NewJPanel p2=new NewJPanel(n2);//建立一個面板,並將視窗傳入
          n2.add(p2);//視窗中新增面板p2
          n2.setVisible(true);//顯示視窗
    }
    
}

--------------------------------------------------------------------


package 中華隊數據_亂玩的;

//面板2中除了按鈕名稱和麵板1不一樣,其他基本功能相同

import javax.swing.JFrame;

//面板1
public class NewJPanel extends javax.swing.JPanel {

    /**
     * Creates new form NewJPanel
     */
     JFrame n2=new JFrame();//建立一個視窗
    public NewJPanel(JFrame n2) {
        initComponents();
        this.n2=n2;//通過建構函式接收之前傳過來的面板
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        jButton1 = new javax.swing.JButton();//新增按鈕
        jButton1.setText("測試1");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
                NewJPanel2 p1=new NewJPanel2(n2);//新建面板NewJPanel2,並將視窗n2傳入
                setVisible(false);//隱藏當前面板
                n2.add(p1);//在視窗中新增面板p1
                n2.setVisible(true);//顯示面板
            }
        });
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(115, 115, 115)
                .addComponent(jButton1)
                .addContainerGap(188, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(84, 84, 84)
                .addComponent(jButton1)
                .addContainerGap(187, Short.MAX_VALUE))
        );
    }// </editor-fold>                        

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // TODO add your handling code here:
    }                                        
    // Variables declaration - do not modify                     
    private javax.swing.JButton jButton1;
    // End of variables declaration                   
}
------------------------------------------------


package 中華隊數據_亂玩的;

import javax.swing.JFrame;

public class NewJPanel2 extends javax.swing.JPanel {

    /**
     * Creates new form NewJPanel
     */
    JFrame n2=null;
    public NewJPanel2(JFrame n2) {
        initComponents();
        this.n2=n2;
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        jButton1 = new javax.swing.JButton();

        jButton1.setText("測試2");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
                NewJPanel p=new NewJPanel(n2);
                setVisible(false);
                n2.add(p);
                n2.setVisible(true);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(115, 115, 115)
                .addComponent(jButton1)
                .addContainerGap(188, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(84, 84, 84)
                .addComponent(jButton1)
                .addContainerGap(187, Short.MAX_VALUE))
        );
    }// </editor-fold>                        

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // TODO add your handling code here:
    }                                        


    // Variables declaration - do not modify                     
    private javax.swing.JButton jButton1;
    // End of variables declaration                   
}
 

文章標籤

羽 發表在 痞客邦 留言(0) 人氣()

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;

public class frame1 extends JFrame implements ActionListener{

    private JButton jb;
    private JButton jb2;
    public frame1()
    {
        this.setSize(500, 800);
        this.setLocation(600, 400);
        jb=new JButton("跳转");
        jb2 = new JButton("跳啊");
        this.add(jb).setSize(300, 100);
        this.add(jb2).setSize(500, 400);
        jb.addActionListener(this);//加入事件监听
        jb2.addActionListener(this);
        this.setVisible(true);
        
    }
    public static void main(String[] args) {
        // TODO Auto-generated method stub
           frame1 frame=new frame1();
  
    }
    @Override
    public void actionPerformed(ActionEvent e) {
        // TODO Auto-generated method stub
        if(e.getSource()==jb)
        {
            this.dispose();//点击按钮时frame1销毁,new一个frame2
            new frame2();
        }
        
        if(e.getSource()==jb2)
        {
            this.dispose();//点击按钮时frame1销毁,new一个frame2
            new frame3();
        }
    }

}

---------------------------------------------------------------------
package 中華隊數據_亂玩的;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;

public class frame2 extends JFrame implements ActionListener{
private JButton Fr2;
    public frame2()
    {
        Fr2=new JButton("跳转");
        this.setSize(300, 200);
        this.setLocation(300, 400);
        this.setVisible(true);
        this.add(Fr2).setSize(300, 100);
         Fr2.addActionListener((ActionListener) this);
    }
    @Override
    public void actionPerformed(ActionEvent e) {
        // TODO Auto-generated method stub
        if(e.getSource()==Fr2)
        {
            this.dispose();//点击按钮时frame1销毁,new一个frame2
            new frame1();
        }
    }
}

---------------------------------------------------------------

import javax.swing.JButton;
import javax.swing.JFrame;
public class frame3 extends JFrame{
  private JButton j3;
    public frame3()
    {
        
        this.setSize(500, 400);
        this.setLocation(300, 400);
        j3=new JButton("跳转");
        this.setVisible(true);
    }
    public static void main(String[] args) {
     frame3 frame3=new frame3();
    }
    
}

 

 

文章標籤

羽 發表在 痞客邦 留言(0) 人氣()


package myaccount;

import javax.swing.*;
import java.awt.*;
import static java.awt.SystemColor.scrollbar;
import java.awt.event.*;
import java.awt.TextArea;
import java.awt.event.TextEvent;
import java.util.Scanner;

     public class Try08032 extends JFrame{
    JFrame frame;     
    JPanel panel,inpanel,paypanel;
    JLabel inputFieldLabel, outputFieldLabel; 
    JTextField inputField,inputField2,inputField3, outputField,
//    b
               bField,b2Field,b3Field,b4Field
//c    
              ,cField;       
    JButton inputButton;
    
     public Try08032() {
        super("視窗事件範例");//為什麼子類別可以繼承這個範例?這範例從哪來的?
        initApp();
    }
     
     public void initApp() {
        frame = new JFrame();
        panel = new JPanel();
        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
        inpanel = new JPanel();
        paypanel = new JPanel();
        inputFieldLabel = new JLabel("aaaa");

        inputField = new JTextField("aaa1");
        inputField.addActionListener(new inputButtonActionListener());
        
        inputField2 = new JTextField("aaa2");
        inputField2.addActionListener(new inputButtonActionListener());
        
        inputField3 = new JTextField("aaa3");
        inputField3.addActionListener(new inputButtonActionListener());
        
        outputField = new JTextField("aaab");
        inputButton = new JButton("aaaac");
        inputButton.addActionListener(new inputButtonActionListener());

        outputFieldLabel = new JLabel("bbbbb");
       
        bField = new JTextField("bbb1");
        bField.addActionListener(new inputButtonActionListener());
        
        b2Field = new JTextField("bbb2");
        b2Field.addActionListener(new inputButtonActionListener());
        
        b3Field = new JTextField("bbb3");
        b3Field.addActionListener(new inputButtonActionListener());
        
        b4Field = new JTextField("bbb4");
        b4Field.addActionListener(new inputButtonActionListener());
        
        cField = new JTextField();
        
        
        
        frame.add(panel).setSize(500,500);
        panel.setLayout(new GridLayout(6,6));
        panel.add(inputFieldLabel).setSize(500,100);
        panel.add(inpanel).setSize(500,200);
        panel.add(outputFieldLabel).setSize(500,100);
        panel.add(bField);
        panel.add(b2Field);
        panel.add(b3Field);
        panel.add(b4Field);
        panel.add(cField);
        
        inpanel.add(inputField);
        inpanel.add(inputField2);
        inpanel.add(inputField3);
        inpanel.add(outputField);
        inpanel.add(inputButton);
        
        
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(500,500);
        frame.getContentPane().add(panel);
        frame.setVisible(true);
        
     }
       private class inputFieldActionListener implements ActionListener {
        public void actionPerformed(ActionEvent e) {
            changeOutputText();
        }
    }
       private class inputField2ActionListener implements ActionListener {
        public void actionPerformed(ActionEvent e) {
            changeOutputText();
        }
    }
       
        private class inputField3ActionListener implements ActionListener {
        public void actionPerformed(ActionEvent e) {
            changeOutputText();
        }
    }
        
       private class inputButtonActionListener implements ActionListener {
        public void actionPerformed(ActionEvent e) {
            changeOutputText();
    
        }
       private class bField3ActionListener implements ActionListener {
       public void actionPerformed(ActionEvent e) {
            changeOutputText();
        }
      }
       private class b2Field3ActionListener implements ActionListener {
       public void actionPerformed(ActionEvent e) {
            changeOutputText();
        }
      }
       private class b3Field3ActionListener implements ActionListener {
       public void actionPerformed(ActionEvent e) {
            changeOutputText();
        }
      }
       private class b4Field3ActionListener implements ActionListener {
       public void actionPerformed(ActionEvent e) {
            changeOutputText();
        }
      }
       private class cFieldActionListener implements ActionListener {
       public void actionPerformed(ActionEvent e) {
            changeOutputText();
        }
      }
       
    }
       
         public void changeOutputText() {
        String inputfield_str = inputField.getText();
        String inputfield2_str = inputField2.getText();
        String inputfield3_str = inputField3.getText();
        
        int value = Integer.parseInt(inputfield_str);
        int value2 = Integer.parseInt(inputfield2_str);
        int value3 = Integer.parseInt(inputfield3_str);
        int value4;
        value4= value+value2+value3;
        String answer = String.valueOf(value4);
        outputField.setText(answer);
// bb
        String bfield_str =  bField.getText();
        String bfield2_str = b2Field.getText();
        String bfield3_str = b3Field.getText();
        
        int bvalue = Integer.parseInt(bfield_str);
        int bvalue2 = Integer.parseInt(bfield2_str);
        int bvalue3 = Integer.parseInt(bfield3_str);
        int bvalue4;
        
        bvalue4 = bvalue+bvalue2+bvalue3;
        String banswer = String.valueOf(bvalue4);
        b4Field.setText(banswer);
        
        int cvalue;
        cvalue = value4+bvalue4;
        String canswer = String.valueOf(cvalue);
        cField.setText(canswer);  
         }
     
     
     
    public static void main(String[] args) {
    Try08032 app = new  Try08032();
    }
    
}
 

文章標籤

羽 發表在 痞客邦 留言(0) 人氣()

 int value = Integer.parseInt(inputfield_str);
        int value2 = Integer.parseInt(inputfield2_str);
        int value3;
        value3= value+value2;
        String answer = String.valueOf(value3);
        outputField.setText(answer);

 

*: String轉Integer直接用Integer.parseInt(String s)就好了。

文章標籤

羽 發表在 痞客邦 留言(0) 人氣()

資料來源引用自: https://blog.techbridge.cc/2019/09/21/how-to-use-python-tkinter-to-make-gui-app-tutorial/  //這位大大講解的非常前顯易懂

建立視窗步驟

1.引用套件

2.設定視窗標題和字型

3.運行主程式

1.import tkinter as tk

2.window = tk.Tk()

window.title('BMI App') window.geometry('800x600')

window.configure(background='white')

3.window.mainloop()

 

文章標籤

羽 發表在 痞客邦 留言(0) 人氣()

package myaccount;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.TextArea;
import java.awt.event.TextEvent;

//0831知道如何使用傾聽者及自動作加減,還有能自己創造出格子出來
//20200719 建立起一個搜尋框能將收入與支出的結果自動做加減
//20200719 最後用valueOf的方式成功解決算不出總預算的問題
class TryAdmin extends JFrame{
    // 此視窗所用到的元件
    JPanel panel, inPanel, outPanel;
    JLabel inputFieldLabel, outputFieldLabel; 
    JTextField 
//收入  income=收入,change=可動資金,savings=儲蓄
            incomeField,changeField,savingsField
//支出  meals=三餐,meals_day=三餐天數,rent=房租,存錢=savemoney,airtime=通話費,
//     transportation=交通費       
            , mealsField,meals_dayField2,FieldField,savemoney,airtime,transportation
    
//結果
            ,outputField3;
    JButton inputButton,inputButton2;
    

    public TryAdmin() {
        super("678");//為什麼子類別可以繼承這個範例?這範例從哪來的?
        GoGo();
    }

    // 元件相關設置
    public void GoGo() { 
        panel = new JPanel();
        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
////BoxLayout是讓物件保持水平或垂直平行對齊的語法
        inPanel = new JPanel();
        outPanel = new JPanel();

        inputFieldLabel = new JLabel("輸入文字");
        
        incomeField = new JTextField("輸入1");
        incomeField.addActionListener(new inputFieldActionListener()); // 要將事件處理加入

        
        changeField = new JTextField("輸入2");
        changeField.addActionListener(new inputFieldActionListener());

        
        inputButton = new JButton("確定");
        inputButton.addActionListener(new inputButtonActionListener()); // 要將事件處理加入
        inputButton2 = new JButton("確定");
        inputButton2.addActionListener(new inputButtonActionListener()); // 要將事件處理加入
        
        
        outputFieldLabel = new JLabel("輸出文字");
        mealsField = new JTextField("輸出1");
        mealsField.addActionListener(new outputFieldActionListener());
        
        meals_dayField2 = new JTextField("輸出2");
        meals_dayField2.addActionListener(new outputFieldActionListener());
        outputField3 = new JTextField("總輸出");
     
        
        inPanel.add(inputFieldLabel);
        inPanel.add(incomeField);
        inPanel.add(changeField);
        inPanel.add(inputButton);
        inPanel.add(inputButton2);
        
        outPanel.add(outputFieldLabel);
        outPanel.add(mealsField);
        outPanel.add(meals_dayField2);
        outPanel.add(outputField3);
       
        
        
 
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setSize(400, 800);
        this.getContentPane().setLayout(new GridLayout(2,4));
        this.add(inputFieldLabel);
        this.add(incomeField);
        this.add(mealsField);
        this.add(inputButton);
        this.add(changeField);
        this.add(meals_dayField2);
        this.add(outputField3);
        this.add(inputButton2);
        this.setVisible(true);
    }
    // inputField的事件處理
        private class inputFieldActionListener implements ActionListener {
        public void actionPerformed(ActionEvent e) {
            changeOutputText();
        }
    }
        // inputButton的事件處理
    private class inputButtonActionListener implements ActionListener {
        public void actionPerformed(ActionEvent e) {
            changeOutputText();
        }
    }

        private class InputFieldStr2ActionListener implements ActionListener {
            public void actionPerformed(ActionEvent e){
                changeOutputText();
            }
        }
        
            private class inputButton2ActionListener implements ActionListener
            {
            public void actionPerformed(ActionEvent e) 
                {
                changeOutputText();
                }
            }
//         總預算相加   
            private class outputFieldActionListener implements ActionListener
            {
            public void actionPerformed(ActionEvent e) 
                {
                changeOutputText();
                }
            }
            
            private class outputField2ActionListener implements ActionListener
            {
            public void actionPerformed(ActionEvent e) 
                {
                changeOutputText();
                }
            }
            

    public void changeOutputText() {
        String input_field_str = incomeField.getText();
        mealsField.setText(input_field_str);
        
        String InputFieldStr2 = changeField.getText();
        meals_dayField2.setText(InputFieldStr2);
        
        String outputField_str = mealsField.getText();
        int afterfield = Integer.valueOf(outputField_str);
        afterfield = Integer.parseInt(outputField_str);
        
        String outputField2_str = meals_dayField2.getText();
        int afterfield2 = Integer.valueOf(outputField2_str);
        afterfield2 = Integer.parseInt(outputField2_str);

        int afterfield3 = afterfield +afterfield2;
        String answer = String.valueOf(afterfield3);
        outputField3.setText(answer);
    }
    public static void main(String[] args) {
         TryAdmin app = new  TryAdmin();
    }
}


 

文章標籤

羽 發表在 痞客邦 留言(0) 人氣()


package myaccount;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.TextArea;
import java.awt.event.TextEvent;

//0831知道如何使用傾聽者及自動作加減,還有能自己創造出格子出來
class Moudoule1 extends JFrame
{
    // 此視窗所用到的元件
    int fieldWidth = 10;
    JPanel panel, inPanel, outPanel;
    JLabel inputFieldLabel, outputFieldLabel; 
    JTextField inputField, outputField,outputField2;
    JButton inputButton;
    private Object inpanel;

    public Moudoule1() 
    {
        super("視窗事件範例");//為什麼子類別可以繼承這個範例?這範例從哪來的?
        initApp();
    }

    // 元件相關設置
    public void initApp() 
    { 
        panel = new JPanel();
        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
//BoxLayout是讓物件保持水平或垂直平行對齊的語法
        inPanel = new JPanel();
        outPanel = new JPanel();

        inputFieldLabel = new JLabel("1234"); 
        inputField = new JTextField("6688");
        inputField.addActionListener(new inputFieldActionListener()); // 要將事件處理加入
        outputField2 = new JTextField("55555");
       
//        實驗
        
//        實驗
        
        inputButton = new JButton("確定");
        inputButton.addActionListener(new inputButtonActionListener()); // 要將事件處理加入

        outputFieldLabel = new JLabel("輸出文字");
        outputField = new JTextField(fieldWidth);
        
         panel.add(inputFieldLabel);
         panel.add(inputField);
         panel.add(outputFieldLabel);
         panel.add(outputField);
         panel.add(outputField2);
        inPanel.add(inputFieldLabel);
        inPanel.add(inputField);
        inPanel.add(inputButton);
      
        outPanel.add(outputFieldLabel);
        outPanel.add(outputField);

        panel.add(inPanel);
        panel.add(outPanel);
        
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setSize(500, 500);
        this.getContentPane().add(panel);
        this.setVisible(true);
    }

    // inputField的事件處理
    private class inputFieldActionListener implements ActionListener {
        public void actionPerformed(ActionEvent e) {
            changeOutputText();
        }
    }

    // inputButton的事件處理
    private class inputButtonActionListener implements ActionListener {
        public void actionPerformed(ActionEvent e) {
            changeOutputText();
        }
    }

    public void changeOutputText() 
        {
        String input_field_str = inputField.getText()   ;
        String input_out_str   = outputField2.getText();
       
        int afterfield = (int)(Float.parseFloat(input_field_str));
        int afterout   = (int)(Float.parseFloat(input_out_str));
        int afteroutcome = afterfield+afterout;
        outputField.setColumns(afteroutcome);
        }
    public static void main(String[] args) 
    {
         Moudoule1 app = new  Moudoule1();
    }
    }


 

文章標籤

羽 發表在 痞客邦 留言(0) 人氣()

主要用來儲存過去學java的點點滴滴

文章標籤

羽 發表在 痞客邦 留言(0) 人氣()

..協議達成 伊朗貨幣強升逾3%
作者: 黃啟霖 | 中央廣播電台 – 2013年11月24日 下午6:06.
....在伊朗和列強達成突破性的核子協議之後,西方將放寬對伊朗的經濟制裁,伊朗經濟可望開始復甦,利多消息激勵伊朗貨幣走強,伊朗對美元匯率今天(24日)立即跳升超過3%。

在德黑蘭的自由市場,伊朗貨幣里亞爾(rial)對美元匯率成為1美元兌換2萬9千里亞爾。而在協議達成之前,1美元可以兌換大約3萬里亞爾。

伊朗外匯交易商指出,他們可以感覺到伊朗出現正面的信心。

交易商指出,伊朗國內類似水泥與陶瓷等建材的價格已經出現下滑,因為民眾都認為制裁將逐步放寬,讓伊朗更容易從國外取得供應貨品。

多數伊朗人和企業都透過自由市場匯率以換取強勢貨幣。某些與公家有關的公司因為可以獲得優惠匯率,才以中央銀行的匯率換匯。伊朗中央銀行今天的匯率仍然維持在1美元兌換2萬4,822里亞爾的水準。

在經濟制裁之下,伊朗過去2年的通貨膨脹飆漲超過30%,里亞爾兌美元貶值近70%。在去年底的時候,1美元甚至可以兌換到將近4萬里亞爾

羽 發表在 痞客邦 留言(1) 人氣()


中央社 – 2013年11月24日 下午6:20.
....(中央社記者徐梅玉約翰尼斯堡特稿)非洲以野生動物園多著稱於世,其中又以南非的數量居冠,是全球歐美人士休閒渡假勝地。1位旅居南非20多年的台商今年買下1座野生動物園,堪稱南非華人第一人。

這座佔地700多公頃、位於林坡坡省(Limpopo)的銀色小溪渡假村(Silver Streams Lodge),距離約翰尼斯堡約200公里,座落在群山環抱中,清淨無染。一望無垠的大地上,野生動物肆意奔跑著;仰望蔚藍天空,老鷹正一圈又一圈盤旋著。

台籍員工楊先生表示,他的老闆來自台灣高雄,經過20多年打拼,事業有成。工作之餘非常喜好親近大自然,尤其是動物,因而決定向原園主買下這座2009年開發完成的渡假野生動物園。

渡假村第一期工程,包括五星級住宿小屋、交誼廳與大型會議中心已完成,而第二期工程執照也已核發,近期內將開工,未來可同時容納數百人入住。

動物方面,楊先生表示,目前園區內以草食動物為主,包括黑斑羚、水羚羊、伊蘭羚羊、非洲旋角大羚羊、斑馬、長頸鹿、野豬等10幾種。非洲羚羊總計有30多種,園區目前不到10種,考慮未來陸續引進其他種類的羚羊。

年底前,馬場完工後,遊客便有馬可騎;明年初,犀牛區域電網完工後,將開始飼養犀牛,為遭到大量盜獵的南非犀牛,盡一份保育繁殖的力量。

他說: 「明年初,遊客可以坐在涼風習習的草棚下,喝著咖啡,欣賞小溪對岸的犀牛媽媽帶著寶寶漫步的溫馨情景。」

園區資深導遊兼欣賞動物專用敞篷車司機塞茨海迪(Tshepo Setshedi)表示,野生動物已漸漸習慣車子引擎聲,但如果遊客發出驚喜聲或是下車聊天拍照,動物反而因為驚嚇過度立即飛奔離開。

除觀賞動物外,遊客也可於清晨蟲鳴鳥叫聲中溯溪而上,享受雲淡風輕,或於黃昏沿著步道欣賞夕陽餘暉景緻。累了,還有專業SPA,讓人通體舒暢。

園區提供專用婚禮場地,新人可於大自然懷抱中,在眾多野生動物見證下,許下終生誓言,完成人生大事。

管理整個園區的經理龐特海齊(Piet Bonthuyzen)說,上個月因為雷電交加引發森林大火,燒掉許多樹木草原,影響動物食物。經過緊急採購大量糧草,在整個園區到處放置後,終於免去動物斷炊之慮。所幸隨著一波波雨水,草已漸漸長成。

另一位女性管理員范德桑德(Liandra van derSandt)告訴記者一個感人真實故事。她說園區剛開始營業的第2年,有一頭長頸鹿媽媽在草原上不幸被雷電擊斃,才剛出生不久的長頸鹿寶寶因為缺乏媽媽的照顧,不久也身亡。

管理員非常難過,於是將母子的頭做成標本,置於園區開放式酒吧的牆壁上,供工作人員憑弔。1021124

羽 發表在 痞客邦 留言(0) 人氣()


中央社 – 2013年11月24日 下午1:13.
....(中央社記者黃巧雯台北24日電)第3屆兩岸產業合作論壇28日將在中國大陸江蘇省昆山市舉行,經濟部表示,屆時會中將聚焦產業合作試點情況、園區合作可行性、如何減緩雙方產業競爭等3議題。

兩岸產業合作論壇距離前一次101年11月在新竹舉辦,隔了一年有餘,這次28日起連續2天在中國大陸舉行,將由雙方產合論壇召集人經濟部次長杜紫軍與大陸發改委副主任張曉強共同主持這次論壇。

經濟部官員表示,會中將聚焦3議題,首先為檢討過去兩岸產業合作試點成果及未來如何進一步擴大,業別涵蓋冷鏈物流、LED照明、無線城市等。

其次,雙方將針對兩岸園區合作的可行性與推動策略進行研究。

官員指出,屆時將討論可行性,由雙邊研究機構報告可行性研究後,再進行討論。

值得注意的是,雙方還將針對兩岸產業合作的合理分工和布局,進行討論。

官員表示,由於兩岸產業逐漸從過去合作發展成競爭的態勢,因此如何減緩雙方產業競爭,例如避免重複投資等,屆時也將討論。

另外,官員指出,產合論壇是產業合作工作小組先期智庫的討論,若雙方討論有共識,共識將提至產合小組用行政的方式呈現。

換言之,產合論壇主要是雙方智庫對智庫的討論,由政府支持,雙方由副部長級做共同召集人,這次論壇討論的內容也將在下次產合工作小組討論。

官員以兩岸園區合作為例,去年陸方提出這項議題後,我方認為先由智庫研究可行性,雙方經過一年各自智庫研究後,這次提到產合論壇討論,討論有共識才會提至產合小組。

除了兩岸產業合作論壇外,雙方將論壇前一天(27日)也將舉行產業合作工作分組會議,探討目前產業合作執行進度。1021124

羽 發表在 痞客邦 留言(0) 人氣()

http://www.cheers.com.tw/article/article.action?id=5047579&page=1

羽 發表在 痞客邦 留言(0) 人氣()

..

聯發科結盟遊戲發行商 衝8核
.-字
+字
.中央社 – 2013年11月18日 下午5:34..


.




.
.

(中央社記者張建中新竹18日電)手機晶片廠聯發科宣布,與遊戲發行商Gameloft合作;將在所有搭配聯發科8核心晶片的智慧手機上提供全新遊戲「現代戰爭 5」。

聯發科即將於20日在中國大陸深圳正式發表智慧手機真8核解決方案MT6592,今天搶先宣布,與Gameloft合作,暖身意味濃厚。

聯發科表示,「現代戰爭 5」是一款情節緊湊、具有強烈視覺衝擊的戰爭遊戲;玩家可在遊戲中體驗不同的地形和環境。

聯發科指出,MT6592支持高清晰度的連續滾動,可完美呈現精細的柔化粒子特效,到增強景深等各方面細節,創造更逼真的遊戲體驗。

聯發科技無線通訊事業部總經理朱尚祖說,隨著行動網路應用與服務的快速發展,手機遊戲已成為領先增值服務之一,也是體驗真8核MT6592晶片性能的最佳介面。

聯發科表示,「現代戰爭 5」將在所有配備MT6592晶片的智慧型手機上提供,明年初開始在Google Play商店中供玩家下載;雙方的合作是一重大突破,讓消費者能夠隨時隨地享受遊戲體驗。1021118

羽 發表在 痞客邦 留言(0) 人氣()

«12 3