开发者

Eclipse Visual Editor: Components not shown in JTabbedPane

I want to create a JTabbedPane in a Visual Class using the Visual Editor in Eclipse.

I selected JTabbedPane from the beans menu on the toolbar. I next clicked on the class to drop it in. So far, no problems. But wait, no tabs are showing up.

The tutorials on the web say to drop a component into the TabbedPane and the tabs will show up. I dropped a JLabel and no tabs showed up.

Deleted the JLabel using the design window. Dragged a JTextPane, still no tabs.

I drag开发者_开发百科 a JTextfield, onto the TabbedPane (without deleting the JTextPane), still no tabs showing.

I set the "tabs_text" properties of the JTextField and the JTextPane. Still no tabs show up.

Also, the components are not showing on the TabbedPane. It's like a gray whole that just swallows things and no images are reflected back.

Anybody have a step by step tutorial, instructions or something similar for how to put a JTabbedPane onto a Visual Class and also components into the JTabbedPane? Pictures would be very helpful.

Do I have to use NetBeans or hand-code the JTabbedPane?

Note: I'm trying to create a tabbed pane (or notebook in other GUI terminology) with one tab for person's address and another tab for phone numbers.


You should be able to create a JTabbedPane with the editor. But since you asked:

Do I have to use NetBeans or hand-code the JTabbedPane?

I will answer that with no you don't. But I would very highly recommend hand-coding the entire GUI. Visual Builders are nice for prototypes but produce much pain and bloodshed for those who have to maintain the code. Once you get past the Swing learning curve, you will find that Builders only limit your ability.


The TabbedPanel is showing up. Here's what I did:

  • I created a separate class, Residence, derived from JPanel. Added all the labels and fields.
  • Modified the addTab statement to add the new panel.
  • Changed the add method to use 2 parameters, not 4.
  • Removed all "ve" comments, placed in the code by the Visual Editor.

I don't know which, any or if all of the above was necessary, but that is what I did and now the TabbedPane is showing in the Visual Editor.

Looks like the Visual Editor may be more useful to show what the form looks like rather than as a tool to build them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜