Google

Wednesday, June 4, 2008

Inticas 020: Teacher/Subject Slots, Enabled Multiline Cells


Each slot will now display Subject & Teacher Initials.
Also enabled multi-line cells. Subject will display on one line and
Teacher initials on second line.
I had to increase the rowheight, by using a customised CellRenderer:

import javax.swing.JTextArea;
import javax.swing.table.TableCellRenderer;
import java.awt.Component;
import javax.swing.JTable;

class MultiLineCellRenderer extends JTextArea implements TableCellRenderer
{

public MultiLineCellRenderer() {
setLineWrap(true);
setWrapStyleWord(true);
setOpaque(true);
}

public Component getTableCellRendererComponent(JTable jTable,
Object obj, boolean isSelected, boolean hasFocus, int row,
int column)
{

setText((String)obj);
return this;
}
}



and also modified the RoomFrame constructor:

public RoomFrame()
{

initComponents();
mytable.setRowHeight(40);

for(int b=1;b<=12;b++)
{
mytable.getColumnModel().getColumn(b).setCellRenderer(
new MultiLineCellRenderer());
//mytable.getColumnModel().getColumn(b).setPreferredWidth(50);
}

}



To Do:
Classroom Allocation Algorithms by taking the subjects from the Subject class
and the Teacher info from the Teacher class saved in the SubjectSerialized
and TeacherSerialized files respectively.