View Single Post
Light Poster
12Oct2011,18:56  
Taharka's Avatar
Thanks mate! This is what the code looks like I have been learning Java online its great fun, but can be a bit frustrating. I actually think I learn more when i get things wrong!

Code:
//*java tutorial 62 JButton
import java.awt.FlowLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;

public class BT62Gui extends JFrame{//* extends means inheriting everything from JFrame
    
    private JButton reg;
    private JButton custom;
    
    public BT62Gui(){ //* Constructor for the BT62Gui class this also shows a blank screen
        super("The Title");
        setLayout(new FlowLayout()); //* Sets the default layout
        
        reg = new JButton("reg button");//* Displays a button
        add(reg);
        
        Icon b = new ImageIcon(getClass().getResource("b.png")); //* For putting a button on screen.
        Icon x = new ImageIcon(getClass().getResource("b.png")); //* For putting a button on screen.
    }
    
    
}

Last edited by shabbir; 12Oct2011 at 23:06.. Reason: Code blocks