package cz.muni.fi.bronchus.gui; /* * NewFileDialog.java * * Created on 8. cervenec 2004, 9:48 */ import java.net.URL; import javax.swing.*; /** * * @author xudrzal */ public class NewFileDialog extends MyCentralizedJDialog { private MyResources myResources; private JList myJList; private int selected=-1; public static int ObjectBank_OPTION=0; public static int AssessmentBasic_OPTION=1; public static int Assessment_SEQ_SUM_OPTION=2; public static int Assessment_RAND_SUM_OPTION=3; public static int Assessment_SEQ_NUM_OPTION=4; public static int Assessment_RAND_NUM_OPTION=5; /** Creates new form NewFileDialog */ public NewFileDialog(java.awt.Frame parent, boolean modal, MyResources res) { super(parent, modal); myResources = res; initComponents(); myInitComponents(); } /** 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. */ private void initComponents() {//GEN-BEGIN:initComponents jPanel1 = new javax.swing.JPanel(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); jLabel1 = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); jLabel2 = new javax.swing.JLabel(); jScrollPane2 = new javax.swing.JScrollPane(); jTextArea1 = new javax.swing.JTextArea(); getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); jPanel1.setPreferredSize(new java.awt.Dimension(400, 300)); jButton1.setFont(new java.awt.Font("Dialog", 0, 11)); jButton1.setText(myResources.getBundle("cz/muni/fi/bronchus/bundles/NewFileDialogBundle", "OK")); jButton1.setEnabled(false); jButton1.setPreferredSize(new java.awt.Dimension(70, 25)); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jPanel1.add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(230, 265, -1, -1)); jButton2.setFont(new java.awt.Font("Dialog", 0, 11)); jButton2.setText(myResources.getBundle("cz/muni/fi/bronchus/bundles/NewFileDialogBundle", "Cancel")); jButton2.setPreferredSize(new java.awt.Dimension(70, 25)); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); jPanel1.add(jButton2, new org.netbeans.lib.awtextra.AbsoluteConstraints(320, 265, -1, -1)); jLabel1.setFont(new java.awt.Font("Dialog", 0, 11)); jLabel1.setText(myResources.getBundle("cz/muni/fi/bronchus/bundles/NewFileDialogBundle", "Select New File")); jPanel1.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, -1, -1)); jPanel1.add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 30, 380, 100)); jLabel2.setFont(new java.awt.Font("Dialog", 0, 11)); jLabel2.setText(myResources.getBundle("cz/muni/fi/bronchus/bundles/NewFileDialogBundle", "Description")); jPanel1.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 140, -1, -1)); jScrollPane2.setPreferredSize(new java.awt.Dimension(380, 95)); jTextArea1.setEditable(false); jTextArea1.setFont(new java.awt.Font("Dialog", 0, 11)); jTextArea1.setLineWrap(true); jTextArea1.setWrapStyleWord(true); jScrollPane2.setViewportView(jTextArea1); jPanel1.add(jScrollPane2, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 160, -1, -1)); getContentPane().add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1)); pack(); }//GEN-END:initComponents private String getDescription(int i) { switch (i) { case 0: return myResources.getBundle("cz/muni/fi/bronchus/bundles/NewFileDialogBundle","Object-Bank_desc"); case 1: return myResources.getBundle("cz/muni/fi/bronchus/bundles/NewFileDialogBundle","An_Assessment_desc"); case 2: return myResources.getBundle("cz/muni/fi/bronchus/bundles/NewFileDialogBundle","Assessment_sequential_SumOfScores_desc"); case 3: return myResources.getBundle("cz/muni/fi/bronchus/bundles/NewFileDialogBundle","Assessment_random_SumOfScores_desc"); case 4: return myResources.getBundle("cz/muni/fi/bronchus/bundles/NewFileDialogBundle","Assessment_sequential_NumberCorrect_desc"); case 5: return myResources.getBundle("cz/muni/fi/bronchus/bundles/NewFileDialogBundle","Assessment_random_NumberCorrect_desc"); default: return ""; } } private void myInitComponents() { this.setTitle(myResources.getBundle("cz/muni/fi/bronchus/bundles/NewFileDialogBundle","New_File")); String listData[]={ myResources.getBundle("cz/muni/fi/bronchus/bundles/NewFileDialogBundle","Object_Bank"), myResources.getBundle("cz/muni/fi/bronchus/bundles/NewFileDialogBundle","Assessment"), myResources.getBundle("cz/muni/fi/bronchus/bundles/NewFileDialogBundle","Assessment_Sequential_SumOfScores"), myResources.getBundle("cz/muni/fi/bronchus/bundles/NewFileDialogBundle","Assessment_Random_SumOfScores"), myResources.getBundle("cz/muni/fi/bronchus/bundles/NewFileDialogBundle","Assessment_Sequential_NumberCorrect"), myResources.getBundle("cz/muni/fi/bronchus/bundles/NewFileDialogBundle","Assessment_Random_NumberCorrect") }; myJList=new JList(listData); myJList.setCellRenderer(new NewFileCellRenderer()); myJList.setFont(new java.awt.Font("Dialog", 0, 11)); myJList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); myJList.setLayoutOrientation(JList.HORIZONTAL_WRAP); myJList.setVisibleRowCount(-1); myJList.addListSelectionListener(new javax.swing.event.ListSelectionListener() { public void valueChanged(javax.swing.event.ListSelectionEvent evt) { if (myJList.getSelectedIndex()!=-1) { jTextArea1.setText(getDescription(myJList.getSelectedIndex())); jButton1.setEnabled(true); } else { jButton1.setEnabled(false); } } }); myJList.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { if (evt.getClickCount()==2 && myJList.getSelectedIndex()!=-1) { selected=myJList.getSelectedIndex(); setVisible(false); dispose(); } } }); jScrollPane1.setViewportView(myJList); } private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed // TODO add your handling code here: selected=myJList.getSelectedIndex(); setVisible(false); dispose(); }//GEN-LAST:event_jButton1ActionPerformed private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed // TODO add your handling code here: selected=-1; setVisible(false); dispose(); }//GEN-LAST:event_jButton2ActionPerformed public int showDialog() { setVisible(true); return selected; } /** * @param args the command line arguments */ public static void main(String args[]) { new NewFileDialog(new javax.swing.JFrame(), true, null).setVisible(true); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JPanel jPanel1; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JTextArea jTextArea1; // End of variables declaration//GEN-END:variables }