com.ihhira.projects.badgemaker.Badge.java Source code

Java tutorial

Introduction

Here is the source code for com.ihhira.projects.badgemaker.Badge.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ihhira.projects.badgemaker;

import javax.swing.BorderFactory;
import org.apache.poi.ss.usermodel.Row;

/**
 *
 * @author ihhira
 */
public class Badge extends javax.swing.JPanel {

    /**
     * Creates new form Badge
     */
    public Badge() {
        initComponents();
        jScrollPane1.setBorder(BorderFactory.createEmptyBorder());
    }

    /**
     * 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")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        attendeeName = new javax.swing.JLabel();
        attendeePosition = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        attendeeCompany = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        attendeeInterest = new javax.swing.JTextArea();
        actualName = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();

        setBackground(new java.awt.Color(255, 255, 255));
        setBorder(new javax.swing.border.LineBorder(new java.awt.Color(240, 240, 240), 1, true));
        setMaximumSize(new java.awt.Dimension(300, 400));

        attendeeName.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        attendeeName.setText("Name");

        attendeePosition.setText("position");

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel1.setText("JUGBD Meetup 5.0");

        attendeeCompany.setText("Company");

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel2.setText("Interests:");

        attendeeInterest.setColumns(20);
        attendeeInterest.setFont(new java.awt.Font("Monospaced", 0, 18)); // NOI18N
        attendeeInterest.setLineWrap(true);
        attendeeInterest.setRows(5);
        attendeeInterest.setText("Spring, Hibernate");
        attendeeInterest.setWrapStyleWord(true);
        attendeeInterest.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        attendeeInterest.setMaximumSize(new java.awt.Dimension(300, 400));
        jScrollPane1.setViewportView(attendeeInterest);

        actualName.setFont(new java.awt.Font("Tahoma", 0, 8)); // NOI18N
        actualName.setText("jLabel3");

        jLabel3.setText("Hosted by Kona Software Lab Ltd.");

        jLabel4.setFont(new java.awt.Font("Tahoma", 0, 5)); // NOI18N
        jLabel4.setText("Badge made by - https://github.com/imranhasanhira/BadgeMaker");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                .addGroup(layout.createSequentialGroup().addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(attendeeName, javax.swing.GroupLayout.Alignment.LEADING,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        Short.MAX_VALUE)
                                .addComponent(actualName, javax.swing.GroupLayout.Alignment.LEADING,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        Short.MAX_VALUE)
                                .addComponent(attendeePosition, javax.swing.GroupLayout.Alignment.LEADING,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        Short.MAX_VALUE)
                                .addComponent(attendeeCompany, javax.swing.GroupLayout.Alignment.LEADING,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        Short.MAX_VALUE)
                                .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, 241, Short.MAX_VALUE)
                                .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING,
                                        javax.swing.GroupLayout.PREFERRED_SIZE, 224,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup().addContainerGap().addComponent(attendeeName)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(actualName)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(attendeePosition)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(attendeeCompany)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18).addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 17, Short.MAX_VALUE)
                        .addComponent(jLabel3).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel4).addGap(13, 13, 13)));
    }// </editor-fold>//GEN-END:initComponents

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel actualName;
    private javax.swing.JLabel attendeeCompany;
    private javax.swing.JTextArea attendeeInterest;
    private javax.swing.JLabel attendeeName;
    private javax.swing.JLabel attendeePosition;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JScrollPane jScrollPane1;
    // End of variables declaration//GEN-END:variables

    void setData(Row row) {
        attendeeName.setText(row.getCell(12).toString());
        attendeePosition.setText(row.getCell(20).toString());
        attendeeCompany.setText(row.getCell(21).toString());

        String interests = row.getCell(11).toString();
        attendeeInterest.setText(interests);

        actualName.setText(row.getCell(1) + " " + row.getCell(2));

    }
}