All Downloads are FREE. Search and download functionalities are using the official Maven repository.

bc.ui.swing.lists.GridList Maven / Gradle / Ivy

The newest version!
/* 
 * The MIT License
 *
 * Copyright 2016 Benny Lutati.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package bc.ui.swing.lists;

import bc.ui.swing.visuals.Visual;
import java.awt.GridLayout;
import java.util.LinkedList;
import java.util.List;

/**
 *
 * @author bennyl
 */
public class GridList extends javax.swing.JPanel {

    GridLayout grid;
    ComponentBuilder cbuild = new ComponentBuilder.DefaultComponentBuilder();
    
    /** Creates new form GridList */
    public GridList() {
        initComponents();
        grid = (GridLayout) content.getLayout();
    }

    public ComponentBuilder getComponentBuilder() {
        return cbuild;
    }

    public void setComponentBuilder(ComponentBuilder cbuild) {
        this.cbuild = cbuild;
    }
    
    public void setVgap(int vgap) {
        grid.setVgap(vgap);
    }

    public void setHgap(int hgap) {
        grid.setHgap(hgap);
    }

    public void setColumns(int cols) {
        grid.setColumns(cols);
    }

    public int getVgap() {
        return grid.getVgap();
    }

    public int getRows() {
        return grid.getRows();
    }

    public int getHgap() {
        return grid.getHgap();
    }

    public int getColumns() {
        return grid.getColumns();
    }

    public void setItems(List items){
        content.removeAll();
        content.setVisible(false);
        for (Visual item : items){
            content.add(cbuild.build(item));
        }
        content.setVisible(true);
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // //GEN-BEGIN:initComponents
    private void initComponents() {

        scroll = new javax.swing.JScrollPane();
        content = new javax.swing.JPanel();

        setOpaque(false);
        setLayout(new java.awt.BorderLayout());

        scroll.setBorder(null);
        scroll.setOpaque(false);

        content.setLayout(new java.awt.GridLayout());
        scroll.setViewportView(content);

        add(scroll, java.awt.BorderLayout.CENTER);
    }// //GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel content;
    private javax.swing.JScrollPane scroll;
    // End of variables declaration//GEN-END:variables
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy