Xara
Xara

Reputation: 9098

Menu buttons to be present in all the frames

I am creating different frames for my GUI(Netbeans drag and drop) and in that i want to keep some buttons(sort of menu bar) visible in all the frames but the problem is when i copy the main frame and paste it,those buttons are there in the new frame with new names.So, i have to write the same code everytime.Is there any other easy approach for doing this.

Upvotes: 1

Views: 299

Answers (2)

trashgod
trashgod

Reputation: 205855

JToolBar is ideal for this, as it can float above the frame. Action lets you encapsulate the code conveniently. FileMenu is a basic example that combines the two.

Upvotes: 2

lzdt
lzdt

Reputation: 499

Make own MenuBar class, put your buttons there and use different instances of it in all your Frames is what you want I guess? So you have only to put different ActionListeners on each instance and not write same copy-pasted code over again.

Also you can make that frame as your own subclassed component which you can reuse from netbeans GUI builder like an JButton. Try to ask more precisely, hard to guess what you want.

Upvotes: 0

Related Questions