我在设置布局之前初始化了MotePanel,Command Panel和LEDPanel,那么我是如何得到这个例外的.
请帮忙.
Exception in thread "main" java.awt.AWTError: BoxLayout can't be shared
at javax.swing.BoxLayout.checkContainer(BoxLayout.java:462)
at javax.swing.BoxLayout.invalidateLayout(BoxLayout.java:246)
at javax.swing.BoxLayout.addLayoutComponent(BoxLayout.java:279)
at java.awt.Container.addImpl(Container.java:1107)
at java.awt.Container.add(Container.java:974)
at javax.swing.JFrame.addImpl(JFrame.java:556)
at java.awt.Container.add(Container.java:377)
at Window.<init>(Window.java:54)
Run Code Online (Sandbox Code Playgroud)
public class Window extends JFrame{
private JPanel MotePanel;
private JPanel LEDPanel;
private JPanel CommandPanel;
private JCheckBox motes[];
private JRadioButton Leds[];
public Window(){
this.setLayout(new BoxLayout(this,BoxLayout.X_AXIS));
this.setTitle("Sensor Networks Lab");
this.setSize(300, 200);
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
MotePanel = new JPanel();
LEDPanel = new JPanel();
CommandPanel = new JPanel();
motes = new JCheckBox[10];
Leds = new JRadioButton[3];
MotePanel.setLayout(new …Run Code Online (Sandbox Code Playgroud) 我想用"},{"分隔符来分割字符串.我尝试了各种各样的东西,但没有一个能奏效.
string="2,1,6,4,5,1},{8,1,4,9,6,6,7,0},{6,1,2,3,9},{2,3,5,4,3 "
Run Code Online (Sandbox Code Playgroud)
把它分成这样的东西:
2,1,6,4,5,1
8,1,4,9,6,6,7,0
6,1,2,3,9
2,3,5,4,3
Run Code Online (Sandbox Code Playgroud)
string.split("},{") 在Python控制台上工作,但如果我编写一个Python脚本,在这个操作中它不起作用.