,如果我理解正確的話,你要在標籤旁邊的JTabbedPane中繪製文本字段?
這樣做沒有簡單的方法。您可以使用在右上方繪製TextField的glassPane-Component
。並將其設置爲框架。
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
JFrame frame = new JFrame();
frame.setBounds(50, 50, 800, 600);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel glasspane = new JPanel(new FlowLayout(FlowLayout.RIGHT));
frame.setGlassPane(glasspane);
glasspane.setOpaque(false);
JTextField textField = new JTextField("Search");
glasspane.add(textField);
glasspane.setVisible(true);
JTabbedPane tabs = new JTabbedPane();
tabs.setBorder(BorderFactory.createEmptyBorder(10, 5, 5, 5));
tabs.addTab("Lorem", null);
tabs.addTab("Ipsum", null);
tabs.addTab("Dolor", null);
frame.setContentPane(tabs);
frame.setVisible(true);
真棒謝謝你! – LDAdams 2011-05-27 16:20:24