mike9182
mike9182

Reputation: 450

Why does my swing GUI look different in design than at run-time?

When I design my GUI using swing, the Swing Control Buttons are grey and the text easily fits on them. However, when I run the program the buttons become partly blue and the text no longer fits on them. Why does my program look different in the Swing Design than at run-time?

Upvotes: 3

Views: 2903

Answers (2)

camickr
camickr

Reputation: 324088

Why does my program look different in the Swing Design than at run-time?

Probably has something to do with your Look and Feel.

However, when I run the program the buttons become partly blue and the text no longer fits on them.

Probably because you are not using layout managers. Layout managers will make sure components are displayed properlly, even when switching between LAF's.

I can't guess what tool you are using to create your GUI but you are doing something wrong with the tool. If you need more help then post your SSCCE that demonstrates the problem.

Upvotes: 1

Denis Tulskiy
Denis Tulskiy

Reputation: 19167

I suppose you're using some GUI builder. Netbeans gui builder displays preview with native LaF, while program runs with default Metal LaF, which has different margins for components and font size. Either change LaF in your program to the one that works best for your layout, or make your components larger.

Upvotes: 0

Related Questions