java输入语句打不开面板_java程序问题关于面板内容显示不出来

package点餐;importjava.awt.BorderLayout;importjava.awt.Toolkit.*;importjava.awt.event.*;importjavax.swing.*;publicclassorderformextendslogoimplementsActionListener{JPanel...

package 点餐;

import java.awt.BorderLayout;

import java.awt.Toolkit.*;

import java.awt.event.*;

import javax.swing.*;

public class orderform extends logo implements ActionListener

{

JPanel m1,m2;

JScrollPane scroll;

private String[] columnL ={"菜号","菜名","单价","数量","总计"};

private String[][] rowData = {{"1","套餐一","5", "0","0"},

{"2","套餐二","4.5", "0","0"},

{"3","套餐三","7", "0","0"},

{"4","套餐四","9", "0","0"},

{"5","套餐五","10", "0","0"}};

private JTable jTable;

private JButton submit = new JButton("提交");

private JButton cencal = new JButton("取消");

@SuppressWarnings("empty-statement")

public orderform()

{

this.setTitle("理工城院电子点餐系统 V1.0");//题目

m1 = new JPanel();

m2 = new JPanel();

jTable = new JTable(rowData,columnL);

submit.addActionListener(this);

cencal.addActionListener(this);

//jTable.enable(false);

scroll = new JScrollPane();

scroll.add(jTable);

//scroll.setVisible(true);

// m1.setVisible(true);

// m1.setSize(900,400);

m2.add(submit);

m2.add(cencal);

//m2.setSize(900,50);

this.setLayout(new BorderLayout());

add(BorderLayout.NORTH,scroll);

add(BorderLayout.SOUTH,m2);

this.add(m1);

this.setLocation(250, 140); //设置窗口的起始位置

this.setSize(900, 450);

this.setVisible(true);

}

public void actionPerformed(ActionEvent e)

{

if( e.getSource() == submit)

{

Double sumtemp = 0.0;

for( int i = 0; i < 5; i++)

{

rowData[i][3] = jTable.getValueAt(i, 3).toString();

Double temp1 = Double.parseDouble(rowData[i][3]);

Double temp2 = Double.parseDouble(rowData[i][2]);

temp1 = temp1*temp2;

sumtemp += temp1;

rowData[i][4] = temp1.toString();/**/

//rowData[i][4]= jTable.getValueAt(i, 3).toString();

}

jTable.updateUI();

JOptionPane.showMessageDialog(this,

sumtemp.toString()+"元", "总计",

JOptionPane.INFORMATION_MESSAGE);

}

else if( e.getSource() == cencal )

{

new menu_next();

setVisible(false);

}

}

public static void main(String[] args)

{

orderform a = new orderform();

a.setVisible(true);

}

}

展开

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值