0% found this document useful (0 votes)
5 views7 pages

Advanced Java Swing Programming Guide

This document contains notes from an Advanced Java Programming class about Swing JComponents and FlowLayout managers. The notes discuss using FlowLayout to arrange buttons from left to right or right to left, and setting orientation. BorderLayout is also covered, with examples of adding buttons to the north, south, east, west, and center sections. The document concludes with an announcement of a question and answer session.

Uploaded by

Mackendy Talcide
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views7 pages

Advanced Java Swing Programming Guide

This document contains notes from an Advanced Java Programming class about Swing JComponents and FlowLayout managers. The notes discuss using FlowLayout to arrange buttons from left to right or right to left, and setting orientation. BorderLayout is also covered, with examples of adding buttons to the north, south, east, west, and center sections. The document concludes with an announcement of a question and answer session.

Uploaded by

Mackendy Talcide
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

École Supérieure d'Infotronique d'Haïti

Advanced Java Programming


Module 3: Swing JComponent and FlowManager
Moïse Edner BRUTUS M. Sc.
March 2016
Plan de séance

1. Utilisation d'un FlowLayer Manager


2. Utilisation de Button
3. BorderLayout Manager
4. Text Components
5. Travaux Pratiques
6. Questions & Réponse

March 8, 2017 Moïse Edner Brutus, Adv. Java's Class 2


Utilisation d'un FlowLayer Manager
import [Link];
import [Link];
import [Link].*;

public class FlowLayoutTest1 {

public static void main(String[] args){


JFrame frame = new JFrame("Flow Layout Test 1");
[Link](JFrame.EXIT_ON_CLOSE);

Container contentPane = [Link]();


[Link](new FlowLayout());

for(int i = 1; i <= 5; i++ ){

[Link](new JButton("Button " + i));


}
[Link]();
[Link](true);
}
March 8, 2017 } Moïse Edner Brutus, Adv. Java's Class 3
Utilisation d'un FlowLayer Manager (suite)
import [Link];
import [Link];
import [Link].*;

public class FlowLayoutTest2 {

public static void main(String[] args){


JFrame frame = new JFrame("Flow Layout Test 1");
[Link](JFrame.EXIT_ON_CLOSE);
Right Alignment !
Container contentPane = [Link]();
Give a try with: FlowLayout myLayout = new FlowLayout([Link]);
LEFT,
CENTER, [Link](myLayout);
LEADING,
TRAILING; for(int i = 1; i <= 5; i++ ){

[Link](new JButton("Button " + i));


}
[Link]();
[Link](true);
}
March 8, 2017 } Moïse Edner Brutus, Adv. Java's Class 4
Utilisation d'un FlowLayer Manager (suite)
import [Link].*;
import [Link].*;

public class FlowLayoutTestOrientation {


public static void main(String[] args){
JFrame frame = new JFrame("Flow Layout Test 1");
[Link](JFrame.EXIT_ON_CLOSE);

Container contentPane = [Link]();


FlowLayout myLayout = new FlowLayout([Link]);
Orientation:
RIGHT_TO_LEFT [Link](ComponentOrientation.RIGHT_TO_LEFT);
// TRY [Link](myLayout);
LEFT_TO_RIGHT
for(int i = 1; i <= 5; i++ ){
[Link](new JButton("Button " + i));
}
[Link]();
[Link](true);
}

}
March 8, 2017 Moïse Edner Brutus, Adv. Java's Class 5
BorderLayout Manager
import [Link].*;
import [Link].*;

public class BorderLayoutTest {


public static void main(String[] args){
JFrame frame = new JFrame("Flow Layout Test 1");
[Link](JFrame.EXIT_ON_CLOSE);
Container contentPane = [Link]();
Give a try with: // Nous ajoutons un button a chaque partie du borderlayout
PAGE_START, [Link](new JButton("North"), [Link]);
PAGE_END, [Link](new JButton("South"), [Link]);
LINE_START, [Link](new JButton("EAST"), [Link]);
LINE_END; [Link](new JButton("West"), [Link]);
[Link](new JButton("Center"), [Link]);

[Link]();
[Link](true);
}
}

March 8, 2017 Moïse Edner Brutus, Adv. Java's Class 6


Questions & Réponses!!

March 8, 2017 Moïse Edner Brutus, Adv. Java's Class 7

You might also like