0
ComboBox에 대한 사용자 지정 목록 모델을 설정하기 만하면됩니다. 주석 처리 된 코드도 작동하지 않았습니다. 나는 왜 그런지 전혀 모른다!intellij에서 사용자 지정 구성 요소 생성이 실패합니다.
내가 JDK 1.8
import jssc.SerialPortList;
import javax.swing.*;
import java.awt.*;
public class sampleForm extends JFrame {
private JComboBox comboBox1;
private JPanel panel1;
/*public sampleForm() {
super("title");
String[] portNames = SerialPortList.getPortNames();
setLayout(new FlowLayout());
comboBox1 = new JComboBox(portNames);
add(comboBox1);
}*/
public static void main(String[] args) {
JFrame frame = new JFrame("sampleForm");
frame.setContentPane(new sampleForm().panel1);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
private void createUIComponents() {
// TODO: place custom component creation code here
String[] portNames = SerialPortList.getPortNames();
comboBox1 = new JComboBox(port);
}
} 클래스가 이미 JFrame
입니다