/* License see bottom */
package jtrackbase.gui;
import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.border.Border;
import jtrackbase.Constants;
import jtrackbase.db.Genre;
public class GenrePanel extends DataInputPanel<Genre> {
public GenrePanel() {
this(new Genre());
}
public GenrePanel(Genre g) {
genre=g;
createUI();
showData();
}
private void createUI() {
Border b=BorderFactory.createLineBorder(Color.BLACK);
b=BorderFactory.createTitledBorder(b, "Genre");
setBorder(b);
setLayout(new GridBagLayout());
GridBagConstraints gbc=new GridBagConstraints();
gbc.gridx=0;
gbc.gridy=0;
gbc.anchor=GridBagConstraints.EAST;
add(new JLabel("Name:"), gbc);
gbc.gridy++;
add(new JLabel("Kommentar:"), gbc);
nameField.setColumns(Constants.TEXT_FIELD_COLUMNS);
gbc.gridx++;
gbc.gridy=0;
gbc.anchor=GridBagConstraints.WEST;
gbc.fill=GridBagConstraints.HORIZONTAL;
gbc.weightx=1.0;
add(nameField, gbc);
commentField.setRows(Constants.TEXT_AREA_ROWS);
commentField.setColumns(Constants.TEXT_AREA_COLUMNS);
gbc.gridwidth=2;
gbc.gridx=0;
gbc.gridy=2;
gbc.weighty=1.0;
gbc.fill=GridBagConstraints.BOTH;
add(new JScrollPane(commentField), gbc);
}
private void showData() {
if (genre.getName()!=null) {
nameField.setText(genre.getName());
}
if (genre.getComment()!=null) {
commentField.setText(genre.getComment());
}
}
private void saveData() {
genre.setName(nameField.getText());
genre.setComment(commentField.getText());
}
@Override
public Genre getData() {
saveData();
return genre;
}
@Override
public void displayErrors() {
// TODO Auto-generated method stub
}
@Override
public boolean isDataValid() {
// TODO Auto-generated method stub
return false;
}
private JTextField nameField=new JTextField();
private JTextArea commentField=new JTextArea();
private Genre genre;
}
/*
Copyright (C) 2008 Onkobu Tanaake
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program (gplv3.txt).
*/