Java Currency Converter GUI [英] Java Currency Converter GUI
问题描述
我正在尝试制作一个简单的Java货币转换器GUI。到目前为止,我有这个:(4个部分)
我如何设置jcombbox中每个项目的值(例如每种货币),以便可以使用它们来计算转换? / p>
这是第一部分(1个组合框):
import java。 awt。*;
import java.awt.event。*;
import javax.swing。*;
公共类测试扩展了JPanel
{
私人JPanel面板;
私人JLabel messageLabel;
私人JTextField USDTextField;
个私人JPanel CurrencyPanel;
私人JComboBox CurrencyBox;
private String []货币= {美元-美元,
英镑-英镑,澳元-澳大利亚元,
欧元}};
public currency1()
{
setLayout(new BorderLayout(4,1));
buildCurrencyPanel();
add(CurrencyPanel,BorderLayout.CENTER);
setVisible(true);
setBorder(BorderFactory.createTitledBorder( Select currency));
}
private void buildCurrencyPanel()
{
CurrencyPanel = new JPanel();
CurrencyBox = new JComboBox(Currency);
CurrencyPanel.add(CurrencyBox);
}
public static void main(String [] args)
{
new currency1();
}
}
仅注释,我对Currency Converter的看法
-
货币对的定义,默认情况下存在基础货币和可变货币
-
范围汇率的定义
-
定义为购买/出售
-
基本/变量的定义
-
(将所有上午的点放在一起),然后有四个可能的组合
-
购买基数(1,000欧元-在1.31处)
-
销售基数( 1,000欧元-在1.31处)
-
购买变量(1,000.-美元在1.311处)
-
卖出变量(1,000美元-在1.311处)
-
-
GBP / USD具有相反的计算方法
I'm trying to make a simple java currency converter GUI. So far I have this :(4 parts)
How would I set the values for each item in the jcombbox (ex. each currency) so that I can use them to calculate the conversion?
Here's the first part (1 combobox):
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class test extends JPanel
{
private JPanel panel;
private JLabel messageLabel;
private JTextField USDTextField;
private JPanel CurrencyPanel;
private JComboBox CurrencyBox;
private String[] Currency = { "USD - United States Dollar",
"GBP - Great Britain Pound", "AUD - Australian Dollar",
"EUR- Euro"};
public currency1()
{
setLayout(new BorderLayout(4,1));
buildCurrencyPanel();
add(CurrencyPanel, BorderLayout.CENTER);
setVisible(true);
setBorder(BorderFactory.createTitledBorder("Select currency"));
}
private void buildCurrencyPanel()
{
CurrencyPanel = new JPanel();
CurrencyBox = new JComboBox(Currency);
CurrencyPanel.add(CurrencyBox);
}
public static void main(String[] args)
{
new currency1();
}
}
only comment, my view about Currency Converter
definition for Currency Pairs, by default is there Base and Variable Currency
definitions for Exange Rate
definition for Buy/Sale
definition for Base/Variable
(put all a.m. points together) then there are four possible combinations
buy Base (EUR 1,000.- at 1.31)
sell Base (EUR 1,000.- at 1.31)
buy Variable (USD 1,000.- at 1.311)
sell Variable (USD 1,000.- at 1.311)
GBP/USD has reverse calculations methods
这篇关于Java Currency Converter GUI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!