Trainee AES, (IE10) wrote:
>
> Hi Everyone,
> I want to add a JSplitPane in the openmap, can u plz help me how to do
> it. Map should be visible in only one pane.
> I am trying with OpenMapFframe.java, but unable to implement it.
you could:
- specialize the BasicMapPanel overiding the constructors and the
addMapBeanToPanel methods to create a panel with a JSplitPane 9one side
of which will contain the MapBean and the other side MapPanelChild(ren).
- create your own subclass of the OpenMap app to use your new
BasicMapPanel subclass.
- add a child to the JSplitPane by implementing the MapPanelChild
interface and ensuring it is added to the BeanContext (for example use
"extends OMComponentPanel implements MapPanelChild" which acheives both
these things).
- in your application, you would create a new OpenMap instance of the
subclass - say "YourOpenMap" - passing the PropertyHandler.
YourOpenMap app = new YourOpenMap();
in the attached code fragments for the new BasicMapPanel subclass, any
MapPanelChild with preferredLocation of BorderLayout.EAST is added to
the SplitPane while the MapBean itself is added to the right of the Pane
in the constructor.
hope this helps,
matt
--
public class SplitMapPanel extends BasicMapPanel {
/**
* JSplitPane containing the MapBean (right) and a MapPanelChild (left).
*/
protected JSplitPane splitPane = new JSplitPane();
public SplitMapPanel () {
super(false);
splitPane.setOneTouchExpandable(true);
splitPane.setDividerLocation(0.3);
add(splitPane, BorderLayout.CENTER);
splitPane.setRightComponent(mapBean);
}
/**
* Create a MapPanel that configures itself with the properties
* contained in the PropertyHandler provided. If the
* PropertyHandler is null, a new one will be created.
*/
public SplitMapPanel(PropertyHandler propertyHandler) {
super (propertyHandler, false);
splitPane.setOneTouchExpandable(true);
splitPane.setDividerLocation(0.3);
add(splitPane, BorderLayout.CENTER);
splitPane.setRightComponent(mapBean);
}
/**
* The mapBean is created in the super() constructor and adding of
* the component to the splitPane is deferred until the super()
* contructor completes. This is slightly unholy...
*/
protected void addMapBeanToPanel (MapBean map) {}
/**
* Add a child to the MapPanel.
*/
protected void addMapPanelChild (MapPanelChild mpc) {
String location = mpc.getPreferredLocation();
// Special handling to place the child in the JSpiltPane
// if EAST requested.
if (location.equals(BorderLayout.EAST)) {
splitPane.setLeftComponent((Component) mpc);
}
else {
add((Component) mpc, location);
}
}
}
--
public class YourOpenMap extends OpenMap {
/**
* Create a new OpenMap framework object - creates a MapPanel,
* OpenMapFrame, and brings up the layer palettes that are being
* told to be open at startup. The properties in the
* PropertyHandler will be used to configure the application.
* PropertyHandler may be null.
*/
public YourOpenMap(PropertyHandler propertyHandler) {
mapPanel = new SplitMapPanel(propertyHandler);
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
showInFrame();
}
});
}
}
ps: sorry if this arrives at the list twice... forgot to use a
subscribed email address. doh!
--
[To unsubscribe to this list send an email to "majdart@bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Tue Mar 23 21:24:45 2004
This archive was generated by hypermail 2.1.8 : Thu May 12 2005 - 07:18:38 EDT