Hoyte, potřeboval bych pomoct s mojim GUI....
chci abych mel ty JTable pres celý JPanel....
dále při maximalizaci aby se mi JTably natahly...
Zde je mé GUI prosím o pomoc díky
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/*
* @author Dave-CZ
*/
public final class Databaze extends JFrame implements ActionListener{
private javax.swing.JPanel mainPanel;
private javax.swing.JPanel Hlavni;
private javax.swing.JPanel RegKlubyPanel;
private javax.swing.JPanel HledatKlPanel;
private javax.swing.JLabel lbHledejKl;
private javax.swing.JTextField txtHledejKl;
private javax.swing.JButton btnHledejKl;
private javax.swing.JPanel KlubyPanel;
private javax.swing.JPanel Kluby;
private JScrollPane KlubyTable;
private JTable TabulkaKluby;
private javax.swing.JPanel TlKlubyPanel;
private javax.swing.JButton btnNovyKlub;
private javax.swing.JButton btnSmazKlub;
private javax.swing.JPanel ZalozkyP;
private javax.swing.JPanel ZalozkyPa;
private javax.swing.JTabbedPane Zalozka;
private javax.swing.JPanel UdajeTab;
private javax.swing.JPanel Informace;
private javax.swing.JLabel lb1Cislo;
private javax.swing.JTextField txtCislo;
private javax.swing.JLabel lb1Nazev;
private javax.swing.JTextField txtNazev;
private javax.swing.JLabel lb1CelyNazev;
private javax.swing.JTextField txtCelyNazev;
private javax.swing.JLabel lb1Banka;
private javax.swing.JTextField txtBanka;
private javax.swing.JLabel lb1Lomitko;
private javax.swing.JTextField txtLomitko;
private javax.swing.JPanel Kontakt;
private javax.swing.JLabel lb1Mobil;
private javax.swing.JTextField txtMobil;
private javax.swing.JLabel lb1Email;
private javax.swing.JTextField txtEmail;
private javax.swing.JLabel lb1WWW;
private javax.swing.JTextField txtWWW;
private javax.swing.JPanel AdresaPrec;
private javax.swing.JLabel lb1JmPr;
private javax.swing.JTextField txtJmPr;
private javax.swing.JLabel lb1Ulice;
private javax.swing.JTextField txtUlice;
private javax.swing.JLabel lb1CP;
private javax.swing.JTextField txtCP;
private javax.swing.JLabel lb1Mesto;
private javax.swing.JTextField txtMesto;
private javax.swing.JLabel lb1PSC;
private javax.swing.JTextField txtPSC;
private javax.swing.JPanel TlUdajePanel;
private javax.swing.JButton btnUlozUdaj;
private javax.swing.JButton btnVymazUdaje;
private javax.swing.JPanel ClenoveTab;
private javax.swing.JPanel ClenovePanel;
private javax.swing.JPanel Clenove;
private JScrollPane ClenoveTable;
private JTable TabulkaClenove;
private javax.swing.JPanel Hledat;
private javax.swing.JLabel lb2HledejCL;
private javax.swing.JTextField txt2HledejCL;
private javax.swing.JButton btn2HledejCL;
private javax.swing.JPanel TlClenUdajePanel;
private javax.swing.JButton btn2PridejCL;
private javax.swing.JButton btn2UpravCL;
private javax.swing.JButton btn2SmazCL;
public Databaze()
{
setTitle("Databaze");
getContentPane().add(initComponents());
pack();
}
public JPanel initComponents() {
GridBagConstraints gridBagConstraints;
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.insets.top = 5;
gridBagConstraints.insets.left = 5;
Hlavni = new JPanel();
RegKlubyPanel = new JPanel();
HledatKlPanel = new JPanel();
lbHledejKl = new JLabel();
txtHledejKl = new JTextField();
btnHledejKl = new JButton();
KlubyPanel = new JPanel();
Kluby = new JPanel();
KlubyTable = new JScrollPane();
TabulkaKluby = new JTable();
TlKlubyPanel = new JPanel();
btnNovyKlub = new JButton();
btnSmazKlub = new JButton();
ZalozkyP = new JPanel();
ZalozkyPa = new JPanel();
Zalozka = new JTabbedPane();
UdajeTab = new JPanel();
Informace = new JPanel();
lb1Cislo = new JLabel();
txtCislo = new JTextField();
lb1Nazev = new JLabel();
txtNazev = new JTextField();
lb1CelyNazev = new JLabel();
txtCelyNazev = new JTextField();
lb1Banka = new JLabel();
txtBanka = new JTextField();
lb1Lomitko = new JLabel();
txtLomitko = new JTextField();
Kontakt = new JPanel();
lb1Mobil = new JLabel();
txtMobil = new JTextField();
lb1Email = new JLabel();
txtEmail = new JTextField();
lb1WWW = new JLabel();
txtWWW = new JTextField();
AdresaPrec = new JPanel();
lb1JmPr = new JLabel();
txtJmPr = new JTextField();
lb1Ulice = new JLabel();
txtUlice = new JTextField();
lb1CP = new JLabel();
txtCP = new JTextField();
lb1Mesto = new JLabel();
txtMesto = new JTextField();
lb1PSC = new JLabel();
txtPSC = new JTextField();
TlUdajePanel = new JPanel();
btnUlozUdaj = new JButton();
btnVymazUdaje = new JButton();
ClenoveTab = new JPanel();
ClenovePanel = new JPanel();
Clenove = new JPanel();
ClenoveTable = new JScrollPane();
TabulkaClenove = new JTable();
Hledat = new JPanel();
lb2HledejCL = new JLabel();
txt2HledejCL = new JTextField();
btn2HledejCL = new JButton();
TlClenUdajePanel = new JPanel();
btn2PridejCL = new JButton();
btn2UpravCL = new JButton();
btn2SmazCL = new JButton();
RegKlubyPanel.setLayout(new GridBagLayout());
RegKlubyPanel.setBorder(BorderFactory.createTitledBorder("Registrovane kluby"));
RegKlubyPanel.setName("RegistrovaneKluby");
HledatKlPanel.setLayout(new GridBagLayout());
HledatKlPanel.setName("RegistrovaneKluby");
lbHledejKl.setText("Hledat:");
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
HledatKlPanel.add(lbHledejKl,gridBagConstraints);
txtHledejKl.setPreferredSize(new Dimension(150, 20));
gridBagConstraints.gridx = 1;
HledatKlPanel.add(txtHledejKl,gridBagConstraints);
btnHledejKl.setText("Vyhledej");
gridBagConstraints.gridx = 2;
HledatKlPanel.add(btnHledejKl,gridBagConstraints);
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
RegKlubyPanel.add(HledatKlPanel,gridBagConstraints);
KlubyPanel.setLayout(new GridBagLayout());
KlubyPanel.setBorder(BorderFactory.createTitledBorder("Kluby"));
KlubyPanel.setName("KlubyPan");
Kluby.setLayout(new GridBagLayout());
final String columnNames[] = { "Název TJ/SK", "Číslo klubu", "Předseda", "Kontakt" };
final Object rowData[][] = { { "TJ SPS Radkov", "706051", "David Chudik", "723111111" },
{ "TJ Sokol Melč", "706056", "Pavel Schrom", "723222222" },
{ "TJ Vitkov", "706054", "Karel Špok", "723333333" }};
TabulkaKluby = new JTable(rowData, columnNames);
KlubyTable = new JScrollPane(TabulkaKluby);
KlubyTable.setPreferredSize(new Dimension(450, 110));
Kluby.add(KlubyTable);
KlubyPanel.add(Kluby);
gridBagConstraints.gridy = 1;
RegKlubyPanel.add(KlubyPanel,gridBagConstraints);
TlKlubyPanel.setLayout(new GridBagLayout());
TlKlubyPanel.setName("TlacikaKluby");
btnNovyKlub.setText("Nový klub");
gridBagConstraints.gridy = 2;
TlKlubyPanel.add(btnNovyKlub,gridBagConstraints);
btnSmazKlub.setText("Smaž klub");
gridBagConstraints.gridx = 1;
TlKlubyPanel.add(btnSmazKlub,gridBagConstraints);
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
RegKlubyPanel.add(TlKlubyPanel,gridBagConstraints);
ZalozkyP.setLayout(new GridBagLayout());
ZalozkyP.setName("Zalozky");
UdajeTab.setLayout(new GridBagLayout());
UdajeTab.setName("Udaje");
Informace.setLayout(new GridBagLayout());
Informace.setBorder(BorderFactory.createTitledBorder("Informace o kluby"));
Informace.setName("Informace");
lb1Cislo.setText("Číslo TJ/SK:");
gridBagConstraints.anchor = GridBagConstraints.EAST;
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
Informace.add(lb1Cislo,gridBagConstraints);
txtCislo.setPreferredSize(new Dimension(100, 20));
gridBagConstraints.anchor = GridBagConstraints.WEST;
gridBagConstraints.gridx = 1;
Informace.add(txtCislo,gridBagConstraints);
lb1Nazev.setText("Název TJ/SK:");
gridBagConstraints.anchor = GridBagConstraints.EAST;
gridBagConstraints.gridx = 2;
Informace.add(lb1Nazev,gridBagConstraints);
txtNazev.setPreferredSize(new Dimension(100, 20));
gridBagConstraints.anchor = GridBagConstraints.WEST;
gridBagConstraints.gridx = 3;
Informace.add(txtNazev,gridBagConstraints);
lb1CelyNazev.setText("Celý název:");
gridBagConstraints.anchor = GridBagConstraints.EAST;
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
Informace.add(lb1CelyNazev,gridBagConstraints);
txtCelyNazev.setPreferredSize(new Dimension(282, 20));
gridBagConstraints.anchor = GridBagConstraints.WEST;
gridBagConstraints.gridwidth = 3;
gridBagConstraints.gridx = 1;
Informace.add(txtCelyNazev,gridBagConstraints);
lb1Banka.setText("Bankovní spojení:");
gridBagConstraints.anchor = GridBagConstraints.EAST;
gridBagConstraints.gridwidth = 1;
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
Informace.add(lb1Banka,gridBagConstraints);
txtBanka.setPreferredSize(new Dimension(100, 20));
gridBagConstraints.anchor = GridBagConstraints.WEST;
gridBagConstraints.gridx = 1;
Informace.add(txtBanka,gridBagConstraints);
lb1Lomitko.setText("/");
gridBagConstraints.gridx = 2;
Informace.add(lb1Lomitko,gridBagConstraints);
txtLomitko.setPreferredSize(new Dimension(50, 20));
gridBagConstraints.gridx = 3;
Informace.add(txtLomitko,gridBagConstraints);
Kontakt.setLayout(new GridBagLayout());
Kontakt.setBorder(BorderFactory.createTitledBorder("Kontakt"));
Kontakt.setName("Kontakt");
lb1Mobil.setText("Mobil:");
gridBagConstraints.anchor = GridBagConstraints.EAST;
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
Kontakt.add(lb1Mobil,gridBagConstraints);
txtMobil.setPreferredSize(new Dimension(100, 20));
gridBagConstraints.anchor = GridBagConstraints.WEST;
gridBagConstraints.gridx = 1;
Kontakt.add(txtMobil,gridBagConstraints);
lb1Email.setText("E-mail:");
gridBagConstraints.anchor = GridBagConstraints.EAST;
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
Kontakt.add(lb1Email,gridBagConstraints);
txtEmail.setPreferredSize(new Dimension(100, 20));
gridBagConstraints.anchor = GridBagConstraints.WEST;
gridBagConstraints.gridx = 1;
Kontakt.add(txtEmail,gridBagConstraints);
lb1WWW.setText("WWW:");
gridBagConstraints.anchor = GridBagConstraints.EAST;
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
Kontakt.add(lb1WWW,gridBagConstraints);
txtWWW.setPreferredSize(new Dimension(100, 20));
gridBagConstraints.anchor = GridBagConstraints.WEST;
gridBagConstraints.gridx = 1;
Kontakt.add(txtWWW,gridBagConstraints);
AdresaPrec.setLayout(new GridBagLayout());
AdresaPrec.setBorder(BorderFactory.createTitledBorder("Předseda"));
AdresaPrec.setName("Predseda");
lb1JmPr.setText("Jméno a příjmení:");
gridBagConstraints.anchor = GridBagConstraints.EAST;
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
AdresaPrec.add(lb1JmPr,gridBagConstraints);
txtJmPr.setPreferredSize(new Dimension(187, 20));
gridBagConstraints.anchor = GridBagConstraints.WEST;
gridBagConstraints.gridwidth = 3;
gridBagConstraints.gridx = 1;
AdresaPrec.add(txtJmPr,gridBagConstraints);
lb1Ulice.setText("Ulice:");
gridBagConstraints.anchor = GridBagConstraints.EAST;
gridBagConstraints.gridwidth = 1;
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
AdresaPrec.add(lb1Ulice,gridBagConstraints);
txtUlice.setPreferredSize(new Dimension(100, 20));
gridBagConstraints.anchor = GridBagConstraints.WEST;
gridBagConstraints.gridx = 1;
AdresaPrec.add(txtUlice,gridBagConstraints);
lb1CP.setText("ČP:");
gridBagConstraints.anchor = GridBagConstraints.EAST;
gridBagConstraints.gridx = 2;
AdresaPrec.add(lb1CP,gridBagConstraints);
txtCP.setPreferredSize(new Dimension(50, 20));
gridBagConstraints.anchor = GridBagConstraints.WEST;
gridBagConstraints.gridx = 3;
AdresaPrec.add(txtCP,gridBagConstraints);
lb1Mesto.setText("Město:");
gridBagConstraints.anchor = GridBagConstraints.EAST;
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
AdresaPrec.add(lb1Mesto,gridBagConstraints);
txtMesto.setPreferredSize(new Dimension(100, 20));
gridBagConstraints.anchor = GridBagConstraints.WEST;
gridBagConstraints.gridx = 1;
AdresaPrec.add(txtMesto,gridBagConstraints);
lb1PSC.setText("PSČ:");
gridBagConstraints.anchor = GridBagConstraints.EAST;
gridBagConstraints.gridx = 2;
AdresaPrec.add(lb1PSC,gridBagConstraints);
txtPSC.setPreferredSize(new Dimension(50, 20));
gridBagConstraints.anchor = GridBagConstraints.WEST;
gridBagConstraints.gridx = 3;
AdresaPrec.add(txtPSC,gridBagConstraints);
TlUdajePanel.setLayout(new GridBagLayout());
TlUdajePanel.setName("TlacikaUdaje");
btnUlozUdaj.setText("Ulož údaje");
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
TlUdajePanel.add(btnUlozUdaj,gridBagConstraints);
btnVymazUdaje.setText("Smaž údaje");
gridBagConstraints.gridx = 1;
TlUdajePanel.add(btnVymazUdaje,gridBagConstraints);
ZalozkyP.add(UdajeTab);
ZalozkyPa.setLayout(new GridBagLayout());
ZalozkyPa.setName("Zalozky");
ClenoveTab.setLayout(new GridBagLayout());
ClenoveTab.setName("Clenove");
ClenovePanel.setLayout(new GridBagLayout());
ClenovePanel.setBorder(BorderFactory.createTitledBorder("Členové"));
ClenovePanel.setName("ClenovePanel");
Clenove.setLayout(new GridBagLayout());
final String Names[] = { "Charakter", "Jméno", "Příjmení" };
final Object Data[][] = { { "1", "Martin", "Jedna" },
{ "2", "Karel", "Dva" },
{ "3", "Radek", "Tři" } };
TabulkaClenove = new JTable(Data, Names);
ClenoveTable = new JScrollPane(TabulkaClenove);
ClenoveTable.setPreferredSize(new Dimension(450, 110));
Clenove.add(ClenoveTable);
ClenovePanel.add(Clenove);
Hledat.setLayout(new GridBagLayout());
Hledat.setName("HledatCL");
lb2HledejCL.setText("Hledat:");
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
Hledat.add(lb2HledejCL,gridBagConstraints);
txt2HledejCL.setPreferredSize(new Dimension(150, 20));
gridBagConstraints.gridx = 1;
Hledat.add(txt2HledejCL,gridBagConstraints);
btn2HledejCL.setText("Vyhledej");
gridBagConstraints.gridx = 2;
Hledat.add(btn2HledejCL,gridBagConstraints);
TlClenUdajePanel.setLayout(new GridBagLayout());
TlClenUdajePanel.setName("TlacitkaClen");
btn2PridejCL.setText("Přidej člena");
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
TlClenUdajePanel.add(btn2PridejCL,gridBagConstraints);
btn2UpravCL.setText("Uprav člena");
gridBagConstraints.gridx = 1;
TlClenUdajePanel.add(btn2UpravCL,gridBagConstraints);
btn2SmazCL.setText("Smaž člena");
gridBagConstraints.gridx = 2;
TlClenUdajePanel.add(btn2SmazCL,gridBagConstraints);
ZalozkyPa.add(ClenoveTab);
Hlavni.setLayout(new GridBagLayout());
UdajeTab.setLayout(new GridBagLayout());
ClenoveTab.setLayout(new GridBagLayout());
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
UdajeTab.add(Informace,gridBagConstraints);
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 0;
UdajeTab.add(Kontakt,gridBagConstraints);
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 0;
UdajeTab.add(AdresaPrec,gridBagConstraints);
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridwidth = 3;
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
UdajeTab.add(TlUdajePanel,gridBagConstraints);
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridwidth = 1;
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.weighty = 0.5;
ClenoveTab.add(ClenovePanel,gridBagConstraints);
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.weighty = 0.5;
ClenoveTab.add(Hledat,gridBagConstraints);
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.weighty = 0.5;
ClenoveTab.add(TlClenUdajePanel,gridBagConstraints);
Zalozka.addTab("Údaje o TJ/SK", UdajeTab);
Zalozka.addTab("Členové", ClenoveTab);
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.fill = GridBagConstraints.BOTH;
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.weighty = 0.5;
Hlavni.add(RegKlubyPanel,gridBagConstraints);
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.fill = GridBagConstraints.BOTH;
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.weighty = 0.5;
Hlavni.add(Zalozka,gridBagConstraints);
}
public void actionPerformed(ActionEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}
}