34 lines
1.2 KiB
Java
34 lines
1.2 KiB
Java
package com.thebrokenrail.freshcoffee.dialog.client;
|
|
|
|
import com.thebrokenrail.freshcoffee.config.HardcodedConfig;
|
|
import com.thebrokenrail.freshcoffee.dialog.Dialog;
|
|
import com.thebrokenrail.freshcoffee.dialog.server.ServerDialog;
|
|
|
|
import javax.swing.JLabel;
|
|
import javax.swing.JOptionPane;
|
|
import javax.swing.SwingConstants;
|
|
|
|
public class ClientDialog implements Dialog {
|
|
public static final Dialog INSTANCE = new ClientDialog();
|
|
|
|
private ClientDialog() {
|
|
}
|
|
|
|
private JLabel format(String message) {
|
|
JLabel label = new JLabel(String.format("<html><center>%s", message.replaceAll("\n", "<br>")));
|
|
label.setHorizontalAlignment(SwingConstants.CENTER);
|
|
return label;
|
|
}
|
|
|
|
@Override
|
|
public int showOptionDialog(String message, String noText, String yesText) {
|
|
return JOptionPane.showOptionDialog(null, format(message), HardcodedConfig.TITLE, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[]{noText, yesText}, yesText);
|
|
}
|
|
|
|
@Override
|
|
public void showErrorDialog(String message) {
|
|
ServerDialog.INSTANCE.showErrorDialog(message);
|
|
JOptionPane.showMessageDialog(null, format(message), HardcodedConfig.TITLE, JOptionPane.ERROR_MESSAGE);
|
|
}
|
|
}
|