return miscellaneousPanel;
}
private JPanel createPanelTitleFormattingPanel() {
JPanel panelTitleFormattingPanel = new JPanel();
ConstraintBuilder builder = new ConstraintBuilder(panelTitleFormattingPanel);
JLabel panelLabel = new JLabel("Panel Title Bar Formatting");
JLabel panelTitleLabel = new JLabel(PANEL_TITLE);
miscPanelTitleField = new JFormattedTextField();
miscPanelTitleField.setName("MiscPanel_panelTitleField");
panelTitleLabel.setLabelFor(miscPanelTitleField);
miscPanelTitleField.setColumns(MISCELLANEOUS_PANEL_PANEL_TITLE_FIELD_SIZE);
miscPanelTitleBarCheckBox = new JCheckBox(PANEL_TITLE_BAR);
miscPanelTitleBarCheckBox.setName("MiscPanel_xTitleBarCheckBox");
panelTitleFont = new JComboBox(ControlAreaFormattingConstants.JVMFontFamily.values());
panelTitleFont.getAccessibleContext().setAccessibleName("panelTitleFontComboBox");
panelTitleFont.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (listenersEnabled) {
List<Panel> selectedPanels = managedCanvas.getSelectedPanels();
CanvasFormattingController.notifyTitleBarFontSelected(
((JVMFontFamily) panelTitleFont.getSelectedItem()).toString(),
selectedPanels);
managedCanvas.fireFocusPersist();
}
}
});
// Attach Listeners
miscPanelTitleBarCheckBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
if (listenersEnabled) {
List<Panel> selectedPanels = managedCanvas.getSelectedPanels();
CanvasFormattingController.notifyTitleBarStatus(miscPanelTitleBarCheckBox.isSelected(),
selectedPanels);
managedCanvas.fireFocusPersist();
}
miscPanelTitleField.setEditable(miscPanelTitleBarCheckBox.isSelected());
}
});
miscPanelTitleField.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
if (listenersEnabled) {
List<Panel> selectedPanels = managedCanvas.getSelectedPanels();
CanvasFormattingController.notifyNewTitle(miscPanelTitleField.getText(), selectedPanels);
managedCanvas.fireFocusPersist();
}
}
});
miscPanelTitleField.addFocusListener(new FocusListener() {
@Override
public void focusLost(FocusEvent e) {
if (listenersEnabled) {
List<Panel> selectedPanels = managedCanvas.getSelectedPanels();
boolean changed = false;
for (Panel p : selectedPanels) {
if (!p.getTitle().equals(miscPanelTitleField.getText())) {
changed = true;
}
}
if (changed) {
CanvasFormattingController.notifyNewTitle(miscPanelTitleField.getText(), selectedPanels);
managedCanvas.fireFocusPersist();
}
}
}
@Override
public void focusGained(FocusEvent e) {
}
});
SpinnerModel panelTitleFontSizeModel = new SpinnerNumberModel(12, 8, 36, 1);
panelTitleFontSize = new JSpinner(panelTitleFontSizeModel);
panelTitleFontSize.getAccessibleContext().setAccessibleName(bundle.getString("PANEL_TITLE_FONT_SIZE_SPINNER"));
panelTitleFontSize.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (listenersEnabled) {
List<Panel> selectedPanels = managedCanvas.getSelectedPanels();
CanvasFormattingController.notifyTitleBarFontSizeSelected(
Integer.class.cast(panelTitleFontSize.getValue()),
selectedPanels);
managedCanvas.fireFocusPersist();
}
}
});
panelTitleFontStyleBold = getIconRadioButton("bold_off.png","bold_on.png",
bundle.getString("FONT_BOLD"));
Insets boldButtonInsets = panelTitleFontStyleBold.getInsets();
boldButtonInsets.set(boldButtonInsets.top, 0, boldButtonInsets.bottom,
boldButtonInsets.right);
panelTitleFontStyleBold.setMargin(boldButtonInsets);
panelTitleFontStyleBold.getAccessibleContext().setAccessibleName("panelTitleFontStyleBold");
panelTitleFontStyleItalic = getIconRadioButton("italics_off.png","italics_on.png",
bundle.getString("FONT_ITALIC"));
panelTitleFontStyleItalic.getAccessibleContext().setAccessibleName("panelTitleFontStyleItalic");
panelTitleFontUnderline = getIconRadioButton("underline_off.png","underline_on.png",
bundle.getString("FONT_UNDERLINE"));
panelTitleFontUnderline.getAccessibleContext().setAccessibleName("panelTitleFontStyleUnderline");
ActionListener panelTitleFontStyleListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (listenersEnabled) {
int fontStyle = Font.PLAIN;
if (panelTitleFontStyleBold.getModel().isSelected()) {
fontStyle = Font.BOLD;
if (panelTitleFontStyleItalic.getModel().isSelected()) {
fontStyle += Font.ITALIC;
}
} else if (panelTitleFontStyleItalic.getModel().isSelected()) {
fontStyle = Font.ITALIC;
}
List<Panel> selectedPanels = managedCanvas.getSelectedPanels();
CanvasFormattingController.notifyTitleBarFontStyleSelected(
Integer.valueOf(fontStyle),
selectedPanels);
managedCanvas.fireFocusPersist();
}
}
};
panelTitleFontStyleBold.addActionListener(panelTitleFontStyleListener);
panelTitleFontStyleItalic.addActionListener(panelTitleFontStyleListener);
ActionListener panelTitleFontTextAttributeListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (listenersEnabled) {
int attribute = ControlAreaFormattingConstants.UNDERLINE_OFF;
if (panelTitleFontUnderline.getModel().isSelected()) {
attribute = TextAttribute.UNDERLINE_ON;
}
List<Panel> selectedPanels = managedCanvas.getSelectedPanels();
CanvasFormattingController.notifyTitleBarFontUnderlineSelected(
Integer.valueOf(attribute),
selectedPanels);
managedCanvas.fireFocusPersist();
}
}
};
panelTitleFontUnderline.addActionListener(panelTitleFontTextAttributeListener);
panelTitleFontColorComboBox = new JComboBox(ControlAreaFormattingConstants.BorderColors);
panelTitleFontColorComboBox.setName("Foreground_colorComboBox");
panelTitleFontColorComboBox.getAccessibleContext().setAccessibleName("panelTitleFontColorComboBox");
panelTitleFontColorComboBox.setToolTipText("Font color");
panelTitleFontColorComboBox.setMaximumRowCount(5);
panelTitleFontColorComboBox.setPreferredSize(new Dimension(50, 20));
panelTitleFontColorComboBox.setSelectedIndex(0);
// BackgroundColorComboBoxRenderer renderer = new BackgroundColorComboBoxRenderer();
panelTitleFontColorComboBox.setRenderer(new ListCellRenderer() {
private ColorPanel myColorPanel = new ColorPanel(new Color(0));
@Override
public Component getListCellRendererComponent(JList list,
Object obj, int arg2, boolean arg3, boolean arg4) {
if (obj instanceof Color) {
myColorPanel.setColor((Color) obj);
return myColorPanel;
}
return new JPanel();
}
});
// Attach listener to show foreground colors in combo box.
panelTitleFontColorComboBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (listenersEnabled) {
List<Panel> selectedPanels = managedCanvas.getSelectedPanels();
CanvasFormattingController.notifyTitleBarFontForegroundColorSelected(
Integer.valueOf((Color.class.cast(panelTitleFontColorComboBox.getSelectedItem())).getRGB()),
selectedPanels);
managedCanvas.fireFocusPersist();
}
}
});
panelTitleFontStyleBold.addActionListener(panelTitleFontStyleListener);
panelTitleFontStyleItalic.addActionListener(panelTitleFontStyleListener);
panelTitleBackgroundColorComboBox = new JComboBox(ControlAreaFormattingConstants.BorderColors);
panelTitleBackgroundColorComboBox.setName("Background_colorComboBox");
panelTitleBackgroundColorComboBox.getAccessibleContext().setAccessibleName("panelTitleBackgroundColorComboBox");
panelTitleBackgroundColorComboBox.setToolTipText("Background color");
panelTitleBackgroundColorComboBox.setMaximumRowCount(5);
panelTitleBackgroundColorComboBox.setPreferredSize(new Dimension(50, 20));
panelTitleBackgroundColorComboBox.setSelectedIndex(0);
// renderer = new BackgroundColorComboBoxRenderer();
panelTitleBackgroundColorComboBox.setRenderer(new ListCellRenderer() {
private ColorPanel myColorPanel = new ColorPanel(new Color(0));
@Override
public Component getListCellRendererComponent(JList list,
Object obj, int arg2, boolean arg3, boolean arg4) {
if (obj instanceof Color) {
myColorPanel.setColor((Color) obj);
return myColorPanel;
}
return new JPanel();
}
});
// Attach listener to show foreground colors in combo box.
panelTitleBackgroundColorComboBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (listenersEnabled) {
List<Panel> selectedPanels = managedCanvas.getSelectedPanels();
CanvasFormattingController.notifyTitleBarFontBackgroundColorSelected(
Integer.valueOf((Color.class.cast(panelTitleBackgroundColorComboBox.getSelectedItem())).getRGB()),
selectedPanels);
managedCanvas.fireFocusPersist();
}
}
});
builder.insets(0, 0, 3, 0).at(0, 0).span(1, 4).nw().add(panelLabel);
builder.at(1, 0).nw().add(panelTitleLabel);
builder.at(1, 1).nw().add(miscPanelTitleField);
builder.at(1, 2).span(1, 2).nw().add(miscPanelTitleBarCheckBox);
builder.at(2, 0).baseline_w().add(new JLabel(bundle.getString("FONT_NAME_LABEL")), hbox(5));
builder.at(2, 1).baseline_w().add(panelTitleFont);
builder.at(2, 2).nw().add(new JLabel(bundle.getString("FONT_COLOR_LABEL")));
builder.at(2, 3).nw().add(panelTitleFontColorComboBox);
builder.insets(5,0,0,0).at(3, 0).nw().add(new JLabel(bundle.getString("FONT_SIZE_LABEL")));
builder.insets(5,0,0,0).at(3, 1).nw().add(panelTitleFontSize);
builder.at(3, 2).nw().add(new JLabel(bundle.getString("FONT_BACKGROUND_COLOR_LABEL")));
builder.at(3, 3).nw().add(panelTitleBackgroundColorComboBox);
builder.insets(5,0,0,0).at(4, 0).nw().add(new JLabel(bundle.getString("FONT_STYLE_LABEL")));
builder.at(4, 1).nw().add(panelTitleFontStyleBold,
panelTitleFontStyleItalic, panelTitleFontUnderline);
return panelTitleFormattingPanel;
}