java/rozsirene-atributy/src/cz/frantovo/rozsireneAtributy/gui/Panel.java
branchv_0
changeset 16 c25305af7968
parent 15 984cba2864e5
child 19 adea235f456a
     1.1 --- a/java/rozsirene-atributy/src/cz/frantovo/rozsireneAtributy/gui/Panel.java	Tue Dec 28 17:02:08 2010 +0100
     1.2 +++ b/java/rozsirene-atributy/src/cz/frantovo/rozsireneAtributy/gui/Panel.java	Tue Dec 28 17:24:05 2010 +0100
     1.3 @@ -6,6 +6,8 @@
     1.4  import java.util.logging.Level;
     1.5  import java.util.logging.Logger;
     1.6  import javax.swing.JOptionPane;
     1.7 +import javax.swing.JTable;
     1.8 +import javax.swing.ListSelectionModel;
     1.9  import javax.swing.event.ListSelectionEvent;
    1.10  import javax.swing.event.ListSelectionListener;
    1.11  
    1.12 @@ -19,12 +21,16 @@
    1.13  	private static final ResourceBundle překlady = ResourceBundle.getBundle("cz.frantovo.rozsireneAtributy.Překlady");
    1.14  	private Model model;
    1.15  	private Atribut vybranýAtribut;
    1.16 +	private JTable tabulka;
    1.17  
    1.18  	public Panel(Model model) {
    1.19  		this.model = model;
    1.20  		initComponents();
    1.21 -		tabulka.setModel(model);
    1.22 -		
    1.23 +
    1.24 +		tabulka = new JTable(model);
    1.25 +		tabulka.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    1.26 +		posuvnýPanel.setViewportView(tabulka);
    1.27 +
    1.28  		/** Výběr aktuálního atributu v tabulce */
    1.29  		tabulka.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    1.30  
    1.31 @@ -55,25 +61,10 @@
    1.32      private void initComponents() {
    1.33  
    1.34          posuvnýPanel = new javax.swing.JScrollPane();
    1.35 -        tabulka = new javax.swing.JTable();
    1.36          tlačítkoPřidat = new javax.swing.JButton();
    1.37          tlačítkoSmazat = new javax.swing.JButton();
    1.38          tlačítkoZnovuNačíst = new javax.swing.JButton();
    1.39  
    1.40 -        tabulka.setModel(new javax.swing.table.DefaultTableModel(
    1.41 -            new Object [][] {
    1.42 -                {null, null, null, null},
    1.43 -                {null, null, null, null},
    1.44 -                {null, null, null, null},
    1.45 -                {null, null, null, null}
    1.46 -            },
    1.47 -            new String [] {
    1.48 -                "Title 1", "Title 2", "Title 3", "Title 4"
    1.49 -            }
    1.50 -        ));
    1.51 -        tabulka.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
    1.52 -        posuvnýPanel.setViewportView(tabulka);
    1.53 -
    1.54          tlačítkoPřidat.setMnemonic('p');
    1.55          java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("cz/frantovo/rozsireneAtributy/Překlady"); // NOI18N
    1.56          tlačítkoPřidat.setText(bundle.getString("přidatAtribut")); // NOI18N
    1.57 @@ -148,7 +139,6 @@
    1.58  	}//GEN-LAST:event_tlačítkoZnovuNačístActionPerformed
    1.59      // Variables declaration - do not modify//GEN-BEGIN:variables
    1.60      private javax.swing.JScrollPane posuvnýPanel;
    1.61 -    private javax.swing.JTable tabulka;
    1.62      private javax.swing.JButton tlačítkoPřidat;
    1.63      private javax.swing.JButton tlačítkoSmazat;
    1.64      private javax.swing.JButton tlačítkoZnovuNačíst;