能在像Frame这样的容器中实现:
要求输入以下数据:
K,0.00,#0,516.35,#1,8.28,516.31,37.09,516.41,37.65,516.23,41.39,516.20
K,0.00,#0,516.35,#2,25.28,516.40,33.53,516.67,34.12,516.25,41.37,516.26
K,20.00,#0,516.31,#1,15.39,516.35,41.37,516.42
K,20.00,#0,516.31,#2,18.90,516.35,19.00,516.10,22.35,516.11,23.87,517.03,27.94,517.90,30.58,515.32,38.01,515.36,39.50,517.35,42.37,517.34
K,40.00,#0,516.19,#1,1.05,515.15,7.02,515.10,8.79,516.95,15.87,516.63,17.63,516.04,18.73,516.02,19.53,516.51,40.39,516.50
K,40.00,#0,516.19,#2,0.50,516.24,2.68,516.82,3.92,516.54,40.39,516.57
点击转换按钮,转换为下面的数据
0.00,#0
8.28,516.31,37.09,516.41,37.65,516.23,41.39,516.20
25.28,516.40,33.53,516.67,34.12,516.25,41.37,516.26
20.00,#0
15.39,516.35,41.37,516.42
18.90,516.35,19.00,516.10,22.35,516.11,23.87,517.03,27.94,517.90,30.58,515.32,38.01,515.36,39.50,517.35,42.37,517.34
40.00,#0
1.05,515.15,7.02,515.10,8.79,516.95,15.87,516.63,17.63,516.04,18.73,516.02,19.53,516.51,40.39,516.50
0.50,516.24,2.68,516.82,3.92,516.54,40.39,516.57
应该不叫软件,叫小程序,不能看明白要求的,可是到我另外一个博客里面去看,我的两外一个账号,秦朝无泪,也悬赏了100分,希望哪位能做出来,200分都给他,
这个小程序的目标要求在我博客的日记里能够看到
http://hi.baidu.com/QINCHAOwulei
高分求用Java编写的一个小软件
答案:2 悬赏:10 手机版
解决时间 2021-01-25 20:27
- 提问者网友:且恨且铭记
- 2021-01-25 16:08
最佳答案
- 五星知识达人网友:枭雄戏美人
- 2021-01-25 17:13
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
public class Test extends JFrame implements ActionListener {
private static final long serialVersionUID = 1L;
private JTextArea txt2;
private JTextArea txt1;
public static void main(String args[]) {
try {
Test frame = new Test();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
public Test() {
super();
setName("");
setResizable(false);
getContentPane().setLayout(null);
setTitle("Test");
setBounds(100, 100, 367, 375);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final JScrollPane scrollPane1 = new JScrollPane();
scrollPane1.setBounds(10, 10, 341, 149);
getContentPane().add(scrollPane1);
final JScrollPane scrollPane2 = new JScrollPane();
scrollPane2.setBounds(10, 188, 340, 145);
getContentPane().add(scrollPane2);
txt1 = new JTextArea();
scrollPane1.setViewportView(txt1);
txt2 = new JTextArea();
scrollPane2.setViewportView(txt2);
final JButton btn = new JButton();
btn.addActionListener(this);
btn.setText("Click");
btn.setBounds(10, 165, 74, 17);
getContentPane().add(btn);
}
public void actionPerformed(ActionEvent e) {
String ss = txt1.getText();
String[] strArr = ss.split("K,");
String temp = "";
for (int i = 0; i < strArr.length; i++) {
if (strArr[i].length() == 0) {
continue;
}
int indexFir = strArr[i].indexOf("#");
int indexLast = strArr[i].lastIndexOf("#");
String str1 = strArr[i].substring(0, indexFir + 2);
String str2 = strArr[i]
.substring(indexLast + 3, strArr[i].length());
if (temp.equals(str1)) {
txt2.append(str2);
txt2.append("\n\r");
} else {
txt2.append(str1);
txt2.append("\n\r");
txt2.append(str2);
txt2.append("\n\r");
}
temp = str1;
}
}
}
//不懂百度HI我~
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
public class Test extends JFrame implements ActionListener {
private static final long serialVersionUID = 1L;
private JTextArea txt2;
private JTextArea txt1;
public static void main(String args[]) {
try {
Test frame = new Test();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
public Test() {
super();
setName("");
setResizable(false);
getContentPane().setLayout(null);
setTitle("Test");
setBounds(100, 100, 367, 375);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final JScrollPane scrollPane1 = new JScrollPane();
scrollPane1.setBounds(10, 10, 341, 149);
getContentPane().add(scrollPane1);
final JScrollPane scrollPane2 = new JScrollPane();
scrollPane2.setBounds(10, 188, 340, 145);
getContentPane().add(scrollPane2);
txt1 = new JTextArea();
scrollPane1.setViewportView(txt1);
txt2 = new JTextArea();
scrollPane2.setViewportView(txt2);
final JButton btn = new JButton();
btn.addActionListener(this);
btn.setText("Click");
btn.setBounds(10, 165, 74, 17);
getContentPane().add(btn);
}
public void actionPerformed(ActionEvent e) {
String ss = txt1.getText();
String[] strArr = ss.split("K,");
String temp = "";
for (int i = 0; i < strArr.length; i++) {
if (strArr[i].length() == 0) {
continue;
}
int indexFir = strArr[i].indexOf("#");
int indexLast = strArr[i].lastIndexOf("#");
String str1 = strArr[i].substring(0, indexFir + 2);
String str2 = strArr[i]
.substring(indexLast + 3, strArr[i].length());
if (temp.equals(str1)) {
txt2.append(str2);
txt2.append("\n\r");
} else {
txt2.append(str1);
txt2.append("\n\r");
txt2.append(str2);
txt2.append("\n\r");
}
temp = str1;
}
}
}
//不懂百度HI我~
全部回答
- 1楼网友:往事埋风中
- 2021-01-25 18:19
你的问题正在解答,请耐心等待...
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯