开发者

Jpanel layout problem, show a two column of buttons and labels, how?

I want to make a jPanel (vehicleListPanel) with two column like this:

NAME   |   button
name   |   button
...

Left column shows vehicle name, and right column shows an icon proper with vehicle status (red, green icon) ...

I try to make it, but there is problems with button size, I can't set it how I want. Could you give me an example?开发者_Go百科


If you have NetBeans, you can use the GUI designer to do this by visually dragging, dropping, and resizing your component without even specifying a layout. Even if ultimately you don't want to use NetBeans, you can look at the generated code to know how you can achieve a similar result manually.


You can use GridLayout if you want all the columns to have the same width.

It would be helpful if you show some code.


If you are having problem with sizes, then you are either specifying the wrong size, or else, you have some layout manager that is taking over and changing the sizes. If you are building the GUI yourself without any use of Drag Drop facilities like Netbeans and Eclipse provide, you might want to use this:

vehicleListPanel.setLayout(null);

This leaves everything up to you though. Just like Sanoj said, it would be helpful if you gace us some code.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜