ImageIcon niet getoond

Status
Niet open voor verdere reacties.

Clemens Schalkw

Gebruiker
Lid geworden
5 dec 2007
Berichten
166
Ik heb een method "createHomePage()" waarin ik een ImageIcon heb staan.
Echter wordt de image niet getoond. Weet iemand wat ik fout doe ?
Voor de duidelijkheid heb ik de hele class maar even gepost.

Code:
import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;

/**
 *
 * @author Clemens Schalkwijk
 */

public class MainFrame {

    private JFrame mainFrame;
    private JPanel topPanel;
    private JTabbedPane tabbedPane;

    public MainFrame() {
        makeMainFrame();
    }

    public static void main(String[] args) {
        new MainFrame();
    }

    private final void makeMainFrame() {
        mainFrame = new JFrame("Condor CMR");
        mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        mainFrame.setLayout(new BorderLayout());

        mainFrame.add(makeTopPanel(), BorderLayout.CENTER);

        mainFrame.pack();
        mainFrame.setVisible(Boolean.TRUE);
    }

    private final JComponent makeTopPanel() {

        topPanel = new JPanel(new BorderLayout());

		tabbedPane = new JTabbedPane();
		tabbedPane.addTab( "Homepage", createHomePage() );
		tabbedPane.addTab( "Corporates", createCorporatePage() );
		tabbedPane.addTab( "Persons", createPersonPage() );
        tabbedPane.addTab( "Contact", createContactPage() );
		topPanel.add( tabbedPane, BorderLayout.CENTER );

        return topPanel;
    }

    public JComponent createHomePage() {
        JPanel pnl_homepage = new JPanel(new GridBagLayout());
        pnl_homepage.setBackground(Color.RED);
        GridBagConstraints cstr_homepage = new GridBagConstraints();
        cstr_homepage.fill = GridBagConstraints.HORIZONTAL;

        JLabel lbl_imageFrame = new JLabel();
        lbl_imageFrame.setBorder(LineBorder.createGrayLineBorder());
        ImageIcon logo = new ImageIcon("./images/logo.png");

        lbl_imageFrame.setIcon(logo);
        pnl_homepage.add(lbl_imageFrame, cstr_homepage);

        return pnl_homepage;
    }

    public JComponent createCorporatePage() {

        JPanel pnl_corporatePage = new JPanel(new GridBagLayout());
        pnl_corporatePage.setBackground(Color.BLUE);

        return pnl_corporatePage;
    }

    public JComponent createPersonPage() {

        JPanel pnl_personPage = new JPanel(new GridBagLayout());
        pnl_personPage.setBackground(Color.BLACK);

        return pnl_personPage;
    }

    public JComponent createContactPage() {

        JPanel pnl_contactPage = new JPanel(new GridBagLayout());
        pnl_contactPage.setBackground(Color.GREEN);

        return pnl_contactPage;
    }
}
 
Status
Niet open voor verdere reacties.

Nieuwste berichten

Terug
Bovenaan Onderaan