Finished dark design and implementing important Components
This commit is contained in:
@@ -59,7 +59,7 @@ public class OACOptionPane extends JOptionPane implements OACComponent {
|
||||
Object[] options,
|
||||
Object initialValue) throws HeadlessException {
|
||||
AtomicInteger result = new AtomicInteger(CLOSED_OPTION);
|
||||
OACDialog dialog = new OACDialog(JOptionPane.getFrameForComponent(parentComponent), title, true);
|
||||
OACDialog dialog = new OACDialog(JOptionPane.getFrameForComponent(parentComponent), null, true);
|
||||
dialog.setUndecorated(true);
|
||||
dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
dialog.setContentPane(buildDialogContent(title, message, icon, optionType, options, result, dialog));
|
||||
@@ -78,6 +78,71 @@ public class OACOptionPane extends JOptionPane implements OACComponent {
|
||||
return result.get();
|
||||
}
|
||||
|
||||
public static int showConfirmDialog(Component parentComponent, Object message) throws HeadlessException {
|
||||
return showConfirmDialog(parentComponent, message, "Select an Option", YES_NO_CANCEL_OPTION);
|
||||
}
|
||||
|
||||
public static int showConfirmDialog(Component parentComponent,
|
||||
Object message,
|
||||
String title,
|
||||
int optionType) throws HeadlessException {
|
||||
return showConfirmDialog(parentComponent, message, title, optionType, QUESTION_MESSAGE);
|
||||
}
|
||||
|
||||
public static int showConfirmDialog(Component parentComponent,
|
||||
Object message,
|
||||
String title,
|
||||
int optionType,
|
||||
int messageType) throws HeadlessException {
|
||||
return showConfirmDialog(parentComponent, message, title, optionType, messageType, null);
|
||||
}
|
||||
|
||||
public static int showConfirmDialog(Component parentComponent,
|
||||
Object message,
|
||||
String title,
|
||||
int optionType,
|
||||
int messageType,
|
||||
Icon icon) throws HeadlessException {
|
||||
return showOptionDialog(
|
||||
parentComponent,
|
||||
message,
|
||||
title,
|
||||
optionType,
|
||||
messageType,
|
||||
icon != null ? icon : resolveDefaultIcon(messageType),
|
||||
null,
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
public static void showMessageDialog(Component parentComponent, Object message) throws HeadlessException {
|
||||
showMessageDialog(parentComponent, message, "Message", INFORMATION_MESSAGE);
|
||||
}
|
||||
|
||||
public static void showMessageDialog(Component parentComponent,
|
||||
Object message,
|
||||
String title,
|
||||
int messageType) throws HeadlessException {
|
||||
showMessageDialog(parentComponent, message, title, messageType, null);
|
||||
}
|
||||
|
||||
public static void showMessageDialog(Component parentComponent,
|
||||
Object message,
|
||||
String title,
|
||||
int messageType,
|
||||
Icon icon) throws HeadlessException {
|
||||
showOptionDialog(
|
||||
parentComponent,
|
||||
message,
|
||||
title,
|
||||
DEFAULT_OPTION,
|
||||
messageType,
|
||||
icon != null ? icon : resolveDefaultIcon(messageType),
|
||||
new Object[]{"OK"},
|
||||
"OK"
|
||||
);
|
||||
}
|
||||
|
||||
private static Container buildDialogContent(String title,
|
||||
Object message,
|
||||
Icon icon,
|
||||
@@ -87,7 +152,6 @@ public class OACOptionPane extends JOptionPane implements OACComponent {
|
||||
OACDialog dialog) {
|
||||
OACPanel root = new OACPanel(new BorderLayout());
|
||||
Color background = DesignManager.resolveBackground(OACOptionPane.class, root.getBackground());
|
||||
Color headerBackground = DesignManager.resolveBackground(OACTitleBar.class, background.darker());
|
||||
Color foreground = DesignManager.resolveForeground(OACOptionPane.class, Color.LIGHT_GRAY);
|
||||
Color borderColor = DesignManager.resolveBorderColor(foreground.darker());
|
||||
|
||||
@@ -95,12 +159,8 @@ public class OACOptionPane extends JOptionPane implements OACComponent {
|
||||
root.setBorder(BorderFactory.createLineBorder(borderColor, 1));
|
||||
|
||||
OACPanel header = new OACPanel(new BorderLayout());
|
||||
header.setBorder(new EmptyBorder(10, 12, 10, 12));
|
||||
header.setBackground(headerBackground);
|
||||
JSeparator separator = new JSeparator(SwingConstants.HORIZONTAL);
|
||||
separator.setForeground(borderColor);
|
||||
separator.setBackground(borderColor);
|
||||
header.add(separator, BorderLayout.SOUTH);
|
||||
header.setBorder(new EmptyBorder(0, 12, 8, 12));
|
||||
header.setBackground(background);
|
||||
|
||||
OACLabel titleLabel = new OACLabel(title == null ? "" : title);
|
||||
titleLabel.setForeground(foreground);
|
||||
@@ -116,14 +176,24 @@ public class OACOptionPane extends JOptionPane implements OACComponent {
|
||||
center.add(iconLabel, BorderLayout.WEST);
|
||||
}
|
||||
|
||||
JTextArea messageArea = new JTextArea(String.valueOf(message));
|
||||
messageArea.setEditable(false);
|
||||
messageArea.setLineWrap(true);
|
||||
messageArea.setWrapStyleWord(true);
|
||||
messageArea.setOpaque(false);
|
||||
messageArea.setForeground(foreground);
|
||||
messageArea.setBorder(null);
|
||||
center.add(messageArea, BorderLayout.CENTER);
|
||||
if (message instanceof Component messageComponent) {
|
||||
if (messageComponent instanceof OACComponent oacComponent) {
|
||||
oacComponent.initDesign();
|
||||
} else {
|
||||
messageComponent.setBackground(background);
|
||||
messageComponent.setForeground(foreground);
|
||||
}
|
||||
center.add(messageComponent, BorderLayout.CENTER);
|
||||
} else {
|
||||
JTextArea messageArea = new JTextArea(String.valueOf(message));
|
||||
messageArea.setEditable(false);
|
||||
messageArea.setLineWrap(true);
|
||||
messageArea.setWrapStyleWord(true);
|
||||
messageArea.setOpaque(false);
|
||||
messageArea.setForeground(foreground);
|
||||
messageArea.setBorder(null);
|
||||
center.add(messageArea, BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
OACPanel buttons = new OACPanel(new FlowLayout(FlowLayout.RIGHT, 8, 8));
|
||||
buttons.setBackground(background);
|
||||
@@ -177,6 +247,15 @@ public class OACOptionPane extends JOptionPane implements OACComponent {
|
||||
};
|
||||
}
|
||||
|
||||
private static Icon resolveDefaultIcon(int messageType) {
|
||||
return switch (messageType) {
|
||||
case ERROR_MESSAGE -> UIManager.getIcon("OptionPane.errorIcon");
|
||||
case WARNING_MESSAGE -> UIManager.getIcon("OptionPane.warningIcon");
|
||||
case QUESTION_MESSAGE -> UIManager.getIcon("OptionPane.questionIcon");
|
||||
default -> UIManager.getIcon("OptionPane.informationIcon");
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component add(Component comp) {
|
||||
this.initOther(comp);
|
||||
|
||||
Reference in New Issue
Block a user