发布网友 发布时间:2022-04-29 18:08
共1个回答
热心网友 时间:2023-10-28 20:03
摘要在JAVA中如何获取文本框中输入的值,并保存在一个文件之中。具体代码如下:import java.io.*;import javax.swing.*;import java.awt.FlowLayout;import java.awt.event.*;public class WriterTo extends JFrame implements ActionListener{JButton b;JTextField t;public WriterTo(){super("文本框内容写入文件");JLabel l=new JLabel("请输入内容:");t=new JTextField(20);b=new JButton("写入");b.addActionListener(this);this.add(l);this.add(t);this.add(b);this.setLayout(new FlowLayout());this.pack();this.setVisible(true);}public void actionPerformed(ActionEvent e) {if(e.getSource()==b){if(t.getText().equals("")){JOptionPane.showMessageDialog(null,"请输入内容~","错误",JOptionPane.ERROR_MESSAGE);t.grabFocus();}else{write(t.getText());JOptionPane.showMessageDialog(null,"写入成功","提示",JOptionPane.INFORMATION_MESSAGE);}}}public void write(String line){try{File f=new File咨询记录 · 回答于2021-12-09JAVA+面向对象要获得一个文本框中的文字,可调用其什么方法您好,这边已经看到你的问题,正在为你整理答案,请稍等。在JAVA中如何获取文本框中输入的值,并保存在一个文件之中。具体代码如下:import java.io.*;import javax.swing.*;import java.awt.FlowLayout;import java.awt.event.*;public class WriterTo extends JFrame implements ActionListener{JButton b;JTextField t;public WriterTo(){super("文本框内容写入文件");JLabel l=new JLabel("请输入内容:");t=new JTextField(20);b=new JButton("写入");b.addActionListener(this);this.add(l);this.add(t);this.add(b);this.setLayout(new FlowLayout());this.pack();this.setVisible(true);}public void actionPerformed(ActionEvent e) {if(e.getSource()==b){if(t.getText().equals("")){JOptionPane.showMessageDialog(null,"请输入内容~","错误",JOptionPane.ERROR_MESSAGE);t.grabFocus();}else{write(t.getText());JOptionPane.showMessageDialog(null,"写入成功","提示",JOptionPane.INFORMATION_MESSAGE);}}}public void write(String line){try{File f=new File热心网友 时间:2023-10-28 20:03
摘要在JAVA中如何获取文本框中输入的值,并保存在一个文件之中。具体代码如下:import java.io.*;import javax.swing.*;import java.awt.FlowLayout;import java.awt.event.*;public class WriterTo extends JFrame implements ActionListener{JButton b;JTextField t;public WriterTo(){super("文本框内容写入文件");JLabel l=new JLabel("请输入内容:");t=new JTextField(20);b=new JButton("写入");b.addActionListener(this);this.add(l);this.add(t);this.add(b);this.setLayout(new FlowLayout());this.pack();this.setVisible(true);}public void actionPerformed(ActionEvent e) {if(e.getSource()==b){if(t.getText().equals("")){JOptionPane.showMessageDialog(null,"请输入内容~","错误",JOptionPane.ERROR_MESSAGE);t.grabFocus();}else{write(t.getText());JOptionPane.showMessageDialog(null,"写入成功","提示",JOptionPane.INFORMATION_MESSAGE);}}}public void write(String line){try{File f=new File咨询记录 · 回答于2021-12-09JAVA+面向对象要获得一个文本框中的文字,可调用其什么方法您好,这边已经看到你的问题,正在为你整理答案,请稍等。在JAVA中如何获取文本框中输入的值,并保存在一个文件之中。具体代码如下:import java.io.*;import javax.swing.*;import java.awt.FlowLayout;import java.awt.event.*;public class WriterTo extends JFrame implements ActionListener{JButton b;JTextField t;public WriterTo(){super("文本框内容写入文件");JLabel l=new JLabel("请输入内容:");t=new JTextField(20);b=new JButton("写入");b.addActionListener(this);this.add(l);this.add(t);this.add(b);this.setLayout(new FlowLayout());this.pack();this.setVisible(true);}public void actionPerformed(ActionEvent e) {if(e.getSource()==b){if(t.getText().equals("")){JOptionPane.showMessageDialog(null,"请输入内容~","错误",JOptionPane.ERROR_MESSAGE);t.grabFocus();}else{write(t.getText());JOptionPane.showMessageDialog(null,"写入成功","提示",JOptionPane.INFORMATION_MESSAGE);}}}public void write(String line){try{File f=new File热心网友 时间:2023-10-28 20:03
摘要在JAVA中如何获取文本框中输入的值,并保存在一个文件之中。具体代码如下:import java.io.*;import javax.swing.*;import java.awt.FlowLayout;import java.awt.event.*;public class WriterTo extends JFrame implements ActionListener{JButton b;JTextField t;public WriterTo(){super("文本框内容写入文件");JLabel l=new JLabel("请输入内容:");t=new JTextField(20);b=new JButton("写入");b.addActionListener(this);this.add(l);this.add(t);this.add(b);this.setLayout(new FlowLayout());this.pack();this.setVisible(true);}public void actionPerformed(ActionEvent e) {if(e.getSource()==b){if(t.getText().equals("")){JOptionPane.showMessageDialog(null,"请输入内容~","错误",JOptionPane.ERROR_MESSAGE);t.grabFocus();}else{write(t.getText());JOptionPane.showMessageDialog(null,"写入成功","提示",JOptionPane.INFORMATION_MESSAGE);}}}public void write(String line){try{File f=new File咨询记录 · 回答于2021-12-09JAVA+面向对象要获得一个文本框中的文字,可调用其什么方法您好,这边已经看到你的问题,正在为你整理答案,请稍等。在JAVA中如何获取文本框中输入的值,并保存在一个文件之中。具体代码如下:import java.io.*;import javax.swing.*;import java.awt.FlowLayout;import java.awt.event.*;public class WriterTo extends JFrame implements ActionListener{JButton b;JTextField t;public WriterTo(){super("文本框内容写入文件");JLabel l=new JLabel("请输入内容:");t=new JTextField(20);b=new JButton("写入");b.addActionListener(this);this.add(l);this.add(t);this.add(b);this.setLayout(new FlowLayout());this.pack();this.setVisible(true);}public void actionPerformed(ActionEvent e) {if(e.getSource()==b){if(t.getText().equals("")){JOptionPane.showMessageDialog(null,"请输入内容~","错误",JOptionPane.ERROR_MESSAGE);t.grabFocus();}else{write(t.getText());JOptionPane.showMessageDialog(null,"写入成功","提示",JOptionPane.INFORMATION_MESSAGE);}}}public void write(String line){try{File f=new File