notify-dpml AT lists.ibiblio.org
Subject: DPML Notify
List archive
svn commit: r1296 - development/laboratory/mgr/main/src/main/net/dpml/mgr/main
- From: mcconnell AT netcompartner.com
- To: notify-dpml AT lists.ibiblio.org
- Subject: svn commit: r1296 - development/laboratory/mgr/main/src/main/net/dpml/mgr/main
- Date: Sun, 26 Dec 2004 06:30:07 +0100
Author: mcconnell
Date: Sun Dec 26 06:30:07 2004
New Revision: 1296
Modified:
development/laboratory/mgr/main/src/main/net/dpml/mgr/main/DefaultDesktop.java
Log:
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:30:07 2004
@@ -22,6 +22,7 @@
import java.awt.Component;
import java.awt.Color;
import java.awt.FlowLayout;
+import java.awt.Container;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
@@ -104,6 +105,11 @@
*/
private JPanel m_panel;
+ /**
+ * The component holding focus.
+ */
+ private Component m_component;
+
//--------------------------------------------------------------------------
// constructor
//--------------------------------------------------------------------------
@@ -162,7 +168,7 @@
if( "quit".equals( e.getActionCommand() ) )
{
exit( 0 );
- }
+ }
}
//--------------------------------------------------------------------------
@@ -172,21 +178,41 @@
public void focusGained( FocusEvent event )
{
Component component = event.getComponent();
- if( component instanceof AbstractButton )
+ refocus( component );
+ }
+
+ public void focusLost( FocusEvent event )
+ {
+ }
+
+ private void refocus( Component component )
+ {
+ Component[] children = m_panel.getComponents();
+ for( int i=0; i<children.length; i++ )
{
- ((AbstractButton)component).setBorderPainted( true );
+ Component child = children[i];
+ if( child.equals( component ) )
+ {
+ ((AbstractButton)child).setBorderPainted( true );
+ defocus( child );
+ }
}
}
- public void focusLost( FocusEvent event )
+ private void defocus( Component component )
{
- Component component = event.getComponent();
- if( component instanceof AbstractButton )
+ Component[] children = m_panel.getComponents();
+ for( int i=0; i<children.length; i++ )
{
- ((AbstractButton)component).setBorderPainted( false );
+ Component child = children[i];
+ if( !child.equals( component ) )
+ {
+ ((AbstractButton)child).setBorderPainted( false );
+ }
}
}
+
//--------------------------------------------------------------------------
// implementation
//--------------------------------------------------------------------------
@@ -212,7 +238,7 @@
panel.setSize( 700, 500 );
panel.setLayout( new FlowLayout( FlowLayout.LEFT ) );
m_panel = panel;
- panel.addMouseListener( new BackgroundListener() );
+ panel.addMouseListener( new BackgroundListener( panel ) );
//
// populate the panel with the entries declared in the configuration
@@ -350,18 +376,32 @@
}
/**
- * MouseEven listener that requests focus on the target component
+ * MouseEvent 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
{
+ private Container m_container;
+
+ private BackgroundListener( Container container )
+ {
+ m_container = container;
+ }
+
public void mouseClicked( MouseEvent event )
{
Component component = event.getComponent();
- if( null != component )
+ component.requestFocus();
+
+ Component[] children = m_container.getComponents();
+ for( int i=0; i<children.length; i++ )
{
- component.requestFocus();
+ Component child = children[i];
+ if( child instanceof AbstractButton )
+ {
+ ((AbstractButton)child).setBorderPainted( false );
+ }
}
}
}
- svn commit: r1296 - development/laboratory/mgr/main/src/main/net/dpml/mgr/main, mcconnell, 12/26/2004
Archive powered by MHonArc 2.6.24.