我有兩個並列的JList控件。它們之間的按鈕很少。當我從eclipse運行時,佈局看起來很好。運行jar文件時JList控件大小發生變化
但是,如果我運行導出的jar文件,左側佔據更多的空間。我不知道它爲什麼這樣做。
我將它們放置在這樣的GridBagLayout的。
mLstMdlTestSuitesAvailable = new DefaultListModel<String>();
mLstTestSuitesAvailable = new JList<String>();
mLstTestSuitesAvailable.setModel(mLstMdlTestSuitesAvailable);
mLstTestSuitesAvailable.setMinimumSize(new Dimension(100, 100));
JScrollPane scrollPaneTestSuitesAvailable = new JScrollPane(mLstTestSuitesAvailable);
GridBagConstraints gbcLstTestSuitesAvailable = new GridBagConstraints();
gbcLstTestSuitesAvailable.fill = GridBagConstraints.BOTH;
gbcLstTestSuitesAvailable.weightx = 10;
gbcLstTestSuitesAvailable.gridwidth = 10;
gbcLstTestSuitesAvailable.weighty = 8;
gbcLstTestSuitesAvailable.gridheight = 8;
gbcLstTestSuitesAvailable.insets = new Insets(0, 11, 10, 11);
gbcLstTestSuitesAvailable.gridx = 0;
gbcLstTestSuitesAvailable.gridy = 1;
panel.add(scrollPaneTestSuitesAvailable, gbcLstTestSuitesAvailable);
mLstMdlTestSuitesSelected = new DefaultListModel<String>();
mLstTestSuitesSelected = new JList<String>();
mLstTestSuitesSelected.setModel(mLstMdlTestSuitesSelected);
GridBagConstraints gbcLstTestSuitesSelected = new GridBagConstraints();
gbcLstTestSuitesSelected.fill = GridBagConstraints.BOTH;
gbcLstTestSuitesSelected.weightx = 10;
gbcLstTestSuitesSelected.gridwidth = 10;
gbcLstTestSuitesSelected.weighty = 8;
gbcLstTestSuitesSelected.gridheight = 8;
gbcLstTestSuitesSelected.insets = new Insets(0, 11, 10, 11);
gbcLstTestSuitesSelected.gridx = 15;
gbcLstTestSuitesSelected.gridy = 1;
JScrollPane scrollPaneTestSuitesSelected = new JScrollPane(mLstTestSuitesSelected);
panel.add(scrollPaneTestSuitesSelected, gbcLstTestSuitesSelected);
任何人都可以請幫助我找出這裏出了什麼問題嗎?
我最初的猜測是配置系統運行JAR的JRE與Eclipse使用的不同之處不同 – ControlAltDel 2014-09-26 16:04:35
兩者都使用1.7.0_45 – 2014-09-26 16:12:10
自己嘗試一下,並使用體面的LayoutManager, MiGLayout – keuleJ 2014-09-26 16:55:24