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
No related branches found
No related tags found
No related merge requests found
3
230411
4
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
230411
4
230511
package shukan;
import javax.swing.JFrame;
import javax.swing.*;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
......@@ -35,8 +35,9 @@ public class Shukan
// Creating Shukan viewer
JFrame frame = new JFrame ("SHUKAN 1.6");
JPanel global = new JPanel(new BorderLayout());
ShukanView canvas = new ShukanView (data, io);
ShukanViewBar barre = new ShukanViewBar(io, data);
ShukanViewBar barre = new ShukanViewBar(io, data, 90);
// Getting the display size
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment ();
......@@ -44,13 +45,14 @@ public class Shukan
GraphicsConfiguration[] gc = gd.getConfigurations ();
Rectangle gcBounds = gc[0].getBounds ();
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)
ShukanController myController = new ShukanController (canvas, data);
canvas.addKeyListener (myController);
canvas.addMouseListener (myController);
// canvas.addMouseMotionListener (myController);
//canvas.addMouseMotionListener (myController);
// Preparing the window closing button
frame.addWindowListener (
......@@ -65,11 +67,12 @@ public class Shukan
// Setting the window geometry
frame.add(barre, BorderLayout.NORTH);
frame.add (canvas, BorderLayout.CENTER);
global.add(barre, BorderLayout.NORTH);
global.add (canvas, BorderLayout.CENTER);
frame.add(global);
Insets ins = frame.getInsets ();
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.setBackground (Color.white);
frame.setVisible (true);
......
......@@ -10,15 +10,27 @@ public class ShukanViewBar extends JPanel {
private ShukanIO myIO = null;
/** Displayed data */
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 JButton buttons[] = new JButton[8];
/** type of the images */
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.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) {
super.paintComponents(g);
// load images
......@@ -29,7 +41,10 @@ public class ShukanViewBar extends JPanel {
}
}
catch(Exception e){System.out.println("Image manquante");}
}
}*/
public int getHeight(){return height;}
public static void main(String args[]){
ShukanData data = new ShukanData ();
......@@ -37,8 +52,8 @@ public class ShukanViewBar extends JPanel {
EventQueue.invokeLater(new Runnable() {
public void run() {
JFrame f = new JFrame("esssai");
ShukanViewBar s = new ShukanViewBar (io,data);
f.setSize(1000, 80);
ShukanViewBar s = new ShukanViewBar (io,data, 90);
f.setSize(1000, s.getHeight());
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.add(s);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment