Upload
cheick-ismael-maiga
View
110
Download
5
Embed Size (px)
DESCRIPTION
Un tutoriel pour prendre en main l'api Jtatoo afin d'améliorer vos ihm swing n'hésitez pas laissez des commentaires
Citation preview
Cheick Ismael MAIGA
Jtatoo : Api pour vos IHM
Introduction Jtattoo se compose de plusieurs outils pour les applications Swing. Chacun d'entre eux permet aux
développeurs d'améliorer leur application avec une excellente interface utilisateur. L’api permet de
modifier les thèmes et d’ajouter des boutons close au jtabbePane et autre fonctionnalités.
Téléchargement et installation
Téléchargement lien : http://www.jtattoo.net/Download.html
Installation Comme tout jar l’installation se fait par l’ajout de la librairie à partir du built path .Il existe plusieur
méthode . Je vais vous présenter deux méthodes
1ère méthode :
Clic droit sur le projet built path add external archives
Une boite de dialogue s’ouvre et vous demande le chemin ou se situe le jar télécharger
2ème méthode :
Cette méthode consiste a crée un user library. L’avantage de cette méthode est que vous n’auriez
plus à aller cherche le jar eclipse s’aura d’office là ou chercher
Clic droit sur le projet built path addlibraries user library (voir screenshots )
Cheick Ismael MAIGA
Cheick Ismael MAIGA
Une fois fini votre api est prêt à être utiliser
TP
Le TP consiste a crée une petite application et tester les différentes thème que nous propose l’api
Les différents lookAndFeel proposés sont :
acryl : "com.jtattoo.plaf.acryl.AcrylLookAndFeel"
aero: "com.jtattoo.plaf.aero.AeroLookAndFeel"
aluminium: "com.jtattoo.plaf.aluminium.AluminiumLookAndFeel"
bernstein: "com.jtattoo.plaf.bernstein.BernsteinLookAndFeel"
fast : "com.jtattoo.plaf.fast.FastLookAndFeel"
graphite : "com.jtattoo.plaf.graphite.GraphiteLookAndFeel"
hifi : "com.jtattoo.plaf.hifi.HiFiLookAndFeel"
luna : "com.jtattoo.plaf.luna.LunaLookAndFeel"
mcwin : "com.jtattoo.plaf.mcwin.McWinLookAndFeel"
mint : "com.jtattoo.plaf.mint.MintLookAndFeel"
noire : "com.jtattoo.plaf.noire.NoireLookAndFeel"
smart : "com.jtattoo.plaf.smart.SmartLookAndFeel"
texture: "com.jtattoo.plaf.texture.TextureLookAndFeel"
Code source de l’appplication
package com.app.ihm; import java.awt.BorderLayout; import java.awt.EventQueue; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.GroupLayout; import javax.swing.GroupLayout.Alignment; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTextArea; import javax.swing.LayoutStyle.ComponentPlacement; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import javax.swing.border.EmptyBorder; import javax.swing.JToolBar; public class Myapp extends JFrame { private JPanel contentPane; private static UIManager ui;//servira modifier le thème private JTextArea textArea; /** * Launch the application. * @throws UnsupportedLookAndFeelException * @throws IllegalAccessException * @throws InstantiationException * @throws ClassNotFoundException */
Cheick Ismael MAIGA
/* * pour modifier le look il suffi de changer la de faire * ui.setLookAndFeel(thème) thème sera changer * par exemple par com.jtattoo.plaf.aero.AeroLookAndFeel */ public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException { //permet de modifier le thème //getUi().setLookAndFeel("com.jtattoo.plaf.aero.AeroLookAndFeel"); EventQueue.invokeLater(new Runnable() { public void run() { try { Myapp frame = new Myapp(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace();}}});} /** * Create the frame. */ public Myapp() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 450, 401); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); contentPane.setLayout(new BorderLayout(0, 0)); setContentPane(contentPane); JPanel panel = new JPanel(); contentPane.add(panel, BorderLayout.WEST); JButton btnNewButton = new JButton("acyrl"); btnNewButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { getUi().setLookAndFeel("com.jtattoo.plaf.acryl.AcrylLookAndFeel"); textArea.setText("acryl"); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e1) { // TODO Auto-generated catch block e1.printStackTrace(); }}}); JButton btnNewButton_1 = new JButton("aero"); btnNewButton_1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { getUi().setLookAndFeel("com.jtattoo.plaf.aero.AeroLookAndFeel"); textArea.setText("aero"); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } }}); JButton btnNewButton_2 = new JButton("aluminium"); btnNewButton_2.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { getUi().setLookAndFeel("com.jtattoo.plaf.aluminium.AluminiumLookAndFeel"); textArea.setText("aluminium"); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e1) { // TODO Auto-generated catch block e1.printStackTrace();}}}); JButton btnNewButton_3 = new JButton("bernstein"); btnNewButton_3.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try {
Cheick Ismael MAIGA
getUi().setLookAndFeel("com.jtattoo.plaf.bernstein.BernsteinLookAndFeel"); textArea.setText("bernstein"); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e1) { // TODO Auto-generated catch block e1.printStackTrace();}}}); JButton btnNewButton_4 = new JButton("fast"); btnNewButton_4.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { getUi().setLookAndFeel("com.jtattoo.plaf.fast.FastLookAndFeel"); textArea.setText("fast"); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }); JButton btnNewButton_5 = new JButton("graphite"); btnNewButton_5.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { getUi().setLookAndFeel("com.jtattoo.plaf.graphite.GraphiteLookAndFeel"); textArea.setText("graphite"); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e1) { // TODO Auto-generated catch block e1.printStackTrace();}}}); JButton btnNewButton_6 = new JButton("hifi"); btnNewButton_6.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { getUi().setLookAndFeel("com.jtattoo.plaf.hifi.HiFiLookAndFeel"); textArea.setText("hifi"); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e1) { // TODO Auto-generated catch block e1.printStackTrace();}}}); JButton btnNewButton_7 = new JButton("luna"); btnNewButton_7.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { getUi().setLookAndFeel("com.jtattoo.plaf.luna.LunaLookAndFeel"); textArea.setText("luna"); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e1) { // TODO Auto-generated catch block e1.printStackTrace(); }}}); JButton btnNewButton_8 = new JButton("texture"); btnNewButton_8.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try {
Cheick Ismael MAIGA
getUi().setLookAndFeel("com.jtattoo.plaf.texture.TextureLookAndFeel"); textArea.setText("texture"); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }); JButton btnNewButton_9 = new JButton("noire"); btnNewButton_9.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { getUi().setLookAndFeel("com.jtattoo.plaf.noire.NoireLookAndFeel"); textArea.setText("noire"); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e1) { // TODO Auto-generated catch block e1.printStackTrace();}}}); JButton btnNewButton_10 = new JButton("smart"); btnNewButton_10.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { try { getUi().setLookAndFeel("com.jtattoo.plaf.smart.SmartLookAndFeel"); textArea.setText("smart"); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e1) { // TODO Auto-generated catch block e1.printStackTrace();}}}); GroupLayout gl_panel = new GroupLayout(panel); gl_panel.setHorizontalGroup( gl_panel.createParallelGroup(Alignment.LEADING) .addGroup(Alignment.TRAILING, gl_panel.createSequentialGroup() .addContainerGap() .addGroup(gl_panel.createParallelGroup(Alignment.TRAILING) .addComponent(btnNewButton_8, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 79, Short.MAX_VALUE) .addComponent(btnNewButton_7, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 79, Short.MAX_VALUE) .addComponent(btnNewButton_6, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 79, Short.MAX_VALUE) .addComponent(btnNewButton_2, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btnNewButton_3, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 79, Short.MAX_VALUE) .addComponent(btnNewButton_4, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 79, Short.MAX_VALUE) .addComponent(btnNewButton_5, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 79, Short.MAX_VALUE) .addComponent(btnNewButton_9, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 79, Short.MAX_VALUE) .addComponent(btnNewButton_10, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 79, Short.MAX_VALUE) .addComponent(btnNewButton_1, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 79, Short.MAX_VALUE) .addComponent(btnNewButton, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 79, Short.MAX_VALUE)) .addContainerGap()) ); gl_panel.setVerticalGroup( gl_panel.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel.createSequentialGroup() .addComponent(btnNewButton) .addPreferredGap(ComponentPlacement.RELATED)
Cheick Ismael MAIGA
.addComponent(btnNewButton_1) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(btnNewButton_2) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(btnNewButton_3) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(btnNewButton_4) .addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(btnNewButton_5) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(btnNewButton_6) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(btnNewButton_7) .addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(btnNewButton_8) .addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(btnNewButton_9) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(btnNewButton_10) .addContainerGap(25, Short.MAX_VALUE)) ); panel.setLayout(gl_panel); JPanel panel_1 = new JPanel(); contentPane.add(panel_1, BorderLayout.CENTER); textArea = new JTextArea(); GroupLayout gl_panel_1 = new GroupLayout(panel_1); gl_panel_1.setHorizontalGroup( gl_panel_1.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel_1.createSequentialGroup() .addContainerGap() .addComponent(textArea, GroupLayout.DEFAULT_SIZE, 296, Short.MAX_VALUE) .addGap(19)) ); gl_panel_1.setVerticalGroup( gl_panel_1.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel_1.createSequentialGroup() .addGap(38) .addComponent(textArea, GroupLayout.DEFAULT_SIZE, 320, Short.MAX_VALUE) .addContainerGap()) ); panel_1.setLayout(gl_panel_1); } public static UIManager getUi() { return ui;} public void setUi(UIManager ui) {
this.ui = ui;}}
Figure 1:Thème par défaut
Cheick Ismael MAIGA
Screenshots de quelques lookAndFeels de JTatoo
Figure 2 Thème Acryl
Figure 3 thème texture
Figure 4 thème aero