我是JAVA GUI的新手,遇到了问题.下图显示了我的问题所在的GUI部分.
我想实现这一点,当我点击"点击切换"按钮时,将交换comboBox的内容.我尝试了不同的方式来交换两个comboBox的位置或交换两个ComboBox的内容,但都没有成功.
以下是我的代码中与此问题相关的部分.
1类:
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JPanel;
public class FilePathComboBox implements ActionListener {
List<String> strings;
BufferedReader input;
JComboBox comboBox;
JPanel jpFilePath;
JButton testJB;
public FilePathComboBox(String filePathOfSyncTool) {
strings = new ArrayList<String>();
FileReader fr;
try {
fr = new FileReader(filePathOfSyncTool);
} catch (FileNotFoundException e1) {
fr = null;
e1.printStackTrace();
}
input = new BufferedReader(fr);
try {
String line = …Run Code Online (Sandbox Code Playgroud)