codice:
-------------------------------------------
WEEK
java.awt.Dimension[width=1182,height=370]
Tutto ok
-------------------------------------------
public class Week extends JPanel{
public Week(int nWeek) {
this.setLayout(new GridLayout(1, 6));
Day[] day = new Day[7];
for(int i=0; i<months.length; i++){
day[i] = new Day(daysWeek[i], daysMonth[i], months[i], years[i]); //è un JPanel
}
JPanel prima = new JPanel();
prima.setLayout(new GridLayout(1,1));
prima.add(day[0]);
JPanel seconda = new JPanel();
seconda.setLayout(new GridLayout(1,1));
seconda.add(day[1]);
[lo stesso per terza, quarta e quinta colonna]
JPanel weekdays = new JPanel();
weekdays.setLayout(new GridLayout(2, 1));
weekdays.add(day[5]);
weekdays.add(day[6]);
JPanel sesta = new JPanel();
sesta.setLayout(new GridLayout(1,1));
sesta.add(weekdays);
this.add(prima);
this.add(seconda);
this.add(terza);
this.add(quarta);
this.add(quinta);
this.add(sesta);
}
}
-------------------------------------------
DAY
java.awt.Dimension[width=197,height=185]
Tutto ok
-------------------------------------------
public class Day extends JPanel{
public Day(String day, int dayNumber, String month, int year){
JLabel giorno = new JLabel(day);
giorno.setFont(new Font("Kalinga", Font.PLAIN, 20));
giorno.setLocation(5, 5);
giorno.setSize(197, 20);
JLabel numero = new JLabel(Integer.toString(dayNumber));
numero.setFont(new Font("Kalinga", Font.PLAIN, 40));
int posN = 150;
if(dayNumber<10) posN=170;
numero.setLocation(posN, 5);
numero.setSize(197, 40);
JLabel mese = new JLabel(month+" "+Integer.toString(year));
mese.setFont(new Font("Kalinga", Font.PLAIN, 15));
mese.setLocation(5, 25);
mese.setSize(197, 15);
this.setLayout(new BorderLayout());
JPanel top = new JPanel();
FlowLayout f = new FlowLayout();
f.setVgap(0);
f.setHgap(0);
top.setLayout(f);
Head h = new Head(); //inutile ai fine del mio problema...è un JPanel con layout null
h.add(giorno);
h.add(mese);
h.add(numero);
top.add(h);
JPanel content = new JPanel(new GridLayout(1,1));
content.add(new EventPanel(day, dayNumber, month, year));
this.add(top, BorderLayout.NORTH);
this.add(content, BorderLayout.CENTER);
}
}
------------------------------------------------------------------------
EVENTPANEL
EventPaneljava.awt.Dimension[width=128,height=135]
La larghezza dovrebbe essere sempre 197 e non capisco perchè sia 128!
La cosa più strana (per me) è che inserendo uno sfondo mi occupa tutto
lo spazio, quindi i 197, ma mi segna 128 ma i componenti al suo interno
occupano 128
------------------------------------------------------------------------
public class EventPanel extends JPanel{
public EventPanel(String day, int dayNumber, String month, int year){
this.setLayout(new BorderLayout());
JPanel components = new JPanel();
components.setLayout(new GridBagLayout());
GridBagConstraints GBC = new GridBagConstraints();
GBC.gridx = 0;
GBC.gridy = 0;
GBC.insets = new Insets(5,0,0,0);
JPanel prova = new JPanel(new GridLayout(1,1));
prova.setBackground(Color.RED);
SingleEvent s = new SingleEvent("fffffffffffffffff");
prova.add(s);
JPanel prova2= new JPanel(new GridLayout(1,1));
prova2.setBackground(Color.RED);
SingleEvent s2 = new SingleEvent("fffffffffffffffff su altra riga???");
prova2.add(s2);
components.add(prova, GBC);
GBC.gridy++;
components.add(prova2, GBC);
GBC.gridy++;
JPanel top = new JPanel(new GridLayout(1,1));
top.add(new UpArrow());//è un Jbutton
this.add(top, BorderLayout.NORTH);
this.add(components, BorderLayout.CENTER);
JPanel bottom = new JPanel(new GridLayout(1,1));
bottom.add(new DownArrow());//altro JButton
bottom.setOpaque(false);
this.add(bottom, BorderLayout.SOUTH);
}
}
------------------------------------------------------------------------
SINGLEEVENT
SingleEvent: java.awt.Dimension[width=126,height=52]
La larghezza, in relazione a EVENTPANEL è corretta anche se dovrebbe
essere 197. Come altezza non ci siamo perchè nella seconda istanza,
la textarea occupa una riga in più e quindi il Jpanel dovrebbe essere
più alto, o no? la visualizzazione dell'altezza resta corretta
------------------------------------------------------------------------
public class SingleEvent extends JPanel{
public SingleEvent(String s){
JPanel container = new JPanel(new BorderLayout());
JPanel bottom = new JPanel();
bottom.add(new JLabel("Piccolo testo testo"));
JPanel center = new JPanel(new GridLayout(1,1));
JTextArea textArea = new JTextArea(s);
center.add(textArea);
textArea.setWrapStyleWord(true);
textArea.setEditable(false);
textArea.setLineWrap(true);
container.add(center, BorderLayout.CENTER);
container.add(bottom, BorderLayout.SOUTH);
this.add(container);
}
}
Un tazzone di doppia caffè con doppia panna e doppio cornetto a chi mi aiuta...sto impazzendo