JApplet Example with FlowLayout and setPreferredSize method


import java.awt.Dimension;
import java.awt.FlowLayout;
import javax.swing.JApplet;
import javax.swing.JButton;

public class JAppletTesting extends JApplet {
   
    FlowLayout fl = new FlowLayout(FlowLayout.LEFT);
   
    JButton btok, btcl;
    Dimension d1;

    public void init() {
// setting layout to FlowLayout      
        setLayout(fl);
        d1 = new Dimension(100, 40);
        btok = new JButton("OK");
        btcl =new JButton("Close");
       
        btok.setPreferredSize(d1);
        add(btok);
        add(btcl);
    }

}

Comments

Popular posts from this blog

Custom Exception example for BankAccount

HashMap HashSet example

Annotation