Pessoal,
Já procurei sobre o assunto e não tive êxito então vou tentar postar aqui para obter uma possível ideia do problema.
Vamos ao causo, implementei um Viewer para uma aplicação em Swing compilada na versão 1.5.0_15.. funcionando normalmente mas recentemente migrei a versão da maquina do usuário para 1.6 14 e o ComboBox existente passou a não se comportar direito.
Como funciona?
O ComboBox exibe uma lista de documentos e quando selecionado um item, exibimos a imagem correspondente ao documento.
Fato!
Após a migração ocorrer ao selecionar um item, nada ocorre.. a combo não dispara nenhum evento mais.. nem exceptions. nada de nada
O que já fiz?
Tentei compilar tudo novamente na versão 1.6 porem tb nao ajudo...
Procurei no forum da Oracle e só achei tiros no escuro ou pessoas dizendo que é um bug...
Segue a implementação da Combo a chamada para obter a seleção do item
public void actionPerformed(CommandEvent event) {
switch (event.getId()) {
case Command.ACTION_TYPEDOC: {
String type = (String) ((JComboBox) southTool.getControl("typeCombo")).getSelectedItem();
break;
}..
.
}
}
import java.awt.Font;
import java.awt.event.ItemListener;
import javax.swing.JComboBox;
import javax.swing.JPopupMenu;
import javax.swing.JWindow;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
/**
* This class extends the default swing combo box to provide some new features.
*
* @author Johnnys
* @see JComboBox
*/
public class ToolComboBox extends JComboBox implements PopupMenuListener {
private int command;
/**
* This window is set as invoker of the popup menu of the combo box.
* Setting it as invoker of the popup (instead of the default invoker), avoids the problem that occurs when the combo is open over an OLE components.
*/
private static final JWindow window = new JWindow();
/**
* Builds a tool bar combo box.
*
* @param command the command ID fired by the combo box
* @param action the listener of the combo box.
*/
public ToolComboBox(int command, ItemListener action) {
super();
this.command = command;
setFont(new Font("Tahoma", Font.BOLD, 12));
addItemListener(action);
// to fix the problem that occurs when the combo box is open over an OLE component
addPopupMenuListener(this);
}
/**
* Gets the command ID that the button fires.
*
* @return the command ID
*/
public int getCommand() {
return command;
}
/**
* Sets the command ID that the button fires.
*
* @param command the command ID
*/
public void setCommand(int command) {
this.command = command;
}
/**
* This method is called before the popup menu becomes visible.
*
* @param e the event
*/
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
Object popup = getUI().getAccessibleChild(this, 0);
if (!(popup instanceof JPopupMenu))
return;
((JPopupMenu)popup).setInvoker(window);
}
/**
* This method is called before the popup menu becomes invisible.
*
* @param e the event
*/
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
}
/**
* This method is called when the popup menu is canceled
*
* @param e the event
*/
public void popupMenuCanceled(PopupMenuEvent e) {
}
}
Desde já agradeço
Abraço!
