为什么我的java程序代码在cmd中说“unchecked or unsafe operation”?

时间:2015-11-11 11:00:33

标签: java warnings

这个确切地说......我想知道它是否要求太多......它会对我们很多人有所帮助......这是一项需要明天通过的活动,这是一项全有或全无的活动。我们宁愿拥有比零更完美的等级......

问题是,当我们在cmd上运行它时,它只是说

注意:Order.java使用未经检查或不安全的操作。 注意:使用-Xlint重新编译:取消选中以获取详细信息...

import java.awt.GridLayout;
import java.awt.BorderLayout;

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

import javax.swing.DefaultListModel;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JRadioButton;
import javax.swing.JLabel;
import javax.swing.JButton;
import javax.swing.ButtonGroup;
import javax.swing.JCheckBox;
import javax.swing.JPanel;

public class Order extends JFrame{

    private JLabel title;
    private JLabel size;
    private JLabel top;
    private JRadioButton b1;
    private JRadioButton b2;
    private JRadioButton b3;
    private JCheckBox c1;
    private JCheckBox c2;
    private JCheckBox c3;
    private JButton process;
    private ButtonGroup group;
    private JPanel p1;
    private JPanel p2;
    private JPanel p3;
    private double total;
    private boolean cb1 = false;
    private boolean cb2 = false;
    private boolean cb3 = false;
    private boolean cheese = false;
    private boolean tomato = false;
    private boolean mushroom = false;
    private String toppings = "Add-on Toppings: ";
    private double length = 0;
    private JList list;
    private boolean cf = false;
    private boolean tf = false;
    private boolean mf = false;
    private String sizeString;
    private String num;
    private String price = "Amount Due: ";
    private DefaultListModel tops;
    private double tprice;
    private String listData[] = new String [3];

public Order(){

    super ("");

    p1 = new JPanel();

    title = new JLabel("WELCOME TO HAUZ DINNERS");
    p1.add(title);

    add(p1, BorderLayout.NORTH);

    p2 = new JPanel();
    p2.setLayout(new GridLayout(4,2));

    size = new JLabel("Burger Size");
    p2.add(size);

    top = new JLabel("Each Add-on Toppings: $1.25");
    p2.add(top);

    b1 = new JRadioButton("Small: $3.50");
    p2.add(b1);

    b1.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
            total = 3.50;
            sizeString = "Burger Size: Small";
        }
    });

    c1 = new JCheckBox("Extra Cheese");
    p2.add(c1);

    c1.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
            if(c1.isSelected()){
                cheese = true;
            }
            else{
                cheese = false;
            }

            if(cheese == true){
                length++;
            }
            else{
                length--;
            }
        }
    });

    b2 = new JRadioButton("Medium: $4.50");
    p2.add(b2);

    b2.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
            total = 4.50;
            sizeString = "Burger Size: Medium";
        }
    });

    c2 = new JCheckBox("Tomato");
    p2.add(c2);

    c2.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
            if(c2.isSelected()){
                tomato = true;
            }
            else{
                tomato = false;
            }

            if(tomato == true){
                length++;
            }

            else{
                length--;
            }
        }
    });

    b3 = new JRadioButton("Large: $6.00");
    p2.add(b3);

    b3.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
            total = 6.00;
            sizeString = "Burger Size: Large";
        }
    });

    c3 = new JCheckBox("Mushrooms");
    p2.add(c3);

    c3.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
            if(c3.isSelected()){
                mushroom = true;
            }
            else{
                mushroom = false;
            }

            if(mushroom == true){
                length++;
            }

            else{
                length--;
            }
        }
    });

    group = new ButtonGroup();
    group.add(b1);
    group.add(b2);
    group.add(b3);

    add(p2, BorderLayout.CENTER);

    p3 = new JPanel();

    process = new JButton("Process Order");
    p3.add(process);

    process.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
            if(cheese == true){
                cf = true;
                if((cf == true)&&(tf != true)&&(mf != true)){
                    toppings = toppings + "Extra Cheese";
                }
                else{
                    toppings = toppings + ", Extra Cheese";
                }
            }
            if(tomato == true){
                tf = true;
                if((cf != true)&&(tf == true)&&(mf != true)){
                    toppings = toppings + "Tomato";
                }
                else{
                    toppings = toppings + ", Tomato";
                }
            }
            if(mushroom == true){
                mf = true;
                if((cf != true)&&(tf != true)&&(mf == true)){
                    toppings = toppings + "Mushrooms";
                }
                else{
                    toppings = toppings + ", Mushrooms";
                }
            }

            tprice = 1.25 * length;

            total = total + tprice;
            num = Double.toString(total);

            price = price + "$" + num;

            listData [0] = sizeString;
            listData [1] = toppings;
            listData [2] = price;

            list = new JList(listData);

            p3.add(list);
        }
    });



    add(p3, BorderLayout.SOUTH);

}

public static void main(String[]args){

    Order frame = new Order();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(350,220);
    frame.setVisible(true);

}

}

0 个答案:

没有答案