こんにちは、このパズルを解くのに苦労しています。教授はコードを提供し、列見出しをクリックできるように変更するように私たちに言いました.誰か私のために変更できますか.? ほぼ4時間を無駄にしました:(Javaスイングではあまり大きくありません。以下はコードです...以下はコードです:
package academic.emailClient.view;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.util.ArrayList;
import java.util.Date;
import java.util.Vector;
import javax.swing.*;
import javax.swing.table.*;
import academic.emailClient.model.Message;
import academic.emailClient.view.entities.MessageView;
public class MailBox extends JFrame {
JTable tableinbox;
private final int MAILBOX_FRAME_WIDTH = 1080;
private final int MAILBOX_FRAME_HEIGHT = 650;
static final boolean VISIBLE = true;
public MailBox() {
Object[] columnNamesinbox = { "Boolean", "Sender", "Subject", "Body" };
Object[][] datainbox = {
{ false, "5@gmail.com", "D", "T" },
{ false, "r@gmail.com", "projhsdject work", "I " },
{ false, "r.@ymail.com", "Job Placement","Iut that" },
{ true, "yam@gmail.com", "s1", "as" }
};
DefaultTableModel modelinbox = new DefaultTableModel(datainbox,
columnNamesinbox);
tableinbox = new JTable(modelinbox) {
@Override
public Class getColumnClass(int columninbox) {
switch (columninbox) {
case 0:
return Boolean.class;
case 1:
return String.class;
case 2:
return String.class;
case 3:
return String.class;
default:
return Boolean.class;
}
}
};
tableinbox.setBackground(Color.lightGray);
tableinbox.setGridColor(new Color(0,128,0));
JTableHeader inboxheader = tableinbox.getTableHeader();
inboxheader.setBackground(Color.DARK_GRAY);
inboxheader.setForeground(Color.white);
}
public int getMesssagesCount(int i) {
return 0;
}
public int GetCheckedItemsNumber(int i) {
return 0;
}
public Object[][] GetCheckedItems() {
return GetCheckedItems();
}
public Object[][] GetMail() {
return GetMail();
}
public Object[][] OrderByDate() {
return OrderByDate();
}
public Object[][] OrderBySender() {
return OrderBySender();
}
public Object[][] OrderBySubject() {
return OrderBySubject();
}
public JTable getMailBox() {
return tableinbox;
}
public void run() {
JFrame MailBoxFrame = new JFrame();
MailBoxFrame.setMaximumSize(new Dimension(MAILBOX_FRAME_WIDTH, MAILBOX_FRAME_HEIGHT));
MailBoxFrame.setPreferredSize(new Dimension(MAILBOX_FRAME_WIDTH, MAILBOX_FRAME_HEIGHT));
MailBoxFrame.setBounds(0, 0, MAILBOX_FRAME_WIDTH, MAILBOX_FRAME_HEIGHT);
MailBoxFrame.setVisible(VISIBLE);
MailBoxFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}