package cstutor; /* * To change this template, choose Tools | Templates * and open the template in the editor. */ /* * TutorialPage.java * * Created on Nov 18, 2009, 1:18:30 PM */ /** * * @author Administrator */ public class TutorialPage extends javax.swing.JFrame { /** Creates new form TutorialPage */ public TutorialPage() { tp = this; 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") // //GEN-BEGIN:initComponents private void initComponents() { next = new javax.swing.JButton(); prev = new javax.swing.JButton(); page1Text = new javax.swing.JLabel(); page2Text = new javax.swing.JLabel(); page3Text = new javax.swing.JLabel(); clear = new javax.swing.JButton(); refresh = new javax.swing.JButton(); run = new javax.swing.JButton(); jScrollPane1 = new javax.swing.JScrollPane(); customText = new javax.swing.JTextArea(); jScrollPane2 = new javax.swing.JScrollPane(); customOutput = new javax.swing.JTextArea(); pageOtherText = new javax.swing.JLabel(); jScrollPane3 = new javax.swing.JScrollPane(); lameImage = new javax.swing.JTextArea(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Tutorial"); next.setText("Next"); next.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { nextActionPerformed(evt); } }); prev.setText("Prev"); prev.setEnabled(false); prev.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { prevActionPerformed(evt); } }); page1Text.setVisible(false); page1Text.setText("For Loops loop for a certain duration"); page2Text.setText("For Loops have 4 parts that need to be filled"); page2Text.setVisible(false); page3Text.setText("Try out a For Loop here!"); page3Text.setVisible(false); clear.setText("Clear"); clear.setVisible(false); clear.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { clearActionPerformed(evt); } }); refresh.setText("Refresh"); refresh.setVisible(false); refresh.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { refreshActionPerformed(evt); } }); run.setText("Run"); run.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { runActionPerformed(evt); } }); run.setVisible(false); customText.setColumns(20); customText.setRows(5); customText.setText("for (int i = 0; i < 4; i++) {\n System.out.println(\"Hello!\");\n}"); customText.setVisible(false); customText.setEnabled(false); jScrollPane1.setViewportView(customText); customOutput.setColumns(20); customOutput.setRows(5); customOutput.setVisible(false); customOutput.setEnabled(false); jScrollPane2.setViewportView(customOutput); pageOtherText.setText("This is an image of a For Loop"); lameImage.setEnabled(false); lameImage.setColumns(20); lameImage.setRows(5); lameImage.setText("This WOULD be an image, but\nnetBeans won't let me import\nan image for it to use. So\ninstead you are getting this\nwall of text that is going to\nsimulate a new image generated\nfor this page.\nTAKE THAT NETBEANS!"); jScrollPane3.setViewportView(lameImage); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(prev) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 466, Short.MAX_VALUE) .addComponent(next)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 84, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(refresh)) .addGap(29, 29, 29) .addComponent(run) .addGap(29, 29, 29) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(clear) .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(51, 51, 51)))) .addGroup(layout.createSequentialGroup() .addGap(170, 170, 170) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(9, 9, 9) .addComponent(page1Text)) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 247, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(page2Text)) .addGroup(layout.createSequentialGroup() .addGap(19, 19, 19) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(page3Text) .addGroup(layout.createSequentialGroup() .addGap(10, 10, 10) .addComponent(pageOtherText))))))) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGap(38, 38, 38) .addComponent(page1Text) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(page2Text) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(page3Text) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(pageOtherText) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 152, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 49, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) .addComponent(run) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(jScrollPane2) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(11, 11, 11) .addComponent(refresh)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGap(2, 2, 2) .addComponent(clear))))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(prev) .addComponent(next)) .addContainerGap()) ); pack(); }// //GEN-END:initComponents private void prevActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_prevActionPerformed Previous(); }//GEN-LAST:event_prevActionPerformed private void nextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nextActionPerformed Next(); }//GEN-LAST:event_nextActionPerformed private void runActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_runActionPerformed customOutput.setText("Hello!\nHello!\nHello!\nHello!"); }//GEN-LAST:event_runActionPerformed private void clearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clearActionPerformed customOutput.setText(""); }//GEN-LAST:event_clearActionPerformed private void refreshActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_refreshActionPerformed customText.setText("for (int i = 0; i < 4; i++) {\n System.out.println(\"Hello!\");\n}"); }//GEN-LAST:event_refreshActionPerformed private void Previous() { if (this.page3 == true) { page3Text.setVisible(false); this.page3 = false; page2Text.setVisible(true); this.page2 = true; next.setEnabled(true); Shell(false); } else if (this.page2 == true) { page2Text.setVisible(false); this.page2 = false; page1Text.setVisible(true); this.page1 = true; } else if (this.page1 == true) { page1Text.setVisible(false); this.page1 = false; pageOtherText.setVisible(true); this.pageOther = true; prev.setEnabled(false); lameImage.setVisible(true); } } private void Next() { if (this.page2 == true) { page2Text.setVisible(false); this.page2 = false; page3Text.setVisible(true); this.page3 = true; next.setEnabled(true); Shell(true); } else if (this.page1 == true) { page1Text.setVisible(false); this.page1 = false; page2Text.setVisible(true); this.page2 = true; prev.setEnabled(true); } else if (this.pageOther == true) { pageOtherText.setVisible(false); this.pageOther = false; lameImage.setVisible(false); page1Text.setVisible(true); this.page1 = true; prev.setEnabled(true); } else if (this.page3 == true) { new cstutor.quizresults.Quiz().setVisible(true); tp.setVisible(false); } } private void Shell(boolean bool) { run.setVisible(bool); refresh.setVisible(bool); customText.setVisible(bool); customOutput.setVisible(bool); customText.setEnabled(bool); clear.setVisible(bool); } /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { (tp = new TutorialPage()).setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton clear; private javax.swing.JTextArea customOutput; private javax.swing.JTextArea customText; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JScrollPane jScrollPane3; private javax.swing.JTextArea lameImage; private javax.swing.JButton next; private javax.swing.JLabel page1Text; private javax.swing.JLabel page2Text; private javax.swing.JLabel page3Text; private javax.swing.JLabel pageOtherText; private javax.swing.JButton prev; private javax.swing.JButton refresh; private javax.swing.JButton run; // End of variables declaration//GEN-END:variables private boolean page1 = false; private boolean page2 = false; private boolean page3 = false; private boolean pageOther = true; private static TutorialPage tp; }