JTable: zjednodušení. v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Tue, 28 Dec 2010 17:24:05 +0100
branchv_0
changeset 16c25305af7968
parent 15 984cba2864e5
child 17 bdae9cab5797
JTable: zjednodušení.
java/rozsirene-atributy/src/cz/frantovo/rozsireneAtributy/gui/Panel.form
java/rozsirene-atributy/src/cz/frantovo/rozsireneAtributy/gui/Panel.java
     1.1 --- a/java/rozsirene-atributy/src/cz/frantovo/rozsireneAtributy/gui/Panel.form	Tue Dec 28 17:02:08 2010 +0100
     1.2 +++ b/java/rozsirene-atributy/src/cz/frantovo/rozsireneAtributy/gui/Panel.form	Tue Dec 28 17:24:05 2010 +0100
     1.3 @@ -47,23 +47,6 @@
     1.4      <Container class="javax.swing.JScrollPane" name="posuvn&#xfd;Panel">
     1.5  
     1.6        <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
     1.7 -      <SubComponents>
     1.8 -        <Component class="javax.swing.JTable" name="tabulka">
     1.9 -          <Properties>
    1.10 -            <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
    1.11 -              <Table columnCount="4" rowCount="4">
    1.12 -                <Column editable="true" title="Title 1" type="java.lang.Object"/>
    1.13 -                <Column editable="true" title="Title 2" type="java.lang.Object"/>
    1.14 -                <Column editable="true" title="Title 3" type="java.lang.Object"/>
    1.15 -                <Column editable="true" title="Title 4" type="java.lang.Object"/>
    1.16 -              </Table>
    1.17 -            </Property>
    1.18 -            <Property name="selectionModel" type="javax.swing.ListSelectionModel" editor="org.netbeans.modules.form.editors2.JTableSelectionModelEditor">
    1.19 -              <JTableSelectionModel selectionMode="0"/>
    1.20 -            </Property>
    1.21 -          </Properties>
    1.22 -        </Component>
    1.23 -      </SubComponents>
    1.24      </Container>
    1.25      <Component class="javax.swing.JButton" name="tla&#x10d;&#xed;tkoP&#x159;idat">
    1.26        <Properties>
     2.1 --- a/java/rozsirene-atributy/src/cz/frantovo/rozsireneAtributy/gui/Panel.java	Tue Dec 28 17:02:08 2010 +0100
     2.2 +++ b/java/rozsirene-atributy/src/cz/frantovo/rozsireneAtributy/gui/Panel.java	Tue Dec 28 17:24:05 2010 +0100
     2.3 @@ -6,6 +6,8 @@
     2.4  import java.util.logging.Level;
     2.5  import java.util.logging.Logger;
     2.6  import javax.swing.JOptionPane;
     2.7 +import javax.swing.JTable;
     2.8 +import javax.swing.ListSelectionModel;
     2.9  import javax.swing.event.ListSelectionEvent;
    2.10  import javax.swing.event.ListSelectionListener;
    2.11  
    2.12 @@ -19,12 +21,16 @@
    2.13  	private static final ResourceBundle překlady = ResourceBundle.getBundle("cz.frantovo.rozsireneAtributy.Překlady");
    2.14  	private Model model;
    2.15  	private Atribut vybranýAtribut;
    2.16 +	private JTable tabulka;
    2.17  
    2.18  	public Panel(Model model) {
    2.19  		this.model = model;
    2.20  		initComponents();
    2.21 -		tabulka.setModel(model);
    2.22 -		
    2.23 +
    2.24 +		tabulka = new JTable(model);
    2.25 +		tabulka.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    2.26 +		posuvnýPanel.setViewportView(tabulka);
    2.27 +
    2.28  		/** Výběr aktuálního atributu v tabulce */
    2.29  		tabulka.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    2.30  
    2.31 @@ -55,25 +61,10 @@
    2.32      private void initComponents() {
    2.33  
    2.34          posuvnýPanel = new javax.swing.JScrollPane();
    2.35 -        tabulka = new javax.swing.JTable();
    2.36          tlačítkoPřidat = new javax.swing.JButton();
    2.37          tlačítkoSmazat = new javax.swing.JButton();
    2.38          tlačítkoZnovuNačíst = new javax.swing.JButton();
    2.39  
    2.40 -        tabulka.setModel(new javax.swing.table.DefaultTableModel(
    2.41 -            new Object [][] {
    2.42 -                {null, null, null, null},
    2.43 -                {null, null, null, null},
    2.44 -                {null, null, null, null},
    2.45 -                {null, null, null, null}
    2.46 -            },
    2.47 -            new String [] {
    2.48 -                "Title 1", "Title 2", "Title 3", "Title 4"
    2.49 -            }
    2.50 -        ));
    2.51 -        tabulka.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
    2.52 -        posuvnýPanel.setViewportView(tabulka);
    2.53 -
    2.54          tlačítkoPřidat.setMnemonic('p');
    2.55          java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("cz/frantovo/rozsireneAtributy/Překlady"); // NOI18N
    2.56          tlačítkoPřidat.setText(bundle.getString("přidatAtribut")); // NOI18N
    2.57 @@ -148,7 +139,6 @@
    2.58  	}//GEN-LAST:event_tlačítkoZnovuNačístActionPerformed
    2.59      // Variables declaration - do not modify//GEN-BEGIN:variables
    2.60      private javax.swing.JScrollPane posuvnýPanel;
    2.61 -    private javax.swing.JTable tabulka;
    2.62      private javax.swing.JButton tlačítkoPřidat;
    2.63      private javax.swing.JButton tlačítkoSmazat;
    2.64      private javax.swing.JButton tlačítkoZnovuNačíst;