[ubuntu-it] Problemi su ubuntu jaunty 9.04 con java.awt

alessio rainieri alessiorainieri a gmail.com
Mer 14 Ott 2009 08:21:21 BST


Questo semplice programma non mi funziona ( ho provato su due PC con ubuntu
jaunty 9.04 ), su Windows invece si.

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.peer.*;

public class ButtonTest {

   public static void main (String[] args){

      ButtonFrame frame = new ButtonFrame();
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setVisible(true);
   }

}

class ButtonFrame extends JFrame {

   /**
    *
    */
   private static final long serialVersionUID = 1L;
   public ButtonFrame(){

      setTitle("Button Test");
      setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);

      Container contentPane = getContentPane();
      ButtonPanel panel = new ButtonPanel();
      contentPane.add(panel);
   }

   public static final int DEFAULT_WIDTH=300;
   public static final int DEFAULT_HEIGHT=200;
}

class ButtonPanel extends JPanel
  {

   /**
    *
    */
   private static final long serialVersionUID = 1L;
   JButton yellowButton = new JButton("Yellowq");
   JButton redButton = new JButton("Red");
   JButton greenButton = new JButton("Green");

   public ButtonPanel() {

      add(yellowButton);
      add(redButton);
      add(greenButton);

      yellowButton.addActionListener(new ActionListener(){
         public void actionPerformed(ActionEvent event){
            setBackground(Color.YELLOW);
         }
      });

      redButton.addActionListener(new ActionListener(){
         public void actionPerformed(ActionEvent event){
            setBackground(Color.RED);
         }
      });

      greenButton.addActionListener(new ActionListener(){
         public void actionPerformed(ActionEvent event){
            setBackground(Color.GREEN);
         }
      });

   }

}
-------------- parte successiva --------------
Un allegato HTML è stato rimosso...
URL: https://lists.ubuntu.com/archives/ubuntu-it/attachments/20091014/16bef75d/attachment.htm 


Maggiori informazioni sulla lista ubuntu-it