Package view.panels

Source Code of view.panels.SearchResultView

package view.panels;

import java.awt.Dimension;

import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SpringLayout;

import model.array.SearchableObjectArray;
import model.movie.SearchableObject;
import view.buttons.SearchResultButton;
import view.layout.SpringUtilities;
import view.layout.VerticalLayout;
import controller.SearchController;

public class SearchResultView extends HistoryPanel {
  private static final long serialVersionUID = 3019686735681839928L;

  private JPanel container;
  private JScrollPane scroll;
  private SearchResultButton searchResultButton;
 
  public SearchResultView(int panelNumber, SearchController controller, SearchableObjectArray results) {
    super(panelNumber);
    setLayout(new SpringLayout());

    container = new JPanel(new VerticalLayout());
    scroll = new JScrollPane(container);
    scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
   
    for (SearchableObject r : results) {
      searchResultButton = new SearchResultButton(r);
      searchResultButton.addSearchResultPressedListener(controller);
      searchResultButton.setPreferredSize(new Dimension(520, 30));
     
      container.add(searchResultButton);
    }
   
    add(scroll);
    SpringUtilities.makeGrid(this, getComponentCount(), 1, 5, 5, 5, 5);
  }
}
TOP

Related Classes of view.panels.SearchResultView

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.