























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
This lecture was delivered by Aniruddh Parmar at B. R. Ambedkar Bihar University for Data Transfer Programming course. It includes: Swing, Abstract, Windowing, Toolkit, Extends, Event, Listeners, Properties, Methods, Configure, Create, Layout
Typology: Slides
1 / 31
This page cannot be seen from the preview
Don't miss anything!
JButton
JButton
order important
JPanel
JButton
Listener
JFrame
JLabel
import javax.swing.;*
class hello { public static void main(String[] args){ JFrame f = new JFrame(“title”); JPanel p = new JPanel(); JButton b = new JButton(“press me”);
p.add(b); // add button to panel f.setContentPane(p); // add panel to frame
f.show(); } }
press me
JButton JButton
JTextArea
n
JPanel: BorderLayout
c
JFrame
JPanel: FlowLayout
JButton JButton
JTextArea
JFrame f = new JFrame(“title”);
JPanel p = new JPanel( );
FlowLayout L = new FlowLayout( );
JButton b1 = new JButton(“press me”);
JButton b2 = new JButton(“then me”);
p.setLayout(L);
p.add(b1);
p.add(b2);
f.setContentPane(p);
Set layout mgr before adding components
press me then me
import javax.swing.;*
class hello extends JApplet {
public void init(){ JButton b = new JButton(“press me”); getContentPane().add(b); }
}
JApplet
contentPane
JButton
import javax.swing.; class helloApp { public static void main(String[] args){ // create Frame and put my mainPanel in it JFrame f = new JFrame(“title”); mainPanel p = new mainPanel(); f.setContentPane(p); f.show(); } } class helloApplet extends JApplet { public void init(){ // put my mainPanel in the Applet mainPanel p = new mainPanel(); getContentPane().add(p); } } // my main GUI is in here: class mainPanel extends JPanel { mainPanel(){ setLayout(new FlowLayout()); JButton b = new JButton(“press me”); add(b); } }*
JApplet
contentPane
JPanel
JFrame
JButton
or
Command line Browser