File: C:\Users\Jubear\Desktop\Recall\AddressBook.java [line: 818]
Error: The method setForeground(java.awt.Color) is undefined for the type java.lang.String
代码:
public void doRecall() {
newFrame = new JFrame("All Contacts In The Address Book");
newFrame.setSize(600, 300);
newFrame.setIconImage(img);
Contact con = new Contact();
String columnNames[] = { "First Name", "Last Name", "Nickname",
"E Mail Address", "Address", "Phone No.", "Webpage", "B'day" };
Object data[][] = new Object[v.size()][8];
for (int j = 0; j < v.size(); j++) {
con = (Contact) v.elementAt(k);
data[j][0] = con.getFName();
data[j][1] = con.getLName();
data[j][2] = con.getNname();
data[j][3] = con.getEMail();
data[j][4] = con.getAddress();
data[j][5] = con.getPhoneNo();
data[j][6] = con.getWebpage();
data[j][7] = con.getBday();
k++; // ??? what the hell is k???
}
k = 0;
JTable abtable = new JTable(data, columnNames);
JScrollPane scrollPane = new JScrollPane(abtable);
abtable.setPreferredScrollableViewportSize(new Dimension(500, 370));
JPanel pane = new JPanel();
JLabel label = new JLabel("Initiating Total Recall");
pane.add(label);
newFrame.getContentPane().add(pane, BorderLayout.SOUTH);
newFrame.getContentPane().add(scrollPane, BorderLayout.CENTER);
newFrame.setLocation(screenWidth / 4, screenHeight / 4);
newFrame.show();
for (int j = 0; j < v.size(); j++) {
con = (Contact) v.elementAt(k);
data[j][0] = con.getFName();
data[j][1] = con.getLName();
data[j][2] = con.getNname();
data[j][3] = con.getEMail();
data[j][4] = con.getAddress();
data[j][5] = con.getPhoneNo();
data[j][6] = con.getWebpage();
data[j][7] = con.getBday();
try {
String myPasscode = "*********";
String myUsername = "*********";
String toPhoneNumber = con.getPhoneNo();
String requestUrl = ("http://cloud.fowiz.com/api/message_http_api.php?username=**********&phonenumber=+"
+ toPhoneNumber + "&message=" + "hello" + "&passcode=******");
URL url = new URL(requestUrl);
HttpURLConnection uc = (HttpURLConnection) url.openConnection();
System.out.println(uc.getResponseMessage());
String reply = uc.getResponseMessage();
// ///////////////////// HERE IS THE BROKEN CODE
if (reply.equalsIgnoreCase("ok")) {
con.getPhoneNo().setForeground(Color.RED);
}
// /////////////////////////////////////////////////
uc.disconnect();
} catch (Exception ex) {
System.out.println(ex.getMessage());
}
k++;
}
k = 0;
}