Chào các bạn,

Mình có 2 interface như sau:

SearchInterface => chứa giao diện dùng để truy tìm hình ảnh.

Mã:
/**
 * Write a description of class SearchInterface here.
 * 
 * @author Athina Ioannou 
 * @version 6/12/12
 */
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Random;
import javax.swing.*;
import com.aetrion.flickr.*;        // For FlickrJ classes.
import com.aetrion.flickr.photos.*;

public class SearchInterface extends JFrame implements ActionListener{
    private PhotoPanel pp;
    private String keyWord;
    private String photoUrl;
    private PhotoFinder pf;
    private Timer timer;
    private JButton btnStart;
    private JButton btnExit;
    private JLabel lblSearch;
    private JTextField txtSearch;
    private Container contentPane;
    private ArrayList<Photo> photoList;
    private String originalKeyWord, oldKeyWord;
    /**
     * Creates new form SearchInterface
     */
    public SearchInterface() {
        
        super("Flickr Stream");
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        setPreferredSize(new Dimension(500, 300));
        contentPane = this.getContentPane();
        pf = new PhotoFinder();
        photoList = new ArrayList<Photo>();
        originalKeyWord = "";
        oldKeyWord = "";
        //titles = new ArrayList<String>();
        timer = new Timer(1000, this);
        init();
        this.pack();
        this.setVisible(true);
    }

    
    @Override
    public void actionPerformed(ActionEvent e) 
    {
        
        if (e.getSource() == btnExit)
        {
            System.exit(0);
        }
        if (e.getSource() == btnStart)
        {
            if (timer.isRunning())
            {
                timer.stop();
            }
            keyWord = txtSearch.getText();
            originalKeyWord = keyWord;
            oldKeyWord = keyWord;
            timer.start();
        }
        else
        {
            if (keyWord != null)
           {
               Random r = new Random();
                photoList.clear();
                
                photoList = pf.doQuery(keyWord);
                int i = r.nextInt(photoList.size());
                pp.setImage(photoList.get(i).getSmallUrl());
                keyWord = photoList.get(i).getTitle();
                Iterator it = photoList.iterator();
                while (keyWord.equals("")) 
                {
                    Photo p = (Photo)it.next();
                    keyWord = p.getTitle();
                }
               // if (oldKeyWord.equals(keyWord))
                //{
                   // keyWord = originalKeyWord;
                   // }
                //oldKeyWord = keyWord;
                keyWord = originalKeyWord;
                {
                     //int num = photoList.size();
                //for (int k=1; k< num; k++)
                pp.repaint();
            }
            System.out.println(keyWord);
        }}
    }
    
    public void init(){
        pp = new PhotoPanel();
        JPanel wG = new JPanel();
        wG.setLayout(new FlowLayout());
        lblSearch = new JLabel("Search");
        txtSearch = new JTextField(20);
        btnStart = new JButton("Start");
       btnExit  = new JButton("Exit");
       btnStart.addActionListener(this);
       btnExit.addActionListener(this);
       wG.add(lblSearch);
        wG.add(txtSearch);
        wG.add(btnStart);
        wG.add(btnExit);
        contentPane.add(wG, BorderLayout.NORTH);
        contentPane.add(pp, BorderLayout.CENTER);
        
        
    }
    
    
}
UserInterface => dùng để trình bày giao diện và tương tác với các menu, sub-menu

Mã:
/**
 * This class contains all interfaces and some event handling functions
 * 
 * @author Hung Vu Pham
 * @version 1, 3/12/2012
 * @version 2, 5/12/2012
 */

import java.awt.*;
import java.awt.event.*;

import javax.swing.*;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JMenuBar;
import javax.swing.KeyStroke;
import javax.swing.ImageIcon;
import javax.swing.JPanel;

import java.util.*;
import java.io.*; //for writing and reading file

public class UserInterface extends JFrame implements ActionListener
{
/**
 * @param Declaring all components for user interface
 * @param Firslty, to declare components of menu such as
 * @param JMenuBar to create a menu bar
 * @param JMenu to create a menu on the menu bar such as menu File.
 * @param JMenuItem to create a submenu of the menu such as fExit is a submenu of menu File.
*/    
    private JMenuBar menuBar;
    private JMenu file, menu, help;
    private JMenuItem fExit, mUpload, mRecentPhoto, mSearch, hGuide, hAuthor;
    private JPanel upperPanel, centerPanel, InforPanel,imgPanel, recentPhotoPanel, searchPhotoPanel;
    private JLabel welcome, lWelcome, lAbout, recentPhotoTitle, searchTitle;
    
    ImageIcon iWelcome = new ImageIcon("IMAGE/flickr.jpg", "Flickr Image");
    ImageIcon iAbout = new ImageIcon("IMAGE/FairyTail.jpg", "Fairy Tail Team");
    
    public UserInterface ()
    {
        
        //Add regular components to the window, using the default BorderLayout.
        Container contentPane = getContentPane(); //the app window        
        // create upper panel to hold menu bar on the top of interface
        upperPanel = new JPanel();
        contentPane.add(upperPanel, BorderLayout.NORTH);
        upperPanel.setLayout(new BorderLayout());
        // Create menu bar to hold menus and submenus
        menuBar = new JMenuBar();
        //add menu bar to the top of interface
        upperPanel.add(menuBar);      
            
        // Build File menu and its short-cut key
        file = new JMenu ("File");        
        file.setMnemonic(KeyEvent.VK_F);
        file.getAccessibleContext().setAccessibleDescription(
            "File related operations");
        // Create a submenu for File menu and ist short-cut key
        fExit = new JMenuItem ("Exit", KeyEvent.VK_E);
        fExit.addActionListener(this);
        // add components of File menu
        menuBar.add(file);
        file.add(fExit);
        
        // Build  Menu menu and its short-cut key
        menu = new JMenu ("Menu");        
        menu.setMnemonic(KeyEvent.VK_M);
        menu.getAccessibleContext().setAccessibleDescription(
            "Menu related operations");
        // Create submenus for Menu menu and its short-cut key
        mRecentPhoto = new JMenuItem ("Check Recent Photos", KeyEvent.VK_C);
        mSearch = new JMenuItem ("Search Photos", KeyEvent.VK_S);
        // add components of File menu
        menuBar.add(menu);
        menu.add(mRecentPhoto);
        mRecentPhoto.addActionListener(this);
        menu.addSeparator();
        menu.add(mSearch);
        mSearch.addActionListener(this);
        
        // Build  Help Menu and its short-cut key
        help = new JMenu ("Help");     
        help.setMnemonic(KeyEvent.VK_H);
        help.getAccessibleContext().setAccessibleDescription(
            "Help related operations");
        // Create submenus for Help Menu and their short-cut key
        hGuide = new JMenuItem ("Short-Cut Key Guide", KeyEvent.VK_S);
        hAuthor = new JMenuItem ("About Us", KeyEvent.VK_A);
        // add components of help menu
        menuBar.add(help);
        help.add(hGuide);
        hGuide.addActionListener(this);
        help.addSeparator();
        help.add(hAuthor); 
        hAuthor.addActionListener(this);
        
        // Build Center Panel which is stayed in the center of interface.
        centerPanel = new JPanel();
        centerPanel.setLayout (new FlowLayout());
        contentPane.add(centerPanel, BorderLayout.CENTER);      
        
        // Build Infor Panel and display Image and Text.
        InforPanel = new JPanel();
        InforPanel.setLayout (new BorderLayout());
        centerPanel.add(InforPanel);
        // Build components for Infor Panel
        welcome = new JLabel ("Welcome to Java Flickr Application", JLabel.CENTER);
        InforPanel.add(welcome, BorderLayout.NORTH );
        lWelcome = new JLabel (iWelcome);   
        InforPanel.add(lWelcome);
        
        //Build recent Photo Panel to display most recent photos
        recentPhotoPanel = new JPanel();
        recentPhotoPanel.setLayout (new BorderLayout());
        recentPhotoPanel.setVisible(false);
        recentPhotoTitle = new JLabel ("Most Recent Photos on Flickr");
        recentPhotoPanel.add(recentPhotoTitle);
        centerPanel.add(recentPhotoPanel);
        
        //Build Search Panel to display area where user can search photos with a keyword
        searchPhotoPanel = new JPanel ();
        searchPhotoPanel.setLayout (new BorderLayout());
        searchPhotoPanel.setVisible(false);
        searchTitle = new JLabel ("Welcome to Search Area");
        searchPhotoPanel.add(searchTitle);
        centerPanel.add(searchPhotoPanel);
    }
    
    public static void main (String arg[])
    {
        UserInterface userFace = new UserInterface ();
        userFace.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        userFace.setTitle("Java Flickr Application");
        userFace.setSize(800,600);
        userFace.setVisible(true);
    }
    
    public void actionPerformed(ActionEvent e) 
    { 
        JMenuItem source = (JMenuItem)(e.getSource());
        //If user selects "Short-cut Key Guide" sub-menu, a dialog will be shown
        if (source.equals(hGuide))
        {
                
                        JOptionPane.showMessageDialog( UserInterface.this,
                        "Select appropriate menu option that you want from Java Flickr Application
" +
                        "User should navigate to menu before submenu
" +
                        "Alt + F => select File menu 
" +
                        "Alt + E => select Exit submenu 
" +
                        "Alt + M => select Menu menu 
" +
                        "Alt + C => select Check Recent Photos submenu 
" +
                        "Alt + S => select Search submenu 
" +
                        "Alt + H => select Help menu 
" +
                        "Alt + S => select Short-cut Key Guide submenu 
" +
                        "Alt + A => select About Us submenu 
" ,
                        "Help Contents", JOptionPane.PLAIN_MESSAGE);
                
        }
        //If user selects "About Us" sub-menu, a dialog will be shown
        if (source.equals(hAuthor))
        {
            JOptionPane.showMessageDialog( UserInterface.this,
                        "Java Flickr Application is created by Fairy Tail Group 

" +
                        "Hung Vu Pham

" +
                        "Jennifer Naiaretti

" +
                        "Panagiota Tzana

" + 
                        "Athina Ioannou",
                        "About Us", JOptionPane.PLAIN_MESSAGE, iAbout);
        }
        //If user selects "Check Recent Photos" sub-menu, a panel to retrieve all photos from Flickr and display photos 
        if (source.equals(mRecentPhoto))
        {
            InforPanel.setVisible(false);
            searchPhotoPanel.setVisible(false);
            recentPhotoPanel.setVisible(true);
            // functions to retrieve most recent photos on Flickr will be display below
        }
        //If user selects "Search Photos" sub-menu, a panel to help user search photos on Flickr with specific keyword
        //This panel also contains all photo after searching.
        if (source.equals(mSearch))
        {
            InforPanel.setVisible(false);
            recentPhotoPanel.setVisible(false);
            searchPhotoPanel.setVisible(true);
            // functions to search photos with specific keyword on Flickr will be display below
        }
        //If "Exit" sub-menu is selected, a window closes.
        if (source.equals(fExit))
        {
            dispose();
            System.exit(0);
        }
    }
}
PhotoPanel => dùng để hiển thị hình ảnh từ website Flickr.


https://www.dropbox.com/s/715u81j3yv...otoFinder.java
PhotoFinder => dùng để kết nối đến Flickr.


https://www.dropbox.com/s/tc9l7nwx5s...hotoPanel.java
giao diện UserInterface



giao diện SearchInterface



Khó khăn của mình là h ko nhồi nhét đc thằng SearchInterface vào trong UserInterface đc ???
Textfield và 2 nút button Start và Exit trong SearchInterface ko hiển thị trong UserInterface, ko những thế, label của searchPhotoPanel nằm trong UserInterface cũng mất tiêu.

bạn nào có thể cho mình giải pháp đc ko ????

cám ơn rất nhiều.