From cfc0915d1cfc6e674fc5cdfd0a3a661adcd4b0cc Mon Sep 17 00:00:00 2001 From: Yana Stamcheva Date: Wed, 16 Jul 2008 14:11:56 +0000 Subject: [PATCH] Synchronize formatting actions. --- .../main/chat/toolBars/EditTextToolBar.java | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/EditTextToolBar.java b/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/EditTextToolBar.java index ba41812c4..95bf4f895 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/EditTextToolBar.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/EditTextToolBar.java @@ -15,13 +15,12 @@ import javax.swing.text.*; import javax.swing.text.html.*; -import say.swing.*; - import net.java.sip.communicator.impl.gui.customcontrols.*; import net.java.sip.communicator.impl.gui.i18n.*; import net.java.sip.communicator.impl.gui.main.chat.*; import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.util.*; +import say.swing.*; /** * The EditTextToolBar is a JToolBar which contains @@ -37,11 +36,6 @@ public class EditTextToolBar { private Logger logger = Logger.getLogger(EditTextToolBar.class); - private Integer[] fontSizeConstants = - new Integer[] - { 9, 10, 11, 12, 13, 14, 18, 24, 36, 48, 64, - 72, 96, 144, 288 }; - private ChatWritePanel chatWritePanel; private JEditorPane chatEditorPane; @@ -63,6 +57,8 @@ public class EditTextToolBar private JToggleButton underlineButton; + private ColorLabel colorLabel; + /** * Creates an instance and constructs the EditTextToolBar. */ @@ -117,6 +113,8 @@ else if (italicButton.isSelected()) int result = fontChooser.showDialog(chatWritePanel); + chatEditorPane.requestFocus(); + if (result == JFontChooser.OK_OPTION) { String fontName = fontChooser.getSelectedFontFamily(); @@ -178,8 +176,6 @@ else if (fontStyle == (Font.BOLD + Font.ITALIC)) if (italicButton.isSelected()) italicButton.doClick(); } - - chatEditorPane.requestFocus(); } } }); @@ -190,7 +186,7 @@ else if (fontStyle == (Font.BOLD + Font.ITALIC)) */ private void initColorLabel() { - final ColorLabel colorLabel = new ColorLabel(); + this.colorLabel = new ColorLabel(); colorLabel.setPreferredSize(new Dimension(21, 21)); colorLabel.setOpaque(true); @@ -200,7 +196,7 @@ private void initColorLabel() colorLabel.addMouseListener(new MouseAdapter() { - public void mousePressed(MouseEvent arg0) + public void mousePressed(MouseEvent event) { Color newColor = JColorChooser.showDialog(new JColorChooser(), @@ -303,12 +299,17 @@ private JToggleButton initStyleToggleButton(final Action action, { final JToggleButton button = new JToggleButton(); button.setPreferredSize(new Dimension(25, 25)); - + button.setName(styleConstant.toString()); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - action.actionPerformed(e); + ActionEvent event = new ActionEvent(chatEditorPane, + ActionEvent.ACTION_PERFORMED, + styleConstant.toString()); + + action.actionPerformed(event); + chatEditorPane.requestFocus(); } }); @@ -341,6 +342,7 @@ public void mouseClicked(MouseEvent e) selectButton(styleConstant, button); } }); + return button; }