Répondre à la discussion

Code Java :

[code]// MyTest.java test class for JNI experimentation

// example 2

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.SwingUtilities;


public class MyTest2 {

  

    public static class Starter implements Runnable {

        public void run() {

            System.out.println("Runnning on AWT Queue.");

          

            JFrame.setDefaultLookAndFeelDecorated(true);

            JFrame frame = new JFrame("That's a frame!");

            frame.setSize(400, 200);

            JLabel label = new JLabel("A Label");

            frame.getContentPane().add(label);

            frame.setLocationRelativeTo(null);

            //Termine le processus lorsqu'on clique sur la croix rouge

            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

            //frame.pack();

            frame.setVisible(true);

          

            //JButton button;

            //JPanel panel;

          

            // my error lines are under the "panel" and  "button"

            // it says i must implement the variables. what does that mean???

            //panel.add(button);

        }

    }

  

    public static class GUI implements Runnable {

        public void run() {

            try {

                System.out.println("Going to put something on the AWT queue.");

                SwingUtilities.invokeAndWait(new Starter());

                System.out.println("2.");

            } catch (Exception exc) {

                throw new RuntimeException(exc);

            }

        }

    }

  

    public static void run() {

        Thread gui = new Thread(new GUI());

        gui.start();

    }

}

[/code]