Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    non si vedono gli elementi nel frame

    questo è il codice del mio programma:
    public static void main(String[] args){
    Mastermind frame = new Mastermind();
    frame.setVisible(true);

    }
    // Componenti del main
    public Mastermind(){
    super();
    Grafica();
    iniziotime();
    }

    public void Grafica(){
    try {
    setDefaultCloseOperation(WindowConstants.DISPOSE_O N_CLOSE);
    BoxLayout thisLayout = new BoxLayout(getContentPane(),javax.swing.BoxLayout.X _AXIS);
    getContentPane().setLayout(thisLayout);
    this.setTitle("Progetto di Programmazione Internet A.A. 2005/2006 - Master Mind");
    getContentPane().setBackground(new java.awt.Color(51,102,204));
    {
    PannelloPrincipale = new JPanel();
    BorderLayout PannelloPrincipaleLayout = new BorderLayout();
    PannelloPrincipale.setLayout(PannelloPrincipaleLay out);
    getContentPane().add(PannelloPrincipale);

    {
    PulsantiGioco = new JPanel();
    PannelloPrincipale.add(PulsantiGioco, BorderLayout.SOUTH);
    GridLayout PulsantiGiocoLayout = new GridLayout(1,3);
    PulsantiGiocoLayout.setVgap(20);
    PulsantiGioco.setLayout(PulsantiGiocoLayout);
    PulsantiGioco.setPreferredSize(new java.awt.Dimension(300, 100));
    PulsantiGioco.setBackground(new java.awt.Color(51,102,204));
    {
    newgame_button = new JButton ("Nuova Partita");
    newgame_button.addMouseListener(new MouseAdapter() {
    public void mouseClicked(MouseEvent evt) {
    System.out.println("Nuova Partita");
    }
    });
    }

    {
    spia_button = new JButton ("Spia");
    spia_button.addMouseListener(new MouseAdapter() {
    public void mouseClicked(MouseEvent evt) {
    System.out.println("Nuova Partita");
    }
    });
    }

    {
    rank_button = new JButton ("Classifica");
    rank_button.addMouseListener(new MouseAdapter() {
    public void mouseClicked(MouseEvent evt) {
    System.out.println("Nuova Partita");
    }
    });
    }
    }

    {
    Tavolozza = new JPanel();
    PannelloPrincipale.add(Tavolozza, BorderLayout.WEST);
    Tavolozza.setLayout(new GridLayout (4 , 1));
    Tavolozza.setPreferredSize(new Dimension (100, 45));
    Tavolozza.setBackground(new java.awt.Color(51,102,204));
    {
    buttonPanel1 = new JPanel();
    buttonPanel1.setPreferredSize (new Dimension(100, 45));
    buttonPanel1.setBackground(new java.awt.Color(51,102,204));

    {
    blulabel = new JLabel (blue);
    blulabel.addMouseListener(new MouseAdapter(){
    public void mouseClicked(MouseEvent evt){
    colorlabel.setIcon(new ImageIcon(getClass().getClassLoader().getResource( "blu.gif")));
    colorselect = "blu.gif";
    }
    });
    }
    {
    blacklabel = new JLabel (black);
    blacklabel.addMouseListener(new MouseAdapter(){
    public void mouseClicked(MouseEvent evt){
    colorlabel.setIcon(new ImageIcon(getClass().getClassLoader().getResource( "black.gif")));
    colorselect = "black.gif";
    }
    });
    }
    }

    {
    buttonPanel2 = new JPanel();
    buttonPanel2.setPreferredSize (new Dimension(100, 45));
    buttonPanel2.setBackground(new java.awt.Color(51,102,204));

    {
    yellowlabel = new JLabel (yellow);
    yellowlabel.addMouseListener(new MouseAdapter(){
    public void mouseClicked(MouseEvent evt){
    colorlabel.setIcon(new ImageIcon(getClass().getClassLoader().getResource( "yellow.gif")));
    colorselect = "yellow.gif";
    }
    });
    }

    {
    redlabel = new JLabel (red);
    redlabel.addMouseListener(new MouseAdapter(){
    public void mouseClicked(MouseEvent evt){
    colorlabel.setIcon(new ImageIcon(getClass().getClassLoader().getResource( "red.gif")));
    colorselect = "red.gif";
    }
    });
    }
    }

    {
    buttonPanel3 = new JPanel();
    buttonPanel3.setPreferredSize (new Dimension(100, 45));
    buttonPanel3.setBackground(new java.awt.Color(51,102,204));

    {
    greenlabel = new JLabel (green);
    greenlabel.addMouseListener(new MouseAdapter(){
    public void mouseClicked(MouseEvent evt){
    colorlabel.setIcon(new ImageIcon(getClass().getClassLoader().getResource( "green.gif")));
    colorselect = "green.gif";
    }
    });
    }

    {
    orangelabel = new JLabel (orange);
    orangelabel.addMouseListener(new MouseAdapter(){
    public void mouseClicked(MouseEvent evt){
    colorlabel.setIcon(new ImageIcon(getClass().getClassLoader().getResource( "orange.gif")));
    colorselect = "orange.gif";
    }
    });
    }
    }

    {
    colorlabel = new JLabel (yellow);
    colorlabel.setPreferredSize (new Dimension (100, 45));
    }
    }


    {
    Soluzione = new JPanel();
    Soluzione.setPreferredSize (new Dimension(200, 50));
    PannelloPrincipale.add(Soluzione, BorderLayout.NORTH);

    {
    s1label = new JLabel (gray);
    s1label.setPreferredSize(new Dimension (40, 40));
    }
    {
    s2label = new JLabel (gray);
    s2label.setPreferredSize(new Dimension (40, 40));
    }
    {
    s3label = new JLabel (gray);
    s3label.setPreferredSize(new Dimension (40, 40));
    }
    {
    s4label = new JLabel (gray);
    s4label.setPreferredSize(new Dimension (40, 40));
    }
    }
    }
    pack();
    this.setSize(600, 600);
    } catch (Exception e)
    {
    e.printStackTrace();
    }
    }
    il risultato è questo.

    qualcuno può darmi una mano a risolvere il problema??

  2. #2
    prova a seguire il mio ultimo consiglio in questo thread.

    ciao

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.