Visualizzazione dei risultati da 1 a 3 su 3
  1. #1
    Utente di HTML.it L'avatar di MOBILUK
    Registrato dal
    Apr 2001
    Messaggi
    225

    [JAVA] Swing: dov'č l'errore?

    quando compilo il seguente codice mi da gli errori vesualizzati nell'allegato

    codice:
    import javax.swing.*;
    import java.awt.*;
    
    public class Application extends JFrame
    {
    public Application()
    {
    JLabel label = new JLabel("Welcome!");
    label.setBorder(BorderFactory.createLineBorder(Color.red));
    
    JLabel labelIcon = new JLabel(new ImageIcon("img.jpe"));
    labelIcon.setBorder(BorderFactory.createLineBorder(Color.blue));
    
    JButton try = new JButton("TRY");
    
    JPanel northPanel = new JPanel();
    northPanel.setLayout(new GridLayout(1,0));
    northPanel.setBorder(BorderFactory.createEmptyBorder(10,4,10,4));
    northPanel.add(label);
    
    JPanel centralPanel = new JPanel();
    centralPanel.setLayout(new BorderLayout());
    centralPanel.setBorder(BorderFactory.createEmptyBorder(3,4,3,4));
    centralPanel.add(BorderLayout.Center,labelIcon);
    
    JPanel southPanel = new JPanel();
    southPanel.setLayout(new BorderLayout());
    southPanel.setBorder(BorderFactory.createEmptyBorder(3,4,3,4));
    southPanel.add(BorderLayout.CENTER,try);
    
    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(BorderLayout.NORTH,northPanel);
    getContentPane().add(BorderLayout.CENTER,centralPanel);
    getContentPane().add(BorderLayout.SOUTH,southPanel);
    pack();
    setVisible(true);
    }
    public static void main (String argv[])
    {
    Application ap = new Application();
    }
    
    }
    qualcuno di voi sa dirmi dov'č che sbaglio?

    grazie
    Immagini allegate Immagini allegate
    ...credi sia aria quella che stai respirando?

  2. #2
    Utente di HTML.it L'avatar di floyd
    Registrato dal
    Apr 2001
    Messaggi
    3,837
    1 non usare try come nome, javac lo interpreta come try catch
    2 BorderLayout.CENTER e non Center

  3. #3
    Utente di HTML.it L'avatar di MOBILUK
    Registrato dal
    Apr 2001
    Messaggi
    225
    grazie 1000 floyd!!

    ora compila correttamente!
    ...credi sia aria quella che stai respirando?

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.