/**
* Copyright 2014 Jason Sorensen (sorensenj@smert.net)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package net.smert.frameworkgl.examples;
import javax.swing.AbstractListModel;
/**
* A JFrame with a JList to select an example and a JButton to execute.
*
* @author Jason Sorensen <sorensenj@smert.net>
*/
public class JFrameMainView extends javax.swing.JFrame {
private final JFrameMainController jFrameMainController;
/**
* Creates new form JFrameMainView
*
* @param jFrameMainController
*/
public JFrameMainView(JFrameMainController jFrameMainController) {
this.jFrameMainController = jFrameMainController;
initComponents();
}
public void setListModel(AbstractListModel listModel) {
jListMainClasses.setModel(listModel);
}
/**
* 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() {
jScrollPaneMainClasses = new javax.swing.JScrollPane();
jListMainClasses = new javax.swing.JList();
jButtonRunExample = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
setName("frameMain"); // NOI18N
setResizable(false);
jListMainClasses.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
jScrollPaneMainClasses.setViewportView(jListMainClasses);
jButtonRunExample.setText("Run Example");
jButtonRunExample.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonRunExampleActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jScrollPaneMainClasses, javax.swing.GroupLayout.DEFAULT_SIZE, 580, Short.MAX_VALUE)
.addComponent(jButtonRunExample))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPaneMainClasses, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jButtonRunExample)
.addContainerGap(118, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jButtonRunExampleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonRunExampleActionPerformed
if (jListMainClasses.getSelectedValue() != null) {
String selected = jListMainClasses.getSelectedValue().toString();
jFrameMainController.actionRunExample(selected);
}
}//GEN-LAST:event_jButtonRunExampleActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButtonRunExample;
private javax.swing.JList jListMainClasses;
private javax.swing.JScrollPane jScrollPaneMainClasses;
// End of variables declaration//GEN-END:variables
}