用Java编了一个图形用户界面的小程序 可是程序运行之后输入变量之后按计算的键却没有内容显示出来
packagecha7;importjava.awt.*;importjava.awt.event.ActionEvent;importjava.awt.event.Ac...
package cha7;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
@SuppressWarnings("serial")
public class lirun extends JFrame implements ActionListener{
private JTextField sale=new JTextField(10);
private JTextField managecost=new JTextField(10);
private JTextField lal=new JTextField(10);
private JTextField sal=new JTextField(10);
private JTextField irb=new JTextField(10);
private JLabel r=new JLabel("利润计划工作中的反复计算");
private JLabel SALE=new JLabel("SALE:");
private JLabel MANAGECOST=new JLabel("MANAGECOST:");
private JLabel LAL=new JLabel("LAL:");
private JLabel SAL=new JLabel("SAL:");
private JLabel IRB=new JLabel("IRB:");
private JLabel salecost=new JLabel();
private JLabel marginalcost=new JLabel();
private JLabel taxprofits=new JLabel();
private JLabel tax=new JLabel();
private JLabel netprofits=new JLabel();
private JLabel operatingexpense=new JLabel();
private JLabel SALECOST=new JLabel("SALECOST:");
private JLabel MARGINALCOST=new JLabel("MARGINALCOST:");
private JLabel TAXPROFITS=new JLabel("TAXPROFITS:");
private JLabel TAX=new JLabel("TAX:");
private JLabel NETPROFITS=new JLabel("NETPROFITS:");
private JLabel OPERATINGEXPENSE=new JLabel("POERATINGEXPENSE:");
private JButton js=new JButton("计算");
public lirun()
{super("lirun");
JPanel contentPane=(JPanel)getContentPane();
contentPane.setLayout(new BorderLayout());
JPanel p1=new JPanel();
JPanel p2=new JPanel(new GridLayout(0,2));
JPanel p3=new JPanel();
contentPane.setBorder(new EmptyBorder(10,10,10,10));
p1.add(r,BorderLayout.CENTER);
p2.add(SALE);
p2.add(sale);
p2.add(MANAGECOST);
p2.add(managecost);
p2.add(LAL);
p2.add(lal);
p2.add(SAL);
p2.add(sal);
p2.add(IRB);
p2.add(irb);
p2.add(SALECOST);
p2.add(salecost);
p2.add(MARGINALCOST);
p2.add(marginalcost);
p2.add(TAXPROFITS);
p2.add(taxprofits);
p2.add(TAX);
p2.add(tax);
p2.add(NETPROFITS);
p2.add(netprofits);
p2.add(OPERATINGEXPENSE);
p2.add(operatingexpense);
p3.add(js,BorderLayout.NORTH);
js.addActionListener(this);
contentPane.add(p1,BorderLayout.NORTH);
contentPane.add(p2,BorderLayout.CENTER);
contentPane.add(p3,BorderLayout.SOUTH);
pack();
setVisible(true);
validate();
}
public void actionPerformed(ActionEvent event)
{
if(event.getSource()==js)
{ double sale1=Double.parseDouble(sale.getText().trim());
double managecost1=Double.parseDouble(managecost.getText().trim());
double lal1=Double.parseDouble(lal.getText().trim());
double sal1=Double.parseDouble(sal.getText().trim());
double irb1=Double.parseDouble(irb.getText().trim());
cha7.Quad q=new cha7.Quad(sale1,managecost1,lal1,sal1,irb1); 展开
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
@SuppressWarnings("serial")
public class lirun extends JFrame implements ActionListener{
private JTextField sale=new JTextField(10);
private JTextField managecost=new JTextField(10);
private JTextField lal=new JTextField(10);
private JTextField sal=new JTextField(10);
private JTextField irb=new JTextField(10);
private JLabel r=new JLabel("利润计划工作中的反复计算");
private JLabel SALE=new JLabel("SALE:");
private JLabel MANAGECOST=new JLabel("MANAGECOST:");
private JLabel LAL=new JLabel("LAL:");
private JLabel SAL=new JLabel("SAL:");
private JLabel IRB=new JLabel("IRB:");
private JLabel salecost=new JLabel();
private JLabel marginalcost=new JLabel();
private JLabel taxprofits=new JLabel();
private JLabel tax=new JLabel();
private JLabel netprofits=new JLabel();
private JLabel operatingexpense=new JLabel();
private JLabel SALECOST=new JLabel("SALECOST:");
private JLabel MARGINALCOST=new JLabel("MARGINALCOST:");
private JLabel TAXPROFITS=new JLabel("TAXPROFITS:");
private JLabel TAX=new JLabel("TAX:");
private JLabel NETPROFITS=new JLabel("NETPROFITS:");
private JLabel OPERATINGEXPENSE=new JLabel("POERATINGEXPENSE:");
private JButton js=new JButton("计算");
public lirun()
{super("lirun");
JPanel contentPane=(JPanel)getContentPane();
contentPane.setLayout(new BorderLayout());
JPanel p1=new JPanel();
JPanel p2=new JPanel(new GridLayout(0,2));
JPanel p3=new JPanel();
contentPane.setBorder(new EmptyBorder(10,10,10,10));
p1.add(r,BorderLayout.CENTER);
p2.add(SALE);
p2.add(sale);
p2.add(MANAGECOST);
p2.add(managecost);
p2.add(LAL);
p2.add(lal);
p2.add(SAL);
p2.add(sal);
p2.add(IRB);
p2.add(irb);
p2.add(SALECOST);
p2.add(salecost);
p2.add(MARGINALCOST);
p2.add(marginalcost);
p2.add(TAXPROFITS);
p2.add(taxprofits);
p2.add(TAX);
p2.add(tax);
p2.add(NETPROFITS);
p2.add(netprofits);
p2.add(OPERATINGEXPENSE);
p2.add(operatingexpense);
p3.add(js,BorderLayout.NORTH);
js.addActionListener(this);
contentPane.add(p1,BorderLayout.NORTH);
contentPane.add(p2,BorderLayout.CENTER);
contentPane.add(p3,BorderLayout.SOUTH);
pack();
setVisible(true);
validate();
}
public void actionPerformed(ActionEvent event)
{
if(event.getSource()==js)
{ double sale1=Double.parseDouble(sale.getText().trim());
double managecost1=Double.parseDouble(managecost.getText().trim());
double lal1=Double.parseDouble(lal.getText().trim());
double sal1=Double.parseDouble(sal.getText().trim());
double irb1=Double.parseDouble(irb.getText().trim());
cha7.Quad q=new cha7.Quad(sale1,managecost1,lal1,sal1,irb1); 展开
2个回答
展开全部
package cha7;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
@SuppressWarnings("serial")
public class lirun extends JFrame implements ActionListener{
private JTextField sale=new JTextField(10);
private JTextField managecost=new JTextField(10);
private JTextField lal=new JTextField(10);
private JTextField sal=new JTextField(10);
private JTextField irb=new JTextField(10);
private JLabel r=new JLabel("利润计划工作中的反复计算");
private JLabel SALE=new JLabel("SALE:");
private JLabel MANAGECOST=new JLabel("MANAGECOST:");
private JLabel LAL=new JLabel("LAL:");
private JLabel SAL=new JLabel("SAL:");
private JLabel IRB=new JLabel("IRB:");
private JLabel salecost=new JLabel();
private JLabel marginalcost=new JLabel();
private JLabel taxprofits=new JLabel();
private JLabel tax=new JLabel();
private JLabel netprofits=new JLabel();
private JLabel operatingexpense=new JLabel();
private JLabel SALECOST=new JLabel("SALECOST:");
private JLabel MARGINALCOST=new JLabel("MARGINALCOST:");
private JLabel TAXPROFITS=new JLabel("TAXPROFITS:");
private JLabel TAX=new JLabel("TAX:");
private JLabel NETPROFITS=new JLabel("NETPROFITS:");
private JLabel OPERATINGEXPENSE=new JLabel("POERATINGEXPENSE:");
private JButton js=new JButton("计算");
public lirun()
{super("lirun");
JPanel contentPane=(JPanel)getContentPane();
contentPane.setLayout(new BorderLayout());
JPanel p1=new JPanel();
JPanel p2=new JPanel(new GridLayout(0,2));
JPanel p3=new JPanel();
contentPane.setBorder(new EmptyBorder(10,10,10,10));
p1.add(r,BorderLayout.CENTER);
p2.add(SALE);
p2.add(sale);
p2.add(MANAGECOST);
p2.add(managecost);
p2.add(LAL);
p2.add(lal);
p2.add(SAL);
p2.add(sal);
p2.add(IRB);
p2.add(irb);
p2.add(SALECOST);
p2.add(salecost);
p2.add(MARGINALCOST);
p2.add(marginalcost);
p2.add(TAXPROFITS);
p2.add(taxprofits);
p2.add(TAX);
p2.add(tax);
p2.add(NETPROFITS);
p2.add(netprofits);
p2.add(OPERATINGEXPENSE);
p2.add(operatingexpense);
p3.add(js,BorderLayout.NORTH);
js.addActionListener(this);
contentPane.add(p1,BorderLayout.NORTH);
contentPane.add(p2,BorderLayout.CENTER);
contentPane.add(p3,BorderLayout.SOUTH);
pack();
setVisible(true);
validate();
}
public void actionPerformed(ActionEvent event)
{
if(event.getSource()==js)
{ double sale1=Double.parseDouble(sale.getText().trim());
double managecost1=Double.parseDouble(managecost.getText().trim());
double lal1=Double.parseDouble(lal.getText().trim());
double sal1=Double.parseDouble(sal.getText().trim());
double irb1=Double.parseDouble(irb.getText().trim());
cha7.Quad q=new cha7.Quad(sale1,managecost1,lal1,sal1,irb1);
try{
q.salecostmarginalcosttaxprofitstaxnetprofitsoperatingexpense();
salecost.setText(Double.toString (q.getSALECOST()));
marginalcost.setText(Double.toString (q.getMARGINALCOST()));
taxprofits.setText(Double.toString (q.getTAXPROFITS()));
tax.setText(Double.toString (q.getTAX()));
netprofits.setText(Double.toString (q.getTAXPROFITS()));
operatingexpense.setText(Double.toString (q.getOPERATINGEXPENSE()));
}catch(Exception e){
salecost.setText("error");
managecost.setText("");}}}
public static void main(String[] args) {
@SuppressWarnings("unused")
lirun f;
f=new lirun(){@SuppressWarnings("unused")
public void run() {new lirun().setVisible(true);}};}}
这个是完整的程序 ,不过还有错误,请高手指正啊
下面这个是调用函数部分package cha7;
public class Quad {
public Quad(double sale1, double managecost1, double lal1, double sal1,
double irb1) {
// TODO Auto-generated constructor stub
}
public static void main(String args[]){
double sale,managecost,lal,sal,irb;
double salecost,marginalcost,taxprofits,tax,netprofits,
operatingexpense,adexpense,interest,badexpense,salescost ;
sale=20;
managecost=10;
lal=100;
sal=50;
irb=30;
salescost= 0.1*sale;
salecost=0.4*sale;
marginalcost=sale-salecost;
adexpense=0.05*sale;
interest=0.1*lal+0.12*sal;
badexpense=0.01*irb;
operatingexpense=salescost+adexpense+interest+badexpense+managecost;
taxprofits=marginalcost-operatingexpense;
tax=0.48*taxprofits;
netprofits=taxprofits-tax;
System.out.println("salecost="+salecost);
System.out.println("marginalcost="+marginalcost);
System.out.println("taxprofits="+taxprofits);
System.out.println("tax="+tax);
System.out.println("netprofits="+netprofits);
System.out.println("operatingexpense="+operatingexpense);
}
public void salecostmarginalcosttaxprofitstaxnetprofitsoperatingexpense() {
// TODO Auto-generated method stub
}
public double getSALECOST() {
// TODO Auto-generated method stub
return 0;
}
public double getMARGINALCOST() {
// TODO Auto-generated method stub
return 0;
}
public double getTAXPROFITS() {
// TODO Auto-generated method stub
return 0;
}
public double getTAX() {
// TODO Auto-generated method stub
return 0;
}
public double getOPERATINGEXPENSE() {
// TODO Auto-generated method stub
return 0;
}
}
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
@SuppressWarnings("serial")
public class lirun extends JFrame implements ActionListener{
private JTextField sale=new JTextField(10);
private JTextField managecost=new JTextField(10);
private JTextField lal=new JTextField(10);
private JTextField sal=new JTextField(10);
private JTextField irb=new JTextField(10);
private JLabel r=new JLabel("利润计划工作中的反复计算");
private JLabel SALE=new JLabel("SALE:");
private JLabel MANAGECOST=new JLabel("MANAGECOST:");
private JLabel LAL=new JLabel("LAL:");
private JLabel SAL=new JLabel("SAL:");
private JLabel IRB=new JLabel("IRB:");
private JLabel salecost=new JLabel();
private JLabel marginalcost=new JLabel();
private JLabel taxprofits=new JLabel();
private JLabel tax=new JLabel();
private JLabel netprofits=new JLabel();
private JLabel operatingexpense=new JLabel();
private JLabel SALECOST=new JLabel("SALECOST:");
private JLabel MARGINALCOST=new JLabel("MARGINALCOST:");
private JLabel TAXPROFITS=new JLabel("TAXPROFITS:");
private JLabel TAX=new JLabel("TAX:");
private JLabel NETPROFITS=new JLabel("NETPROFITS:");
private JLabel OPERATINGEXPENSE=new JLabel("POERATINGEXPENSE:");
private JButton js=new JButton("计算");
public lirun()
{super("lirun");
JPanel contentPane=(JPanel)getContentPane();
contentPane.setLayout(new BorderLayout());
JPanel p1=new JPanel();
JPanel p2=new JPanel(new GridLayout(0,2));
JPanel p3=new JPanel();
contentPane.setBorder(new EmptyBorder(10,10,10,10));
p1.add(r,BorderLayout.CENTER);
p2.add(SALE);
p2.add(sale);
p2.add(MANAGECOST);
p2.add(managecost);
p2.add(LAL);
p2.add(lal);
p2.add(SAL);
p2.add(sal);
p2.add(IRB);
p2.add(irb);
p2.add(SALECOST);
p2.add(salecost);
p2.add(MARGINALCOST);
p2.add(marginalcost);
p2.add(TAXPROFITS);
p2.add(taxprofits);
p2.add(TAX);
p2.add(tax);
p2.add(NETPROFITS);
p2.add(netprofits);
p2.add(OPERATINGEXPENSE);
p2.add(operatingexpense);
p3.add(js,BorderLayout.NORTH);
js.addActionListener(this);
contentPane.add(p1,BorderLayout.NORTH);
contentPane.add(p2,BorderLayout.CENTER);
contentPane.add(p3,BorderLayout.SOUTH);
pack();
setVisible(true);
validate();
}
public void actionPerformed(ActionEvent event)
{
if(event.getSource()==js)
{ double sale1=Double.parseDouble(sale.getText().trim());
double managecost1=Double.parseDouble(managecost.getText().trim());
double lal1=Double.parseDouble(lal.getText().trim());
double sal1=Double.parseDouble(sal.getText().trim());
double irb1=Double.parseDouble(irb.getText().trim());
cha7.Quad q=new cha7.Quad(sale1,managecost1,lal1,sal1,irb1);
try{
q.salecostmarginalcosttaxprofitstaxnetprofitsoperatingexpense();
salecost.setText(Double.toString (q.getSALECOST()));
marginalcost.setText(Double.toString (q.getMARGINALCOST()));
taxprofits.setText(Double.toString (q.getTAXPROFITS()));
tax.setText(Double.toString (q.getTAX()));
netprofits.setText(Double.toString (q.getTAXPROFITS()));
operatingexpense.setText(Double.toString (q.getOPERATINGEXPENSE()));
}catch(Exception e){
salecost.setText("error");
managecost.setText("");}}}
public static void main(String[] args) {
@SuppressWarnings("unused")
lirun f;
f=new lirun(){@SuppressWarnings("unused")
public void run() {new lirun().setVisible(true);}};}}
这个是完整的程序 ,不过还有错误,请高手指正啊
下面这个是调用函数部分package cha7;
public class Quad {
public Quad(double sale1, double managecost1, double lal1, double sal1,
double irb1) {
// TODO Auto-generated constructor stub
}
public static void main(String args[]){
double sale,managecost,lal,sal,irb;
double salecost,marginalcost,taxprofits,tax,netprofits,
operatingexpense,adexpense,interest,badexpense,salescost ;
sale=20;
managecost=10;
lal=100;
sal=50;
irb=30;
salescost= 0.1*sale;
salecost=0.4*sale;
marginalcost=sale-salecost;
adexpense=0.05*sale;
interest=0.1*lal+0.12*sal;
badexpense=0.01*irb;
operatingexpense=salescost+adexpense+interest+badexpense+managecost;
taxprofits=marginalcost-operatingexpense;
tax=0.48*taxprofits;
netprofits=taxprofits-tax;
System.out.println("salecost="+salecost);
System.out.println("marginalcost="+marginalcost);
System.out.println("taxprofits="+taxprofits);
System.out.println("tax="+tax);
System.out.println("netprofits="+netprofits);
System.out.println("operatingexpense="+operatingexpense);
}
public void salecostmarginalcosttaxprofitstaxnetprofitsoperatingexpense() {
// TODO Auto-generated method stub
}
public double getSALECOST() {
// TODO Auto-generated method stub
return 0;
}
public double getMARGINALCOST() {
// TODO Auto-generated method stub
return 0;
}
public double getTAXPROFITS() {
// TODO Auto-generated method stub
return 0;
}
public double getTAX() {
// TODO Auto-generated method stub
return 0;
}
public double getOPERATINGEXPENSE() {
// TODO Auto-generated method stub
return 0;
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |