Pourquoi ma frame est tout blanche???? - Java - Programmation
Marsh Posté le 11-12-2002 à 20:07:59
C'est bon juste un probleme de configuration de Runtime de JCreator ...
Mais quand j'importerai mes sources sous Linux, devrai-je faire une manip pour configurer ce Runtime pour lancer mon application ? Sous Unix on se casse moins la tête ?
@+
Shogun (ex-supporter de JBuil....)
Marsh Posté le 11-12-2002 à 20:11:06
Derniere question ....:ange:
ça sert a quoi le runtime ???
Marsh Posté le 11-12-2002 à 20:02:35
Voila le code
Frame.java
"import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Frame extends JFrame {
private JPanel contentPane;
private JPanel jPanel1 = new JPanel();
private JLabel jLabel1 = new JLabel();
private JPanel jPanel2 = new JPanel();
private JButton jButton1 = new JButton();
private JButton jButton2 = new JButton();
private JPanel jPanel3 = new JPanel();
private JButton jButton3 = new JButton();
private JPanel jPanel4 = new JPanel();
private JButton jButton4 = new JButton();
private JButton jButton5 = new JButton();
private JButton jButton6 = new JButton();
private JPanel jPanel5 = new JPanel();
private JButton jButton7 = new JButton();
private GridBagLayout gridBagLayout1 = new GridBagLayout();
private GridBagLayout gridBagLayout2 = new GridBagLayout();
private GridBagLayout gridBagLayout3 = new GridBagLayout();
private GridBagLayout gridBagLayout4 = new GridBagLayout();
private GridBagLayout gridBagLayout5 = new GridBagLayout();
public Frame() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
contentPane = (JPanel) this.getContentPane();
this.setSize(new Dimension(553, 435));
this.setTitle("GESTION" );
jPanel1.setLayout(gridBagLayout5);
jLabel1.setFont(new java.awt.Font("Dialog", 1, 14));
jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
jLabel1.setText("Bienvenue sur GESTION" );
jPanel2.setLayout(gridBagLayout1);
jPanel2.setFont(new java.awt.Font("Dialog", 1, 14));
jPanel2.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.blue), "x1" ));
jPanel3.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.blue), "x2" ));
jPanel3.setLayout(gridBagLayout4);
jPanel4.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.blue), "x3" ));
jPanel5.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.red), "x4" ));
jPanel5.setLayout(gridBagLayout3);
jPanel4.setLayout(gridBagLayout2);
jButton1.setText("xxxx" );
jButton2.setText("xxxxx" );
jButton3.setText("xxxx" );
jButton4.setText("xxxxx" );
jButton5.setText("xxxx" );
jButton6.setText("xxxxx" );
jButton7.setText("xxxx" );
jPanel1.add(jPanel2, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0
,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(18, 35, 26, 0), 0, 0));
jPanel2.add(jButton1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(18, 23, 0, 24), 33, -2));
jPanel2.add(jButton2, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(22, 23, 42, 24), 35, -2));
jPanel1.add(jPanel3, new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0
,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(16, 35, 82, 0), 0, 0));
jPanel3.add(jButton3, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 54, 8, 54), 0, 0));
jPanel1.add(jPanel4, new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0
,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(18, 53, 0, 26), 0, 0));
jPanel4.add(jButton5, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(22, 37, 0, 38), 32, 0));
jPanel4.add(jButton4, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(7, 37, 0, 38), 24, 0));
jPanel4.add(jButton6, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(22, 37, 26, 38), 10, 0));
jPanel1.add(jPanel5, new GridBagConstraints(1, 2, 1, 1, 1.0, 1.0
,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(16, 53, 82, 26), 0, 0));
jPanel5.add(jButton7, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 39, 10, 30), 18, -2));
jPanel1.add(jLabel1, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(18, 95, 0, 76), 208, 31));
contentPane.add(jPanel1, BorderLayout.CENTER);
}
//Overridden so we can exit when window is closed
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
}
}
Et Application.java
"import javax.swing.UIManager;
import java.awt.*;
public class Application {
private boolean packFrame = false;
public Application() {
Frame1 frame = new Frame1();
if (packFrame) {
frame.pack();
}
else {
frame.validate();
}
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = frame.getSize();
if (frameSize.height > screenSize.height) {
frameSize.height = screenSize.height;
}
if (frameSize.width > screenSize.width) {
frameSize.width = screenSize.width;
}
frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
frame.setVisible(true);
}
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch(Exception e) {
e.printStackTrace();
}
new Application();
}
}"
J'ai JDK 1.4.1 ...
Je vois pas trop d'où ça peut venir ...
Au fait g laisser tomber JBuilder car importer des librairies de 30meg... ça le fait pas