سؤال

I have developed a simple music player in Java which can play any given playlist or simple mp3 song. For now i have worked all things out in plain JPanels. GUI doesn't look neat. I need to revamp the GUI using tabbed pane. How this can be achieved using existing JPanels without affecting current functionality? Also, i am not able to figure out shall i go for Tabbed Pane or Card Layout?

http://docs.oracle.com/javase/tutorial/uiswing/layout/card.html
Because a tabbed pane provides its own GUI, using a tabbed pane is simpler than using the CardLayout class.

هل كانت مفيدة؟

المحلول

"Also, i am not able to figure out shall i go for Tabbed Pane or Card Layout?"

It really depends on your preference of the look of your program. The two layouts perform very similarly, though CardLayout is a little bit more code, though at all not difficult. If you don't want the tab look, which I don't see why you would, for a game, then go with CardLayout

"How this can be achieved using existing JPanels without affecting current functionality? "

  • You need to create separate JPanel for each containment of whatever components you want in each tab. Then just add those JPanel to the JTabbedPane. It shouldn't break any functionality, just the look. Components from another panel should not be affected, you just won't be able to see any changes made, unless that other panel is in view.

  • If you want to go with CardLayout you can look at the tutorial

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top