3

I am using the drag-and-drop style of GUI ( I can't write GUI code yet ).

I only know a few function like: setVisible, getText, setText, etc.

But I want to learn all the functions for the buttons or textfields that I can use

GG.
  • 21,083
  • 14
  • 84
  • 130
joseph
  • 31
  • 2

2 Answers2

4

If you mean the Swing GUI:

  • The actual methods you can call and fields you can access in your code are exactly what you'll find in javax.swing in the Java documentation corresponding to the class you're looking at.

    For example, if you have a JFrame, you can find all the methods in javax.swing.JFrame.

  • Properties are derived from the above Swing methods (mostly in a "remove the 'set' and 'get' manner").

    For example, if you have a JFrame, you might see a background property in Netbeans, and you can find setBackground and getBackground in the documentation.

  • Bindings seem to be NetBeans specific, but these are also based on the properties.

    For example, there's a background binding and also a background property.

  • Events are a bit more complicated - for example, all the mouseX events correspond roughly to addMouseListener and addMouseMotionListener, where the corresponding MouseListener and MouseMotionListener parameters has the mouseClicked, mouseEntered, etc. methods.

If you mean AWT, I imagine something similar would apply for that (but just taken from the java.awt package instead).


That's not to say every method appears in some form in the NetBeans UI - it wouldn't make sense for something like update to appear there, since that's something you need to decide when to call yourself during runtime.

Community
  • 1
  • 1
Bernhard Barker
  • 54,589
  • 14
  • 104
  • 138
1

Whenever you intend to study all the methods of a class, the first thing to check should be the documentation entry of that class (if exists). In general, it should contain some of the methods you are interested about and looking at the documentation entry of the parent class and the parent class of the parent class and so on should reveal all the knowledge you are interested about, therefore, this could be the learning algorithm:

  • define a set of classes you intend to study
  • open the documentation of the class
  • add the parent class/interface to the list described in step 1
  • create a list of methods you are interested about (probably you are not interested in all of them in all the cases)
  • go through the methods one by one
  • reread your lists and check whether you think there are items you might not be remembering some important details and if there are so, reread their entry. Repeat this step until there are no such items

If you already have satisfying theoretical knowledge, but you are not sure about the practice, you might want to create some small sandbox projects to try the things you just learned.

Lajos Arpad
  • 64,414
  • 37
  • 100
  • 175