Hi Jens, On the server-side, in your ULCScrollPane extension you can add a method that will set background color on the viewport.
Please see the snippet below. Thanks and regards, Janak >-----Original Message----- >From: [EMAIL PROTECTED] >[mailto:[EMAIL PROTECTED] Behalf Of Jens Gräulich >Sent: Wednesday, February 07, 2007 2:45 PM >To: [email protected] >Subject: [ULC-developer] Problem with ULCScrollPane Viewport > > >Hi, > >I would like to set the background color for the Viewport of an >ULCScrollPane. It seems to me, that this is not possible without a >client extension. Please find an example below. As I do not have a >getter/setter for the viewport (just the viewportview, which is my >table), I have no chance of setting it directly on the server side. >I have a workaround (below below) in my own client extension but I guess >this should be fixed elsewhere. Could you please have a look at it and >tell me if this is an ULC issue or whether I missed something. > >Kind regards >Jens > >EXAMPLE CODE > >public class ScrollPaneTestPlainULC extends AbstractApplication >{ > public void start() > { > ULCRootPane rootPane; > ULCTable table; > ULCScrollPane sc; > > rootPane=createRootPane(); > table = new ULCTable(getModel(), new String[]{"Name", "Initial", >"Sirname"}); > table.setAutoResizeMode(ULCTable.AUTO_RESIZE_OFF); //table now >is smaller than the viewport > table.setBackground(Color.white); > sc = new ULCScrollPane(table); > sc.setBackground(Color.white); > > rootPane.getContentPane().add(sc); > rootPane.getRootPane().setVisible(true); > } > > private ULCRootPane createRootPane() > { > ULCFrame frame = new ULCFrame(); > frame.setDefaultCloseOperation(ULCFrame.TERMINATE_ON_CLOSE); > return frame; > } > > private Object[][] getModel() > { > return new String[][]{ > {"Bruno", "T.", "Bear"}, > {"Bruno", "T.", "Bear"}, > {"Bruno", "T.", "Bear"}, > {"Bruno", "T.", "Bear"}, > {"Bruno", "T.", "Bear"}, > }; > } > > > public static void main(String[] args) > { > >DevelopmentRunner.setApplicationClass(ScrollPaneTestPlainULC.class); > DevelopmentRunner.run(); > } > > >} > > >WORKAROUND > > >public class UIAScrollPane extends UIScrollPane >{ > > public void setBackgroundColor(Color color) > { > super.setBackgroundColor(color); > getBasicScrollPane().getViewport().setBackground(color); > } > > > protected void postInitializeState() > { > super.postInitializeState(); > >getBasicScrollPane().getViewport().setBackground(getBasicScrollPane >().getBackground()); > } >} ---------------------------------------------------------------------------- - import com.ulcjava.base.application.AbstractApplication; import com.ulcjava.base.application.ULCFrame; import com.ulcjava.base.application.ULCRootPane; import com.ulcjava.base.application.ULCScrollPane; import com.ulcjava.base.application.ULCTable; import com.ulcjava.base.application.util.Color; import com.ulcjava.base.client.UIScrollPane; import com.ulcjava.base.development.DevelopmentRunner; public class ScrollPaneTestPlainULC extends AbstractApplication { public void start() { ULCRootPane rootPane; ULCTable table; ULCMyScrollPane sc; rootPane = createRootPane(); table = new ULCTable(getModel(), new String[] { "Name", "Initial", "Sirname" }); table.setAutoResizeMode(ULCTable.AUTO_RESIZE_OFF); // table now is smaller than the viewport table.setBackground(Color.white); sc = new ULCMyScrollPane(table); sc.setBackgroundOnViewport(Color.white); rootPane.getContentPane().add(sc); rootPane.getRootPane().setVisible(true); } private ULCRootPane createRootPane() { ULCFrame frame = new ULCFrame(); frame.setDefaultCloseOperation(ULCFrame.TERMINATE_ON_CLOSE); return frame; } private Object[][] getModel() { return new String[][] { { "Bruno", "T.", "Bear" }, { "Bruno", "T.", "Bear" }, { "Bruno", "T.", "Bear" }, { "Bruno", "T.", "Bear" }, { "Bruno", "T.", "Bear" }, }; } public static void main(String[] args) { DevelopmentRunner.setApplicationClass(ScrollPaneTestPlainULC.class); DevelopmentRunner.run(); } public static class UIMyScrollPane extends UIScrollPane { public void setBackgroundOnViewport(java.awt.Color color) { getBasicScrollPane().getViewport().setBackground(color); } } public static class ULCMyScrollPane extends ULCScrollPane { private Color fBackgroundOnViewport; public ULCMyScrollPane(ULCTable table) { super(table); } protected String typeString() { return UIMyScrollPane.class.getName(); } public void setBackgroundOnViewport(Color backGroundColor) { fBackgroundOnViewport = (Color)setStateUI("backgroundOnViewport", fBackgroundOnViewport, backGroundColor); } public Color getBackgroundOnViewport() { return fBackgroundOnViewport; } protected void uploadStateUI() { super.uploadStateUI(); setStateUI("backgroundOnViewport", null, fBackgroundOnViewport); } } } _______________________________________________ ULC-developer mailing list [email protected] http://lists.canoo.com/mailman/listinfo/ulc-developer
