1

In Netbeans under the design tab, I am able to add in a JButton which generates a private member javax.swing.JButton jbutton1.

I want all of my JButtons to implement a custom interface that I made called X as such:

public class myCustomButton extends javax.swing.JButton
    implements X
{
   //Some code here...
}

Is there a way to add in myCustomButtons instead of JButtons without messing up the Netbeans designer?

1 Answer 1

2

In the properties of the button on one of the tabs you can put in post creation code (look for that) or something similar which should do what you want. I'd be more specific if I had netbeans on my machine at the moment.

It shouldn't affect the layout in the designer.

This is what I'm talking about:

Screenshot of the code tab of an element in the netbeans designer

That image is from Netbeans 6 but it should not have changed. I believe it is either post-creation or post-declaration you are looking for.

Alternatively you can use the Code Customizer: Screenshot of the Code Customizer in Netbeans 6
(source: netbeans.org)

Sign up to request clarification or add additional context in comments.

1 Comment

@Rhs, this is also an option of course. You can use "custom creation" instead of "default code". But you'll have to cast every time you'll want to access non-JButton members in your code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.