如何在JPanel上添加打印方法

时间:2013-12-03 14:28:39

标签: java

如何在JPanel对象上添加打印方法?

import javax.swing.*;

public class PlaceOrder extends JFrame{

    private JButton PlaceOrderButton;
    private ProductsDatabase Database;

    public PlaceOrder(){
        super("Please fill in your data:");

        ProductsDatabase Database = new ProductsDatabase();
        Database.FillDatabase();

        PlaceOrderButton = new JButton("Place Order");

        JPanel mainPanel = new JPanel();

        mainPanel.setLocation(8, 3);
        mainPanel.add(new JLabel("Products"));
        //I want to add a print method here//
        mainPanel.add(PlaceOrderButton);

        this.setContentPane(mainPanel);
        this.pack();
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setVisible(true);
    }
}

我想添加一个方法来打印ProductsDatabase中添加的产品。

0 个答案:

没有答案