代码拉取完成,页面将自动刷新
同步操作将从 wts286010056/JAVABASE 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
package cn.edu.shengda;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class CoffeeFrame extends JFrame implements ActionListener {
CoffeeFrame(){
init();
this.setTitle("咖啡");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setBounds(0,0,800,600);
this.setVisible(true);
}
public void init(){
radioButtonCoffe=new JRadioButton("咖啡");
radioButtonMilkTea=new JRadioButton("奶茶");
checkBoxMocha=new JCheckBox("摩卡 10");
checkBoxPearl=new JCheckBox("珍珠 15");
checkBoxWhip=new JCheckBox("奶泡 10");
checkBoxChocolate=new JCheckBox("巧克力 20");
labelPrice=new JLabel("价格:");
radioButtonCoffe.addActionListener(this);
radioButtonMilkTea.addActionListener(this);
checkBoxMocha.addActionListener(this);
checkBoxPearl.addActionListener(this);
checkBoxWhip.addActionListener(this);
checkBoxChocolate.addActionListener(this);
add(radioButtonCoffe);
add(radioButtonMilkTea);
add(checkBoxMocha);
add(checkBoxPearl);
add(checkBoxWhip);
add(checkBoxChocolate);
add(labelPrice);
group=new ButtonGroup();
group.add(radioButtonCoffe);
group.add(radioButtonMilkTea);
}
JRadioButton radioButtonCoffe;
JRadioButton radioButtonMilkTea;
JCheckBox checkBoxMocha;
JCheckBox checkBoxPearl;
JCheckBox checkBoxWhip;
JCheckBox checkBoxChocolate;
JLabel labelPrice;
ButtonGroup group;
Beverage beverage;
@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource().equals(radioButtonCoffe)){
System.out.println("咖啡被选中");
beverage=new DarkRoast();
System.out.println(beverage.getDescription()+"$"+
beverage.cost());
}
if(e.getSource().equals(radioButtonMilkTea)){
System.out.println("奶茶被选中");
beverage=new Espresso();
System.out.println(beverage.getDescription()+"$"+
beverage.cost());
}
if(e.getSource().equals(checkBoxMocha)){
System.out.println("摩卡被选中");
beverage=new Mocha(beverage);
System.out.println(beverage.getDescription()+"$"+
beverage.cost());
}
if(e.getSource().equals(checkBoxPearl)){
System.out.println("珍珠被选中");
}
if(e.getSource().equals(checkBoxWhip)){
System.out.println("奶泡被选中");
beverage=new Whip(beverage);
System.out.println(beverage.getDescription()+"$"+
beverage.cost());
}
if(e.getSource().equals(checkBoxChocolate)){
System.out.println("巧克力被选中");
}
}
public static void main(String[] args){
CoffeeFrame coffeeFrame =new CoffeeFrame();
coffeeFrame.setLayout(new FlowLayout());
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。