Java之提示對話方塊的使用!...
阿新 • • 發佈:2019-02-11
btnNewButton.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {//錯誤對話方塊
JOptionPane.showMessageDialog(null,
"這是一個錯誤對話方塊",
"ERROR_MESSAGE",
JOptionPane.ERROR_MESSAGE);
}
});
button.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {//內部資訊對話方塊
JOptionPane.showMessageDialog(null,
"這是一個內部資訊對話方塊",
"INFORMATION",
JOptionPane.INFORMATION_MESSAGE);
}
});
button_1.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {//警告對話方塊
JOptionPane.showMessageDialog(null,
"這是一個警告對話方塊",
"WARNING_MESSAGE",
JOptionPane.WARNING_MESSAGE);
}
});
button_2.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {//詢問對話方塊
JOptionPane.showMessageDialog(null,
"這是一個詢問對話方塊",
"QUESTION_MESSAGE",
JOptionPane.QUESTION_MESSAGE);
}
});
button_3.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {//顯示一個資訊面板
JOptionPane.showConfirmDialog(null,
"這是一個資訊面版",
"YES_NO_OPTION",
JOptionPane.YES_NO_OPTION);
}
});
public void mouseClicked(MouseEvent e) {//錯誤對話方塊
JOptionPane.showMessageDialog(null,
"這是一個錯誤對話方塊",
"ERROR_MESSAGE",
JOptionPane.ERROR_MESSAGE);
}
});
button.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {//內部資訊對話方塊
JOptionPane.showMessageDialog(null,
"這是一個內部資訊對話方塊",
"INFORMATION",
JOptionPane.INFORMATION_MESSAGE);
}
});
button_1.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {//警告對話方塊
JOptionPane.showMessageDialog(null,
"這是一個警告對話方塊",
"WARNING_MESSAGE",
JOptionPane.WARNING_MESSAGE);
}
});
button_2.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {//詢問對話方塊
JOptionPane.showMessageDialog(null,
"這是一個詢問對話方塊",
"QUESTION_MESSAGE",
JOptionPane.QUESTION_MESSAGE);
}
});
button_3.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {//顯示一個資訊面板
JOptionPane.showConfirmDialog(null,
"這是一個資訊面版",
"YES_NO_OPTION",
JOptionPane.YES_NO_OPTION);
}
});