java/rozsirene-atributy/src/cz/frantovo/rozsireneAtributy/gui/Panel.java
changeset 23 69f49b79342e
parent 22 bf06eb899671
child 27 36cee2c8f5f8
     1.1 --- a/java/rozsirene-atributy/src/cz/frantovo/rozsireneAtributy/gui/Panel.java	Sun Oct 07 15:11:42 2012 +0200
     1.2 +++ b/java/rozsirene-atributy/src/cz/frantovo/rozsireneAtributy/gui/Panel.java	Sun Oct 07 16:15:00 2012 +0200
     1.3 @@ -34,6 +34,7 @@
     1.4   */
     1.5  public class Panel extends javax.swing.JPanel {
     1.6  
     1.7 +	private static final int SLOUPEC_NÁZVU = 0;
     1.8  	private static final Logger log = Logger.getLogger(Panel.class.getSimpleName());
     1.9  	private static final ResourceBundle překlady = ResourceBundle.getBundle("cz.frantovo.rozsireneAtributy.Překlady");
    1.10  	private Model model;
    1.11 @@ -45,7 +46,7 @@
    1.12  		initComponents();
    1.13  
    1.14  		tabulka = new JTable(model);
    1.15 -		tabulka.getColumnModel().getColumn(0).setCellEditor(new EditorNázvůAtributů());
    1.16 +		nastavEditor();
    1.17  		tabulka.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    1.18  		posuvnýPanel.setViewportView(tabulka);
    1.19  
    1.20 @@ -66,10 +67,20 @@
    1.21  		});
    1.22  	}
    1.23  
    1.24 +	private void nastavEditor() {
    1.25 +		tabulka.getColumnModel().getColumn(SLOUPEC_NÁZVU).setCellEditor(new EditorNázvůAtributů());
    1.26 +	}
    1.27 +
    1.28  	private Model getModel() {
    1.29  		return model;
    1.30  	}
    1.31  
    1.32 +	public void setModel(Model model) {
    1.33 +		this.model = model;
    1.34 +		tabulka.setModel(model);
    1.35 +		nastavEditor();
    1.36 +	}
    1.37 +
    1.38  	private void zobrazChybovouHlášku(String hláška, Throwable chyba) {
    1.39  		JOptionPane.showMessageDialog(this, hláška, překlady.getString("chyba"), JOptionPane.ERROR_MESSAGE);
    1.40  		log.log(Level.WARNING, hláška, chyba);