ajout grille dans JPanelDessin et essai ajout image map1 dans
JPanelImage
This commit is contained in:
parent
a48ecf2da7
commit
f7161d23d3
|
|
@ -1,10 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-16">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="lib" path="jgoodies-forms-1.8.0.jar" sourcepath="jgoodies-forms-1.8.0-sources.jar"/>
|
||||
<classpathentry kind="lib" path="miglayout15-swing.jar" sourcepath="miglayout-src.zip"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=16
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=16
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
|
|
@ -11,4 +11,4 @@ org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
|||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
||||
org.eclipse.jdt.core.compiler.release=enabled
|
||||
org.eclipse.jdt.core.compiler.source=16
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
||||
|
|
|
|||
|
|
@ -1,14 +1,59 @@
|
|||
package graphique;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
|
||||
public class JPanelDessin extends JPanel {
|
||||
private static final long serialVersionUID = -4704888296894874299L;
|
||||
|
||||
/**
|
||||
* Create the panel.
|
||||
*/
|
||||
public JPanelDessin() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* redéfinition de la methode paintComponent
|
||||
* @param g
|
||||
*/
|
||||
public void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
|
||||
}
|
||||
// Couleur du fond = blanc
|
||||
this.setBackground(Color.black);
|
||||
//
|
||||
// // Affiche une ligne bleue en diagonale
|
||||
// g.setColor(Color.blue);
|
||||
// g.drawLine(0, 0, this.getWidth(), this.getHeight());
|
||||
|
||||
//essai quadrillage
|
||||
int width;
|
||||
int height;
|
||||
int x, y;
|
||||
width = this.getWidth();
|
||||
height = this.getHeight();
|
||||
x=0;
|
||||
y=0;
|
||||
while (y<height) {
|
||||
g.setColor(Color.magenta);
|
||||
g.drawLine(0, y, width, y);
|
||||
y= y + height/11;
|
||||
}
|
||||
while (x<width) {
|
||||
g.setColor(Color.magenta);
|
||||
g.drawLine(x, 0, x, height);
|
||||
x= x + width/11;
|
||||
}
|
||||
|
||||
// // Affiche un cercle noir au centre
|
||||
// g.setColor(Color.black);
|
||||
// g.drawOval( this.getWidth() / 2, this.getHeight() / 2, 10, 10);
|
||||
//
|
||||
// // Affiche un rectangle vide rouge
|
||||
// g.setColor(Color.red);
|
||||
// g.drawRect(100, 100, 20, 20);
|
||||
//
|
||||
// // Affiche un rectangle plein vert
|
||||
// g.setColor(Color.green);
|
||||
// g.fillRect(200, 50, 20, 20);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -5,10 +5,27 @@ import java.awt.EventQueue;
|
|||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import com.jgoodies.forms.layout.FormLayout;
|
||||
import com.jgoodies.forms.layout.ColumnSpec;
|
||||
import com.jgoodies.forms.layout.RowSpec;
|
||||
import com.jgoodies.forms.layout.FormSpecs;
|
||||
import java.awt.GridLayout;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.ImageIcon;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import javax.swing.JButton;
|
||||
import java.awt.GridBagLayout;
|
||||
import javax.swing.border.BevelBorder;
|
||||
import java.awt.Color;
|
||||
|
||||
|
||||
public class MaJFrame extends JFrame {
|
||||
|
||||
private JPanel contentPane;
|
||||
private static final long serialVersionUID = 7252959164975426293L;
|
||||
private JPanelDessin panel_1;
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
|
|
@ -33,12 +50,34 @@ public class MaJFrame extends JFrame {
|
|||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setBounds(100, 100, 450, 300);
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
contentPane.setBorder(new EmptyBorder(0, 0, 0, 0));
|
||||
|
||||
setContentPane(contentPane);
|
||||
contentPane.setLayout(new BorderLayout(0, 0));
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
contentPane.add(panel);
|
||||
contentPane.add(panel, "cell 10 10,grow");
|
||||
contentPane.add(panel, BorderLayout.NORTH);
|
||||
|
||||
JButton btnNewButton = new JButton("ah!");
|
||||
panel.add(btnNewButton);
|
||||
|
||||
panel_1 = new JPanelDessin();
|
||||
panel_1.setBackground(new Color(240, 240, 240));
|
||||
panel_1.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
|
||||
contentPane.add(panel_1, BorderLayout.CENTER);
|
||||
panel_1.setLayout(new GridLayout(1, 0, 0, 0));
|
||||
panel_1.setOpaque(false);
|
||||
|
||||
JPanelImage panel_2 = new JPanelImage("map1.png");
|
||||
contentPane.add(panel_2);
|
||||
panel_2.setLayout(new GridLayout(2, 1, 0, 0));
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue