flutter 一个container里面放置两个TextField用什么包裹?
- 如何才能将txtfiled放入1个mc
- java 前一窗口里textfield的数值相加在第二窗口的textfield中显示
- 用Java编译出,两个文本框和一个确定按钮。
- 关于JAVA。要求有一个文本框textfield和一个文本域textarea,并设置监视器。用getText()方法获取文本框t
如何才能将txtfiled放入1个mc
[ol][*]createEmptyMovieClip(\"container1\",1);[*]container1._x = 100;[*]container1._y = 100;[*]container1.createTextField(\"my_txt0\",2,0,0,100,20);//注意[*]container1.my_txt0.text = \"wo kao\";[/ol]
java 前一窗口里textfield的数值相加在第二窗口的textfield中显示
import java.awt.BorderLayout;
import java.awt.Container;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JTextField;
import java.awt.Rectangle;
import javax.swing.JButton;
public class Add extends JFrame {
private static final long serialVersionUID = 1L;
private JPanel panel1 = null;
private JTextField textfield4 = null;
private JTextField textfield8 = null;
private JTextField textfield12 = null;
private JTextField textfield16 = null;
private JButton button1 = null;
private JTextField textfield20 = null;
private Container panel2;
/**
* This is the default constructor
*/
public Add() {
super();
initialize();
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
this.setSize(300, 200);
this.setContentPane(getJContentPane());
this.setTitle("JFrame");
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (panel1 == null) {
panel1 = new JPanel();
panel1.setLayout(null);
panel1.add(getJTextField(), null);
panel1.add(getJTextField1(), null);
panel1.add(getJTextField2(), null);
panel1.add(getJTextField3(), null);
panel1.add(getJButton(), null);
panel1.add(getTextfield20(), null);
}
return panel1;
}
/**
* This method initializes jTextField
*
* @return javax.swing.JTextField
*/
private JTextField getJTextField() {
if (textfield4 == null) {
textfield4 = new JTextField();
textfield4.setBounds(new Rectangle(14, 37, 50, 30));
textfield4.setText("1");
}
return textfield4;
}
/**
* This method initializes jTextField1
*
* @return javax.swing.JTextField
*/
private JTextField getJTextField1() {
if (textfield8 == null) {
textfield8 = new JTextField();
textfield8.setBounds(new Rectangle(84, 37, 50, 30));
textfield8.setText("2");
}
return textfield8;
}
/**
* This method initializes jTextField2
*
* @return javax.swing.JTextField
*/
private JTextField getJTextField2() {
if (textfield12 == null) {
textfield12 = new JTextField();
textfield12.setBounds(new Rectangle(154, 37, 50, 30));
textfield12.setText("3");
}
return textfield12;
}
/**
* This method initializes jTextField3
*
* @return javax.swing.JTextField
*/
private JTextField getJTextField3() {
if (textfield16 == null) {
textfield16 = new JTextField();
textfield16.setBounds(new Rectangle(224, 37, 50, 30));
textfield16.setText("4");
}
return textfield16;
}
/**
* This method initializes jButton
*
* @return javax.swing.JButton
*/
private JButton getJButton() {
if (button1 == null) {
button1 = new JButton();
button1.setBounds(new Rectangle(109, 108, 69, 26));
button1.setText("求和");
button1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
System.out.println("actionPerformed()"); // TODO
// Auto-generated
// Event stub
// actionPerformed()
showPanel2();
}
});
}
return button1;
}
private void showPanel2() {
// TODO 自动生成方法存根
panel2 = new JPanel();
panel2.setSize(300, 200);
panel2.setLayout(null);
int i1 = Integer.parseInt(textfield4.getText());
int i2 = Integer.parseInt(textfield8.getText());
int i3 = Integer.parseInt(textfield12.getText());
int i4 = Integer.parseInt(textfield16.getText());
int i5 = Integer.parseInt(textfield20.getText());
int sum = i1 + i2 + i3 + i4 + i5;
JTextField textfield = new JTextField();
textfield.setBounds(new Rectangle(84, 37, 50, 30));
textfield.setText("" + sum);
panel2.add(textfield);
JButton button2 = new JButton("返回");
button2.setBounds(109, 108, 69, 26);
button2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
System.out.println("actionPerformed()"); // TODO
// Auto-generated
// Event stub
// actionPerformed()
showPanel1();
}
});
panel2.add(button2);
this.remove(panel1);
this.setContentPane(panel2);
}
private void showPanel1() {
// TODO 自动生成方法存根
this.remove(panel2);
this.setContentPane(panel1);
}
/**
* This method initializes textfield20
*
* @return javax.swing.JTextField
*/
private JTextField getTextfield20() {
if (textfield20 == null) {
textfield20 = new JTextField();
textfield20.setBounds(new Rectangle(14, 70, 50, 30));
textfield20.setText("5");
}
return textfield20;
}
public static void main(String[] args) {
new Add();
}
}
用Java编译出,两个文本框和一个确定按钮。
楼上的说的正是,很多错误,改了一下,可以运行,但不知道是不是你要的效果
import java.awt.*;
import javax.swing.*;
public class Main extends JFrame {
JTextField textField1,textField2;
JButton button;
public Main(){
super("文本框和确定示例");
Container container=getContentPane();
container.setLayout(new FlowLayout());
textField1=new JTextField("文本框" ,10);
textField2=new JTextField("文本框" ,10);
button=new JButton("确定");
container.add(textField2);
container.add(textField1);
container.add(button);
setSize(200,100) ;
setVisible(true);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
Main thisClass = new Main();
thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
thisClass.setVisible(true);
}
});
}
}
关于JAVA。要求有一个文本框textfield和一个文本域textarea,并设置监视器。用getText()方法获取文本框t
这个是很简单的事件触发机制的例子,稍等,我弄给你!!
你需要的是awt的做的?还是用swing做的?
下面是awt的
import java.awt.*;
import java.awt.event.*;
public class Demo implements ActionListener
{
TextField txtf;
TextArea txta;
public Demo()
{
Frame f = new Frame("实例");
f.setSize(500,300);
txtf = new TextField(10);
txta = new TextArea(10,8);
f.add(txtf,BorderLayout.NORTH);
f.add(txta,BorderLayout.CENTER);
txtf.addActionListener(this);
f.setVisible(true);
}
public static void main(String args[])
{
new Demo();
}
public void actionPerformed(ActionEvent e)
{
txta.append(txtf.getText());
}
}