JideButton and focus traversal

This is the forum for JIDE Common Layer which is open sourced at https://github.com/jidesoft/jide-oss. Please note, JIDE technical support doesn't monitor this forum as often as other forums. Please consider subscribe for technical support for JIDE Common Layer so that you can use customer only forum to get a timely response.

Moderator: JIDE Support

Forum rules
Community driven forum for open source JIDE Common Layer. JIDE technical support doesn't monitor this forum as often as other forums. If you only use JIDE Common Layer, please consider subscribing for technical support for JIDE Common Layer so that you can use customer only forum to get a timely response.

JideButton and focus traversal

Postby kirillcool » Mon Jun 30, 2008 8:07 pm

In the attached example, JideButton gets the focus with the Tab key but not on mouse click (unlike the core Swing button and checkbox):

[code]
package test.core;

import java.awt.FlowLayout;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;

import javax.swing.*;

import com.jidesoft.plaf.LookAndFeelFactory;
import com.jidesoft.swing.JideButton;

public class JideButtonFocus extends JFrame {
public JideButtonFocus() {
this.setLayout(new FlowLayout());
JButton coreButton = new JButton("core");
coreButton.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
System.out.println("Core button gained focus");
}

@Override
public void focusLost(FocusEvent e) {
System.out.println("Core button lost focus");
}
});

JCheckBox coreCheckbox = new JCheckBox("core");
coreCheckbox.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
System.out.println("Core checkbox gained focus");
}

@Override
public void focusLost(FocusEvent e) {
System.out.println("Core checkbox lost focus");
}
});

JideButton jideButton = new JideButton("jide");
jideButton.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
System.out.println("Jide button gained focus");
}

@Override
public void focusLost(FocusEvent e) {
System.out.println("Jide button lost focus");
}
});
this.add(coreButton);
this.add(coreCheckbox);
this.add(jideButton);

this.setSize(400, 200);
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

public static void main(String[] args) {
LookAndFeelFactory.installDefaultLookAndFeel();
LookAndFeelFactory.installJideExtension();
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
new JideButtonFocus().setVisible(true);
}
});
}

}
[/code]
kirillcool
 
Posts: 19
Joined: Wed Sep 21, 2005 12:45 am

Postby JIDE Support » Mon Jun 30, 2008 8:11 pm

I think that's correct because by default setRequestFocusEnabled(false) is called on JideButton. JideButtons are intended to be used on toolbar (or CommandBars in the case of JIDE Action Framework). Toolbar buttons are not supposed to grab focus when clicked.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Postby kirillcool » Mon Jun 30, 2008 8:22 pm

:)

Missed that line in the JideButton constructor.
kirillcool
 
Posts: 19
Joined: Wed Sep 21, 2005 12:45 am


Return to JIDE Common Layer Open Source Project Discussion (Community Driven)

Who is online

Users browsing this forum: No registered users and 56 guests