package grafica;
import java.awt.GridBagLayout;
public class Finestra {
/**
* @author Carmine
*/
public static void main(String[] args) {
Start finestraApplicazione = new Start();
finestraApplicazione.setVisible(true);
}
}
package grafica;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.event.*;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JComboBox;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
public class Start extends JFrame {
private Pannellodestro pannellodestro;
private ListaRosa lista;
private FinestraFormazione ff;
public Start(){
super("Gestione squadra");
setSize(new Dimension(1270,750));
Container cp = getContentPane();
JPanel principale = new JPanel();
principale.setLayout(new BoxLayout(principale, BoxLayout.LINE_AXIS));
principale.add(Box.createHorizontalStrut(500));
principale.add(new JLabel("Other stuff goes here"));
principale.add(Box.createHorizontalStrut(400));
pannellodestro = new Pannellodestro();
JPanel pannellocentrale = new JPanel();
JPanel pannellotabella = new JPanel();
principale.add(pannellodestro);
//principale.add(pannellocentrale);
//principale.add(pannellotabella);
cp.setLayout(new BoxLayout(cp, BoxLayout.LINE_AXIS));
cp.add(Box.createHorizontalStrut(500));
//cp.add(new JLabel("Other stuff goes here"));
cp.add(Box.createHorizontalStrut(400));
cp.add(principale);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pack();
setLocationRelativeTo(null);
}
}
package grafica;
import java.util.ArrayList;
import javax.swing.*;
import javax.swing.SpringLayout;
import java.awt.*;
import java.awt.event.*;
import Gestione.*;
public class Pannellodestro extends JPanel {
private static final String[] LIST_STRINGS = {
"Portiere", "Difensore",
"Centrocampista", "Attaccante"
};
private static final String NOME_GIOCATORE = "nome giocatore";
private static final String SCELTA_RUOLO = "scelta ruolo";
private static final int COMBO_COUNT = 25;
private JPanel principale = new JPanel();
private JComboBox[] list = new JComboBox[COMBO_COUNT];
private JTextField[] nGiocatori = new JTextField[COMBO_COUNT];
/**
* Costruttore che mi realizza i pannelli con le JTextField in cui inserire i nomi dei giocatori e le JComboBox
* con cui si sceglie il ruolo
* @param è il titolo del pannello corrispondente
*/
public Pannellodestro() {
JPanel destro = new JPanel(new BorderLayout());
JPanel gridPanel = new JPanel(new GridLayout(0, 2, 0, 0));
JPanel topPanel = new JPanel(new GridLayout(0, 2, 0, 0));
JPanel bottomPanel = new JPanel(new GridLayout(0, 2, 0, 0));
topPanel.add(new JLabel(NOME_GIOCATORE, SwingConstants.CENTER));
topPanel.add(new JLabel(SCELTA_RUOLO, SwingConstants.CENTER));
for (int i = 0; i < list.length; i++) {
nGiocatori[i] = new JTextField(5);
list[i] = new JComboBox(LIST_STRINGS);
list[i].setEditable(false);
gridPanel.add(nGiocatori[i]);
gridPanel.add(list[i]);
}
bottomPanel.add(new JButton("Salva Rosa"));
bottomPanel.add(new JButton("Carica Rosa"));
JScrollPane gridScroll = new JScrollPane(gridPanel);
Dimension gsSize = gridScroll.getPreferredSize();
gridScroll.setPreferredSize(new Dimension(gsSize.width + 15, 500));
destro.add(topPanel, BorderLayout.PAGE_START);
destro.add(gridScroll, BorderLayout.CENTER);
destro.add(bottomPanel,BorderLayout.SOUTH);
}
} |