notify-dpml AT lists.ibiblio.org
Subject: DPML Notify
List archive
svn commit: r1295 - in development/laboratory/mgr: main/src/main/net/dpml/mgr/main plugins/magic/src/main/net/dpml/mgr/magic plugins/metro/src/main/net/dpml/mgr/metro
- From: mcconnell AT netcompartner.com
- To: notify-dpml AT lists.ibiblio.org
- Subject: svn commit: r1295 - in development/laboratory/mgr: main/src/main/net/dpml/mgr/main plugins/magic/src/main/net/dpml/mgr/magic plugins/metro/src/main/net/dpml/mgr/metro
- Date: Sun, 26 Dec 2004 06:01:57 +0100
Author: mcconnell
Date: Sun Dec 26 06:01:57 2004
New Revision: 1295
Modified:
development/laboratory/mgr/main/src/main/net/dpml/mgr/main/DefaultDesktop.java
development/laboratory/mgr/plugins/magic/src/main/net/dpml/mgr/magic/
(props changed)
development/laboratory/mgr/plugins/metro/src/main/net/dpml/mgr/metro/
(props changed)
Log:
add some focus handling within the root panel
Modified:
development/laboratory/mgr/main/src/main/net/dpml/mgr/main/DefaultDesktop.java
==============================================================================
---
development/laboratory/mgr/main/src/main/net/dpml/mgr/main/DefaultDesktop.java
(original)
+++
development/laboratory/mgr/main/src/main/net/dpml/mgr/main/DefaultDesktop.java
Sun Dec 26 06:01:57 2004
@@ -32,12 +32,19 @@
import javax.swing.JDesktopPane;
import javax.swing.KeyStroke;
import javax.swing.ImageIcon;
-import javax.swing.JToggleButton;
+import javax.swing.JButton;
+import javax.swing.AbstractButton;
+import javax.swing.JComponent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
import java.net.URI;
import java.net.URL;
import java.util.Map;
@@ -59,7 +66,8 @@
* @metro.component name="desktop" lifestyle="singleton"
* @metro.service type="net.dpml.mgr.main.Desktop"
*/
-public class DefaultDesktop extends JFrame implements Startable, Runnable,
Desktop, ActionListener
+public class DefaultDesktop extends JFrame
+ implements Startable, Runnable, Desktop, ActionListener, FocusListener
{
//--------------------------------------------------------------------------
// static
@@ -91,6 +99,11 @@
*/
private final Repository m_repository;
+ /**
+ * The content panel.
+ */
+ private JPanel m_panel;
+
//--------------------------------------------------------------------------
// constructor
//--------------------------------------------------------------------------
@@ -153,6 +166,28 @@
}
//--------------------------------------------------------------------------
+ // FocusListener
+
//--------------------------------------------------------------------------
+
+ public void focusGained( FocusEvent event )
+ {
+ Component component = event.getComponent();
+ if( component instanceof AbstractButton )
+ {
+ ((AbstractButton)component).setBorderPainted( true );
+ }
+ }
+
+ public void focusLost( FocusEvent event )
+ {
+ Component component = event.getComponent();
+ if( component instanceof AbstractButton )
+ {
+ ((AbstractButton)component).setBorderPainted( false );
+ }
+ }
+
+
//--------------------------------------------------------------------------
// implementation
//--------------------------------------------------------------------------
@@ -176,6 +211,8 @@
panel.setBackground( Color.white );
panel.setSize( 700, 500 );
panel.setLayout( new FlowLayout( FlowLayout.LEFT ) );
+ m_panel = panel;
+ panel.addMouseListener( new BackgroundListener() );
//
// populate the panel with the entries declared in the configuration
@@ -240,23 +277,23 @@
throws DesktopException
{
Component component = getPluginComponent( uri );
+ component.setName( title );
ImageIcon icon = createImageIcon( component.getClass() );
- //JLabel label = new JLabel( icon );
- //label.setText( title );
- JToggleButton label = new JToggleButton( title, icon );
-
- label.setVerticalTextPosition( JLabel.BOTTOM );
- label.setHorizontalTextPosition( JLabel.CENTER );
- label.setFont( DEFAULT_FONT );
- label.setBackground( Color.white );
- label.setSize( 200, 35 );
-
- label.setBorderPainted( false );
- label.setFocusPainted( false );
- label.setContentAreaFilled( false );
+ JButton button = new JButton( title, icon );
+
+ button.setVerticalTextPosition( JLabel.BOTTOM );
+ button.setHorizontalTextPosition( JLabel.CENTER );
+ button.setFont( DEFAULT_FONT );
+ button.setBackground( Color.white );
+ button.setSize( 200, 35 );
+
+ button.setBorderPainted( false );
+ button.setFocusPainted( false );
+ button.setContentAreaFilled( false );
+ button.addFocusListener( this );
- return label;
+ return button;
}
protected static ImageIcon createImageIcon( Class clazz )
@@ -274,8 +311,6 @@
}
}
-
-
private Component getPluginComponent( URI uri ) throws DesktopException
{
try
@@ -313,4 +348,21 @@
{
return m_logger;
}
+
+ /**
+ * MouseEven listener that requests focus on the target component
+ * in response to a mouse click event. Used to clear the focus on
+ * container buttons within the content panel.
+ */
+ private static class BackgroundListener extends MouseAdapter
+ {
+ public void mouseClicked( MouseEvent event )
+ {
+ Component component = event.getComponent();
+ if( null != component )
+ {
+ component.requestFocus();
+ }
+ }
+ }
}
- svn commit: r1295 - in development/laboratory/mgr: main/src/main/net/dpml/mgr/main plugins/magic/src/main/net/dpml/mgr/magic plugins/metro/src/main/net/dpml/mgr/metro, mcconnell, 12/26/2004
Archive powered by MHonArc 2.6.24.