For a start you can i.e. look here for an example how to implement buttons. You can browse the site also for other components.
The general concept is that you create your GUI with Window Builder visually. Then you can attach action handlers, which are called when the object is triggered. So for example in ordeer to perform some action when a button is pressed you do something like this:
in the main code:
createGUI(this);
In the gui code:
class MyGui
{
private JButton jButton;
private MyButtonListener mListener;
public void createGUI(MyButtonListener oListener)
{
mListener = oListener;
createGUIElements();
}
private createGUIElements()
{
jButton = new JButton();
jButton.setText("MyButton");
jButton.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent e)
{
mListener.onButtonClicked(e);
}
});
}
}
Or an alternative approach where you directly create the action listener in the main application and jsut pass it to the GUi element.
class MyGui
{
private JButton jButton;
private ActionListener mListener;
public void createGUI(ActionListener oListener)
{
mListener = oListener;
createGUIElements();
}
private createGUIElements()
{
jButton = new JButton();
jButton.setText("MyButton");
jButton.addActionListener(mListener);
}
}
The same basically applies to most other controls as well, so you can attach an action handler on a combobox, checkbox, etc..
So to get started, just create a simple window with a single button and try to implement something when the button is pressed.