Skip to Content.
Sympa Menu

notify-dpml - svn commit: r1298 - development/laboratory/mgr/main/src/main/net/dpml/mgr/main

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell AT netcompartner.com
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: svn commit: r1298 - development/laboratory/mgr/main/src/main/net/dpml/mgr/main
  • Date: Sun, 26 Dec 2004 08:54:06 +0100

Author: mcconnell
Date: Sun Dec 26 08:54:06 2004
New Revision: 1298

Modified:

development/laboratory/mgr/main/src/main/net/dpml/mgr/main/DefaultDesktop.java
Log:
more playing around with focus

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 08:54:06 2004
@@ -23,6 +23,7 @@
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Container;
+import java.awt.Window;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
@@ -167,19 +168,15 @@

public void focusGained( FocusEvent event )
{
- Component component = event.getComponent();
- ((AbstractButton)component).setBorderPainted( true );
+ System.out.println( "# GAINED" );
}

public void focusLost( FocusEvent event )
{
- if( !event.isTemporary() )
- {
- Component component = event.getComponent();
- ((AbstractButton)component).setBorderPainted( false );
- }
+ System.out.println( "# LOST" );
}

+

//--------------------------------------------------------------------------
// implementation

//--------------------------------------------------------------------------
@@ -205,6 +202,7 @@
panel.setSize( 700, 500 );
panel.setLayout( new FlowLayout( FlowLayout.LEFT ) );
panel.addMouseListener( new BackgroundListener() );
+ panel.setFocusCycleRoot( true );

//
// populate the panel with the entries declared in the configuration
@@ -241,7 +239,9 @@
DefaultMenuBar menubar = new DefaultMenuBar( DEFAULT_FONT, this );
setJMenuBar( menubar );
setSize( 700, 500 );
+ //addWindowListener( new WindowHandler( this ) );
setVisible( true );
+
}

private URI getEntryURI( Configuration entry ) throws DesktopException
@@ -268,9 +268,8 @@
private Component constructDesktopIcon( final URI uri, final String
title )
throws DesktopException
{
- Component component = getPluginComponent( uri );
- component.setName( title );
- ImageIcon icon = createImageIcon( component.getClass() );
+ Class component = getPluginClass( uri );
+ ImageIcon icon = createImageIcon( component );

JButton button = new JButton( title, icon );

@@ -283,7 +282,7 @@
button.setBorderPainted( false );
button.setFocusPainted( false );
button.setContentAreaFilled( false );
- button.addFocusListener( this );
+ button.addFocusListener( new FocusHandler() );
button.addMouseListener( new ClickListener() );

return button;
@@ -304,23 +303,12 @@
}
}

- private Component getPluginComponent( URI uri ) throws DesktopException
+ private Class getPluginClass( URI uri ) throws DesktopException
{
try
{
ClassLoader classloader = DefaultDesktop.class.getClassLoader();
- Map map = new Hashtable();
- map.put( "urn:dpml.mgr.action-listener", this );
- Map params = new Dictionary( map );
- return (Component) m_repository.getPlugin( classloader, uri, new
Object[]{ params } );
- }
- catch( ClassCastException e )
- {
- final String error =
- "Cannot load desktop plugin ["
- + uri
- + "] because it does not implement the java.awt.Component
interface.";
- throw new DesktopException( error, e );
+ return m_repository.getPluginClass( classloader, uri );
}
catch( Throwable e )
{
@@ -349,7 +337,7 @@
*/
private static class BackgroundListener extends MouseAdapter
{
- public void mouseClicked( MouseEvent event )
+ public void mousePressed( MouseEvent event )
{
Component component = event.getComponent();
component.requestFocus();
@@ -357,8 +345,8 @@
}

/**
- * MouseEvent listener that handles doubleclick events on buttons within
- * the content panel.
+ * MouseEvent listener that listens for doubleclick events on buttons
+ * within the content panel.
*/
private static class ClickListener extends MouseAdapter
{
@@ -368,7 +356,29 @@
int n = event.getClickCount();
if( n > 1 )
{
- System.out.println( "# DOUBLE-CLICK: " + component );
+ System.out.println( "# double-click" );
+ }
+ }
+ }
+
+ /**
+ * Focsus listener on buttons in the content panel that plays around
+ * with borders to reflect focussed state of the target.
+ */
+ private static class FocusHandler implements FocusListener
+ {
+ public void focusGained( FocusEvent event )
+ {
+ Component component = event.getComponent();
+ ((AbstractButton)component).setBorderPainted( true );
+ }
+
+ public void focusLost( FocusEvent event )
+ {
+ if( !event.isTemporary() )
+ {
+ Component component = event.getComponent();
+ ((AbstractButton)component).setBorderPainted( false );
}
}
}



  • svn commit: r1298 - development/laboratory/mgr/main/src/main/net/dpml/mgr/main, mcconnell, 12/26/2004

Archive powered by MHonArc 2.6.24.

Top of Page