java中如何输出文字到textField中
importjavax.swing.text.JTextComponent;importjava.io.*;importjavax.swing.*;importjavax...
import javax.swing.text.JTextComponent; import java.io.*; import javax.swing.*; import javax.swing.event.*; import java.awt.*; import java.awt.event.*; import java.awt.BorderLayout; public class Division extends JFrame implements ActionListener{ JPanel panel1 = new JPanel(); JPanel panel2 = new JPanel(); JPanel panel3 = new JPanel(); JLabel pin = new JLabel("Please Input the Numbers:"); JLabel ds = new JLabel("/"); JLabel rs = new JLabel("="); JTextField txt1 = new JTextField("divisor",10); JTextField txt2 = new JTextField("dividend",10); JTextField txt3 = new JTextField("result",10); JButton btn1 = new JButton("Ok"); JButton btn2 = new JButton("Cancel"); BorderLayout layout = new BorderLayout(); public Division(){ try{ jbInit(); pack(); }catch(Exception e){ e.printStackTrace(); } } public void jbInit() throws Exception{ btn1.setActionCommand("ok"); btn1.addActionListener(this); btn2.setActionCommand("cancel"); btn2.addActionListener(this); t...
展开
1个回答
2013-12-06
展开全部
把你的result改成result+""
因为setText(" ");里面是需要接收一个String 类型的参数
因为setText(" ");里面是需要接收一个String 类型的参数
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询