Java tutorial
/* * 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.github.skittishSloth.sportsCardsDb.catalogs.create; import com.github.skittishSloth.sportsCardsDb.catalogs.create.events.CancelCatalogCreateListener; import com.github.skittishSloth.sportsCardsDb.catalogs.create.events.CatalogNameChangedListener; import com.github.skittishSloth.sportsCardsDb.catalogs.create.events.CreateCatalogListener; import javax.swing.JPanel; import org.apache.commons.lang3.StringUtils; /** * * @author mcory */ public class CreateCatalogPanel extends JPanel implements CreateCatalogView { /** * Creates new form CreateCatalogPanel */ public CreateCatalogPanel() { initComponents(); } /** * 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() { jLabel1 = new javax.swing.JLabel(); nameField = new javax.swing.JTextField(); jLabel2 = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); descriptionArea = new javax.swing.JTextArea(); createBtn = new javax.swing.JButton(); cancelBtn = new javax.swing.JButton(); jLabel1.setText("Name:"); nameField.setColumns(20); nameField.setDoubleBuffered(true); jLabel2.setText("Description:"); descriptionArea.setColumns(20); descriptionArea.setRows(5); jScrollPane1.setViewportView(descriptionArea); createBtn.setText("Create"); cancelBtn.setText("Cancel"); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addGap(70, 70, 70).addComponent(createBtn) .addGap(18, 18, 18) .addComponent(cancelBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE) .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(nameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup().addComponent(jLabel2).addGap(0, 0, Short.MAX_VALUE)) .addComponent(jScrollPane1)).addContainerGap())); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1).addComponent(nameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel2) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(createBtn).addComponent(cancelBtn)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); }// </editor-fold>//GEN-END:initComponents // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton cancelBtn; private javax.swing.JButton createBtn; private javax.swing.JTextArea descriptionArea; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTextField nameField; // End of variables declaration//GEN-END:variables @Override public String getCatalogName() { return nameField.getText(); } @Override public String getDescription() { return descriptionArea.getText(); } @Override public void setCanCreate(final boolean canCreate) { createBtn.setEnabled(canCreate); } @Override public void setOnCreateClicked(final CreateCatalogListener listener) { createBtn.addActionListener(listener); } @Override public void setOnCancelClicked(final CancelCatalogCreateListener listener) { cancelBtn.addActionListener(listener); } @Override public void setOnNameChanged(final CatalogNameChangedListener listener) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }