package okenka; /* * To change this template, choose Tools | Templates * and open the template in the editor. */ /* * HlavniOkno.java * * Created on 26.10.2009, 15:44:15 */ /** * * @author culikzde */ public class HlavniOkno extends javax.swing.JFrame { private static HlavniOkno win = null; public static HlavniOkno getWin () { return win; } public HlavniOkno() { initComponents(); if (win != null) throw new RuntimeException ("To nejde"); win = this; } /** 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() { jScrollPane3 = new javax.swing.JScrollPane(); jTree1 = new javax.swing.JTree(); jScrollPane1 = new javax.swing.JScrollPane(); jTextArea1 = new javax.swing.JTextArea(); jScrollPane2 = new javax.swing.JScrollPane(); jList1 = new javax.swing.JList(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); jScrollPane3.setViewportView(jTree1); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jTextArea1.setColumns(20); jTextArea1.setRows(5); jScrollPane1.setViewportView(jTextArea1); jList1.setModel(new javax.swing.AbstractListModel() { String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" }; public int getSize() { return strings.length; } public Object getElementAt(int i) { return strings[i]; } }); jScrollPane2.setViewportView(jList1); jButton1.setText("jButton1"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jButton2.setText("jButton2"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(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() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(20, 20, 20) .addComponent(jButton1) .addGap(27, 27, 27) .addComponent(jButton2)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap() .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 494, Short.MAX_VALUE))) .addGap(28, 28, 28)) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 476, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(28, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(11, 11, 11) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton1) .addComponent(jButton2)) .addGap(18, 18, 18) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 257, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(23, Short.MAX_VALUE)) ); pack(); }// //GEN-END:initComponents MyModel m ; private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed m = new MyModel (e); m.addListDataListener (new MyListener ()); jList1.setModel (m); // zobraz (e); }//GEN-LAST:event_jButton1ActionPerformed private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed e[3] = new Okno ("posledni"); m.pridano (3, 3); // zobraz (e); }//GEN-LAST:event_jButton2ActionPerformed public void send (String s) { jTextArea1.append (s + "\n"); } int [] a = { 1, 2, 3}; int [] b = new int [5]; int [] c; int [] d = { }; private void zobraz (int [] p) { if (p == null) send ("pole neexistuje"); else { send ("pocet prvku " + p.length); for (int i = 0; i < p.length; i++) send ("prvek " + i + " = " + p[i]); } } Okno [] e = { new Okno ("a"), new Okno ("b"), new Okno (), null }; Okno [] f = new Okno [10]; Okno [] g ; Okno [] h = { } ; Okno [] h2 = new Okno [0] ; private void zobraz (Okno [] p) { if (p == null) send ("pole neexistuje"); else { send ("pocet prvku " + p.length); for (int i = 0; i < p.length; i++) send ("prvek " + i + " = " + (p[i] == null ? "nic" : p[i].nazev)); //send ("prvek " + i + " = " + p[i]); // send ("prvek " + i + " = " + p[i].toString ()); } } int [] [] q = { {1,2,3}, {10, 20}}; // int [,] q = { {1,2,3}, {10, 20, 30}}; int [] [] r ; int [] [] v = new int [10] []; int [] [] w = new int [10] [4]; private void zobraz (int [] [] p) { if (p == null) send ("pole neexistuje"); else { send ("pocet radek " + p.length); for (int i = 0; i < p.length; i++) { // zobraz (p[i]); int [] t = p[i]; if (t == null) send ("radek " + i + "neexistuje" ); else { send ("pocet sloupcu (v radku " + i + ") :" + t.length); for (int j = 0; j < t.length; j++) send ("prvek [" + i + "," + j + " = " + t[j]); } } } } /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new HlavniOkno().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JList jList1; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JScrollPane jScrollPane3; private javax.swing.JTextArea jTextArea1; private javax.swing.JTree jTree1; // End of variables declaration//GEN-END:variables }