Skip to content
Snippets Groups Projects
Commit bec648ca authored by PIQUEREZ Corentin's avatar PIQUEREZ Corentin
Browse files

rajout boutons dans barre outils

parent 07f3ef97
Branches
No related tags found
No related merge requests found
3 4
230411 230511
data/images/parameter.png

15.5 KiB | W: | H:

data/images/parameter.png

2.25 KiB | W: | H:

data/images/parameter.png
data/images/parameter.png
data/images/parameter.png
data/images/parameter.png
  • 2-up
  • Swipe
  • Onion skin
3 4
230411 230511
package shukan; package shukan;
import javax.swing.JFrame; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.WindowAdapter; import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
...@@ -35,8 +35,9 @@ public class Shukan ...@@ -35,8 +35,9 @@ public class Shukan
// Creating Shukan viewer // Creating Shukan viewer
JFrame frame = new JFrame ("SHUKAN 1.6"); JFrame frame = new JFrame ("SHUKAN 1.6");
JPanel global = new JPanel(new BorderLayout());
ShukanView canvas = new ShukanView (data, io); ShukanView canvas = new ShukanView (data, io);
ShukanViewBar barre = new ShukanViewBar(io, data); ShukanViewBar barre = new ShukanViewBar(io, data, 90);
// Getting the display size // Getting the display size
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment (); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment ();
...@@ -44,13 +45,14 @@ public class Shukan ...@@ -44,13 +45,14 @@ public class Shukan
GraphicsConfiguration[] gc = gd.getConfigurations (); GraphicsConfiguration[] gc = gd.getConfigurations ();
Rectangle gcBounds = gc[0].getBounds (); Rectangle gcBounds = gc[0].getBounds ();
canvas.restrictSize ((int) (gcBounds.getWidth ()) - LEFT_MARGIN, canvas.restrictSize ((int) (gcBounds.getWidth ()) - LEFT_MARGIN,
(int) (gcBounds.getHeight ()) - TOP_MARGIN); (int) (gcBounds.getHeight ()) - TOP_MARGIN - barre.getHeight());
barre.setSize(new Dimension((int) (gcBounds.getWidth ()) - LEFT_MARGIN, barre.getHeight()));
// Adding a openGL input handler (controller) // Adding a openGL input handler (controller)
ShukanController myController = new ShukanController (canvas, data); ShukanController myController = new ShukanController (canvas, data);
canvas.addKeyListener (myController); canvas.addKeyListener (myController);
canvas.addMouseListener (myController); canvas.addMouseListener (myController);
// canvas.addMouseMotionListener (myController); //canvas.addMouseMotionListener (myController);
// Preparing the window closing button // Preparing the window closing button
frame.addWindowListener ( frame.addWindowListener (
...@@ -65,11 +67,12 @@ public class Shukan ...@@ -65,11 +67,12 @@ public class Shukan
// Setting the window geometry // Setting the window geometry
frame.add(barre, BorderLayout.NORTH); global.add(barre, BorderLayout.NORTH);
frame.add (canvas, BorderLayout.CENTER); global.add (canvas, BorderLayout.CENTER);
frame.add(global);
Insets ins = frame.getInsets (); Insets ins = frame.getInsets ();
frame.setSize (canvas.displayWidth () + ins.left + ins.right, frame.setSize (canvas.displayWidth () + ins.left + ins.right,
canvas.displayHeight ()+ ins.top + ins.bottom); canvas.displayHeight ()+ barre.getHeight()+ ins.top + ins.bottom);
frame.setLocation (LEFT_MARGIN, 0); frame.setLocation (LEFT_MARGIN, 0);
frame.setBackground (Color.white); frame.setBackground (Color.white);
frame.setVisible (true); frame.setVisible (true);
......
...@@ -10,15 +10,27 @@ public class ShukanViewBar extends JPanel { ...@@ -10,15 +10,27 @@ public class ShukanViewBar extends JPanel {
private ShukanIO myIO = null; private ShukanIO myIO = null;
/** Displayed data */ /** Displayed data */
private ShukanData data = null; private ShukanData data = null;
/** Name of the images files for the buttons of the toolbar */
private String[] imagesName = {"save", "back", "plus", "delete", "left", "right", "export", "parameter"}; private String[] imagesName = {"save", "back", "plus", "delete", "left", "right", "export", "parameter"};
private JButton buttons[] = new JButton[8];
/** type of the images */
private String imagesExtension = ".png"; private String imagesExtension = ".png";
/** height in pixel of the toolbar */
private int height;
public ShukanViewBar(ShukanIO myIO, ShukanData data){ public ShukanViewBar(ShukanIO myIO, ShukanData data, int height){
this.myIO = myIO; this.myIO = myIO;
this.data = data; this.data = data;
this.height = height;
for(int i = 0; i<imagesName.length;i++){
buttons[i] = new JButton("", new ImageIcon("data/images/"+imagesName[i]+imagesExtension));
buttons[i].setPreferredSize(new Dimension(80,80));
add(buttons[i]);
}
} }
@Override /* @Override
public void paintComponent(Graphics g) { public void paintComponent(Graphics g) {
super.paintComponents(g); super.paintComponents(g);
// load images // load images
...@@ -29,7 +41,10 @@ public class ShukanViewBar extends JPanel { ...@@ -29,7 +41,10 @@ public class ShukanViewBar extends JPanel {
} }
} }
catch(Exception e){System.out.println("Image manquante");} catch(Exception e){System.out.println("Image manquante");}
} }*/
public int getHeight(){return height;}
public static void main(String args[]){ public static void main(String args[]){
ShukanData data = new ShukanData (); ShukanData data = new ShukanData ();
...@@ -37,8 +52,8 @@ public class ShukanViewBar extends JPanel { ...@@ -37,8 +52,8 @@ public class ShukanViewBar extends JPanel {
EventQueue.invokeLater(new Runnable() { EventQueue.invokeLater(new Runnable() {
public void run() { public void run() {
JFrame f = new JFrame("esssai"); JFrame f = new JFrame("esssai");
ShukanViewBar s = new ShukanViewBar (io,data); ShukanViewBar s = new ShukanViewBar (io,data, 90);
f.setSize(1000, 80); f.setSize(1000, s.getHeight());
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.add(s); f.add(s);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment