private JToolBar makeToolBar() { JToolBar tool = new JToolBar(); tool.setFloatable(false); // Setup the buttons save.setRequestFocusEnabled(false); tool.add(save); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); String[] fontNames = ge.getAvailableFontFamilyNames(); tool.addSeparator(); cbFonts = new JComboBox(fontNames); cbFonts.setRequestFocusEnabled(false); cbFonts.setMaximumSize(cbFonts.getPreferredSize()); cbFonts.setEditable(true); ActionListener lst = new ActionListener() { public void actionPerformed(ActionEvent e) { if (fFamilyChange) { fFamilyChange = false; return; } editor.grabFocus(); setSelectionAttribute(StyleConstants.Family, cbFonts.getSelectedItem().toString()); } }; cbFonts.addActionListener(lst); tool.add(cbFonts); tool.addSeparator(); sSizes = new JSpinner(new SpinnerNumberModel(12, 1, 100, 1)); sSizes.setRequestFocusEnabled(false); sSizes.setMaximumSize(sSizes.getPreferredSize()); sSizes.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent arg0) { if (fSizeChange) { fSizeChange = false; return; } setSelectionAttribute(StyleConstants.Size, sSizes.getValue()); editor.grabFocus(); } }); tool.add(sSizes); tool.addSeparator(); tbBold = new JToggleButton(LGM.getIconForKey("GameInformationFrame.BOLD")); // $NON-NLS-1$ tbBold.setRequestFocusEnabled(false); lst = new ActionListener() { public void actionPerformed(ActionEvent arg0) { setSelectionAttribute(StyleConstants.Bold, tbBold.isSelected()); } }; tbBold.addActionListener(lst); tool.add(tbBold); tbItalic = new JToggleButton(LGM.getIconForKey("GameInformationFrame.ITALIC")); // $NON-NLS-1$ tbItalic.setRequestFocusEnabled(false); lst = new ActionListener() { public void actionPerformed(ActionEvent arg0) { setSelectionAttribute(StyleConstants.Italic, tbItalic.isSelected()); } }; tbItalic.addActionListener(lst); tool.add(tbItalic); tbUnderline = new JToggleButton(LGM.getIconForKey("GameInformationFrame.UNDERLINED")); // $NON-NLS-1$ tbUnderline.setRequestFocusEnabled(false); lst = new ActionListener() { public void actionPerformed(ActionEvent arg0) { setSelectionAttribute(StyleConstants.Underline, tbUnderline.isSelected()); } }; tbUnderline.addActionListener(lst); tool.add(tbUnderline); tool.addSeparator(); JButton butFontColor = new JButton(LGM.getIconForKey("GameInformationFrame.FONTCOLOR")); // $NON-NLS-1$ butFontColor.setRequestFocusEnabled(false); butFontColor.setActionCommand("GameInformationFrame.FONTCOLOR"); // $NON-NLS-1$ butFontColor.addActionListener(this); tool.add(butFontColor); JButton but = new JButton(LGM.getIconForKey("GameInformationFrame.COLOR")); // $NON-NLS-1$ but.setRequestFocusEnabled(false); but.setActionCommand("GameInformationFrame.COLOR"); // $NON-NLS-1$ but.addActionListener(this); tool.add(but); return tool; }
private JToolBar makeToolBar() { JToolBar tool = new JToolBar(); tool.setFloatable(false); // Setup the buttons save.setRequestFocusEnabled(false); tool.add(save); tool.addSeparator(); JButton button; button = addToolButton("GameInformationFrame.CUT"); // $NON-NLS-1$ tool.add(button); button = addToolButton("GameInformationFrame.COPY"); // $NON-NLS-1$ tool.add(button); button = addToolButton("GameInformationFrame.PASTE"); // $NON-NLS-1$ tool.add(button); tool.addSeparator(); button = new JButton(undoManager.getUndoAction()); button.setText(""); button.setToolTipText(Messages.getString("GameInformationFrame.UNDO")); // $NON-NLS-1$ tool.add(button); button = new JButton(undoManager.getRedoAction()); button.setText(""); button.setToolTipText(Messages.getString("GameInformationFrame.REDO")); // $NON-NLS-1$ tool.add(button); tool.addSeparator(); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); String[] fontNames = ge.getAvailableFontFamilyNames(); cbFonts = new JComboBox<String>(fontNames); cbFonts.setRequestFocusEnabled(false); cbFonts.setMaximumSize(cbFonts.getPreferredSize()); cbFonts.setEditable(true); ActionListener lst = new ActionListener() { public void actionPerformed(ActionEvent e) { if (fFamilyChange) { fFamilyChange = false; return; } editor.grabFocus(); setSelectionAttribute(StyleConstants.Family, cbFonts.getSelectedItem().toString()); } }; cbFonts.addActionListener(lst); tool.add(cbFonts); tool.addSeparator(); sSizes = new JSpinner(new SpinnerNumberModel(12, 1, 100, 1)); sSizes.setRequestFocusEnabled(false); sSizes.setMaximumSize(sSizes.getPreferredSize()); sSizes.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent arg0) { if (fSizeChange) { fSizeChange = false; return; } setSelectionAttribute(StyleConstants.Size, sSizes.getValue()); editor.grabFocus(); } }); tool.add(sSizes); tool.addSeparator(); tbBold = addToggleButton("GameInformationFrame.BOLD"); // $NON-NLS-1$ tbBold.setRequestFocusEnabled(false); tool.add(tbBold); tbItalic = addToggleButton("GameInformationFrame.ITALIC"); // $NON-NLS-1$ tbItalic.setRequestFocusEnabled(false); tool.add(tbItalic); tbUnderline = addToggleButton("GameInformationFrame.UNDERLINE"); // $NON-NLS-1$ tbUnderline.setRequestFocusEnabled(false); tool.add(tbUnderline); tool.addSeparator(); tbLeft = addToggleButton("GameInformationFrame.ALIGN_LEFT"); // $NON-NLS-1$ tbLeft.setRequestFocusEnabled(false); tbLeft.setSelected(true); tool.add(tbLeft); tbCenter = addToggleButton("GameInformationFrame.ALIGN_CENTER"); // $NON-NLS-1$ tbCenter.setRequestFocusEnabled(false); tool.add(tbCenter); tbRight = addToggleButton("GameInformationFrame.ALIGN_RIGHT"); // $NON-NLS-1$ tbRight.setRequestFocusEnabled(false); tool.add(tbRight); tool.addSeparator(); JButton butFontColor = new JButton(LGM.getIconForKey("GameInformationFrame.FONTCOLOR")); // $NON-NLS-1$ butFontColor.setRequestFocusEnabled(false); butFontColor.setActionCommand("GameInformationFrame.FONTCOLOR"); // $NON-NLS-1$ butFontColor.addActionListener(this); butFontColor.setToolTipText( Messages.getString("GameInformationFrame.FONTCOLOR")); // $NON-NLS-1$ tool.add(butFontColor); JButton but = new JButton(LGM.getIconForKey("GameInformationFrame.COLOR")); // $NON-NLS-1$ but.setRequestFocusEnabled(false); but.setActionCommand("GameInformationFrame.COLOR"); // $NON-NLS-1$ but.addActionListener(this); but.setToolTipText(Messages.getString("GameInformationFrame.COLOR")); // $NON-NLS-1$ tool.add(but); return tool; }