[英]Change the label of JComboBox
我將File
類數組傳遞給JComboBox
。 這樣就可以在GUI中顯示所選文件的完整路徑。 我只想在組合框中顯示文件名。
代碼如下:
public void generateGui(File[] files){
// main frame
frame = new JFrame("All In One");
frame.setSize(500, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null);
JPanel scriptPanel = new JPanel();
JCombobox scriptList = new JComboBox(files); // Passing the array of File class
scriptPanel.add(scriptList);
frame.add(scriptPanel,BorderLayout.NORTH);
frame.setVisible(true);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.