コード例 #1
0
ファイル: Misc.java プロジェクト: BackupTheBerlios/freejsm
 public static java.awt.Image loadImageFromFile(String path) {
   java.io.File file = new java.io.File(path);
   if (file.exists()) {
     java.awt.Toolkit tk = java.awt.Toolkit.getDefaultToolkit();
     java.awt.Image img = tk.createImage(path);
     try {
       java.awt.MediaTracker mt = new java.awt.MediaTracker(new javax.swing.JPanel());
       mt.addImage(img, 0);
       mt.waitForID(0);
     } catch (Exception ex) {
       return null;
     }
     return img;
   }
   return null;
 }
コード例 #2
0
  /**
   * This method is called from within the constructor to initialize the form. WARNING: Do NOT
   * modify this code. The content of this method is always regenerated by the FormEditor.
   */
  private void initComponents() { // GEN-BEGIN:initComponents
    label1 = new java.awt.Label();
    panel1 = new java.awt.Panel();
    label2 = new java.awt.Label();
    textField1 = new java.awt.TextField();
    label3 = new java.awt.Label();
    textField2 = new java.awt.TextField();
    button1 = new java.awt.Button();
    button2 = new java.awt.Button();
    addWindowListener(
        new java.awt.event.WindowAdapter() {
          public void windowClosing(java.awt.event.WindowEvent evt) {
            exitForm(evt);
          }
        });

    label1.setFont(new java.awt.Font("Dialog", 0, 11));
    label1.setBackground(new java.awt.Color(204, 204, 204));
    label1.setForeground(java.awt.Color.black);
    label1.setText("Rent Apartment Out");
    label1.setAlignment(java.awt.Label.CENTER);

    add(label1, java.awt.BorderLayout.NORTH);

    panel1.setLayout(new java.awt.GridLayout(3, 2));
    panel1.setFont(new java.awt.Font("Dialog", 0, 11));
    panel1.setName("panel23");
    panel1.setBackground(new java.awt.Color(204, 204, 204));
    panel1.setForeground(java.awt.Color.black);

    label2.setFont(new java.awt.Font("Dialog", 0, 11));
    label2.setBackground(new java.awt.Color(204, 204, 204));
    label2.setForeground(java.awt.Color.black);
    label2.setText("Customer #");
    panel1.add(label2);

    textField1.setBackground(java.awt.Color.white);
    textField1.setName("textfield20");
    textField1.setFont(new java.awt.Font("Dialog", 0, 11));
    textField1.setForeground(java.awt.Color.black);
    panel1.add(textField1);

    label3.setFont(new java.awt.Font("Dialog", 0, 11));
    label3.setBackground(new java.awt.Color(204, 204, 204));
    label3.setForeground(java.awt.Color.black);
    label3.setText("Apartment #");
    panel1.add(label3);

    textField2.setBackground(java.awt.Color.white);
    textField2.setName("textfield21");
    textField2.setFont(new java.awt.Font("Dialog", 0, 11));
    textField2.setForeground(java.awt.Color.black);
    panel1.add(textField2);

    button1.setFont(new java.awt.Font("Dialog", 0, 11));
    button1.setLabel("Rent it");
    button1.setName("button31");
    button1.setBackground(java.awt.Color.lightGray);
    button1.setForeground(java.awt.Color.black);
    button1.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            button1ActionPerformed(evt);
          }
        });
    panel1.add(button1);

    button2.setFont(new java.awt.Font("Dialog", 0, 11));
    button2.setLabel("Cancel");
    button2.setName("button32");
    button2.setBackground(java.awt.Color.lightGray);
    button2.setForeground(java.awt.Color.black);
    button2.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            button2ActionPerformed(evt);
          }
        });
    panel1.add(button2);

    add(panel1, java.awt.BorderLayout.CENTER);
    java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    java.awt.Dimension dialogSize = getSize();
    setSize(new java.awt.Dimension(300, 200));
    setLocation((screenSize.width - 300) / 2, (screenSize.height - 200) / 2);
  } // GEN-END:initComponents
コード例 #3
0
  /**
   * This method is called from within the constructor to initialize the form. WARNING: Do NOT
   * modify this code. The content of this method is always regenerated by the Form Editor.
   */
  private void initComponents() { // GEN-BEGIN:initComponents
    labelDestinataire = new javax.swing.JLabel();
    textIndDestinataire = new javax.swing.JTextField();
    textMessage = new javax.swing.JTextArea();
    labelObjet = new javax.swing.JLabel();
    textIndObjet = new javax.swing.JTextField();
    buttonCancel = new javax.swing.JButton();
    buttonOK = new javax.swing.JButton();

    getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    setResizable(false);
    labelDestinataire.setText("label");
    getContentPane()
        .add(labelDestinataire, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 20, 50, -1));

    textIndDestinataire.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0)));
    getContentPane()
        .add(
            textIndDestinataire,
            new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 20, 360, -1));

    textMessage.setLineWrap(true);
    textMessage.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0)));
    getContentPane()
        .add(textMessage, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 60, 360, 230));

    labelObjet.setText("label");
    getContentPane()
        .add(labelObjet, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 40, 50, -1));

    textIndObjet.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0)));
    getContentPane()
        .add(textIndObjet, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 40, 360, -1));

    buttonCancel.setText("Annuler");
    buttonCancel.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            buttonCancelActionPerformed(evt);
          }
        });

    getContentPane()
        .add(buttonCancel, new org.netbeans.lib.awtextra.AbsoluteConstraints(270, 300, -1, -1));

    buttonOK.setText("jButton1");
    buttonOK.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            buttonOKActionPerformed(evt);
          }
        });

    getContentPane()
        .add(buttonOK, new org.netbeans.lib.awtextra.AbsoluteConstraints(180, 300, -1, -1));

    java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    setBounds((screenSize.width - 494) / 2, (screenSize.height - 400) / 2, 494, 400);
  } // GEN-END:initComponents
コード例 #4
0
ファイル: Misc.java プロジェクト: BackupTheBerlios/freejsm
 public static void centerFrame(java.awt.Component c) {
   java.awt.Toolkit tk = java.awt.Toolkit.getDefaultToolkit();
   c.setLocation(
       (int) ((tk.getScreenSize().getWidth() - c.getWidth()) / 2),
       (int) ((tk.getScreenSize().getHeight() - c.getHeight()) / 2));
 }