Click to See Complete Forum and Search --> : L&F prevents displaying of horizontal scrollbar


beginner
October 6th, 1999, 08:13 AM
I tried running the code sample given by http://www.codeguru.com/java/Swing/index.shtml for
including a horizontal scrollbar. I also added a mouselistener to the list
of a combobox. The code runs fine displaying the horizontal scrollbar when necessary and capturing the mouse clicks. But, when I set the L&F to Windows L&F there was no sign of a horizontal scrollbar nor was I able to
capture mouse clicks. I am giving the code that I made use of.


import javax.swing.UIManager;
import javax.swing.SwingUtilities;
import javax.swing.plaf.basic.*;
import javax.swing.JComboBox;
import javax.swing.JScrollPane;
import javax.swing.ScrollPaneConstants;
import com.sun.java.swing.plaf.windows.*
import java.awt.event.*;

public class myCombo extends JComboBox{
public myCombo(){
super();
setUI(new myComboUI());


/* try {
UIManager.setLookAndFeel(
"com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch (Exception e) { }


SwingUtilities.updateComponentTreeUI(this);*/
} //end of default constructor

public class myComboUI extends WindowsComboBoxUI
{
protected ComboPopup createPopup()
{
BasicComboPopup popup = new BasicComboPopup(comboBox)
{
protected JScrollPane createScroller()
{
return new JScrollPane(list,
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED );
} //end of method createScroller

protected MouseListener createListMouseListener()
{
return new MouseAdapter) {
public void mouseClicked(MouseEvent e)
{
System.out.println("\n CLICKS " + e.getClickCount());
}
};
}
};
return popup;
} //end of createPopup
}//end of inner class myComboUI
}

The above code works fine without the commented lines. Please enlighten me.


Thanks