Jump to content
xisto Community
Sign in to follow this  
arunkumarhg

Java Swing Ui With Xml Java SWING UI With XML

Recommended Posts

Hi,Am in the field of IT since 3.6 yrs, and am fed up with the developing the repet of the code during the Swing GUI Developement.So i thought of writing the GUI Description in a XML FIle and parsing the XML Using the SAX Parser and Build the Swing GUI on the FLY, so that the developement cost of the GUI will reduce and the XML GUI Descriptions can be used as Templates.The XML File some thing look like follows.####################################<?xml version="1.0"?><Menus> <!-- The menu bar at the top of the frame --> <XMenuBar NAME="TopMenu"> <XMenu NAME="File" > <XMenuItem NAME="FileOpen" LABEL="Open..." XInvoker="test.TestInvoker"/> <XMenuItem NAME="FileSave" LABEL="Save"/> <XMenuItem NAME="FileSaveAs" LABEL="Save As..."/> <XMenuItem NAME="FileExit" LABEL="Exit"/> </XMenu> <XMenu NAME="Edit" XInvoker="EditHandler"> <XMenuItem NAME="EditUndo" LABEL="Undo"/> <XMenuItem NAME="EditCut" LABEL="Cut"/> <XMenuItem NAME="EditPaste" LABEL="Paste"/> <XMenuItem NAME="EditDelete" LABEL="Delete"/> <CheckboxMenuItem NAME="EditReadOnly" LABEL="Disable Button 1" XInvoker="Button1Enabler"/> </XMenu> <XMenu NAME="Help" XInvoker="HelpHandler"> <XMenuItem NAME="HelpAbout" LABEL="About"/> <XMenuItem NAME="HelpTutorial" LABEL="Tutorial"/> </XMenu> </XMenuBar> <PopupMenu NAME="Pop1" XInvoker="PopupHandler"> <XMenu NAME="Sub Menu 1" XInvoker="SubMenu1Handler"> <XMenuItem NAME="Item 1" COMMAND="Item One"/> <XMenuItem NAME="Item 2" COMMAND="Item Two"/> </XMenu> <XMenuItem NAME="Item 3" COMMAND="Item Three"/> <XMenuItem NAME="Item 4" COMMAND="Item Four"/> <XMenuItem NAME="Item 5" COMMAND="Item Five" XInvoker="com.javaworld.mar2000.sax.DynamicMenuItemHandler"/> </PopupMenu> </Menus>####################################This is for the Building the Menu bar.I want the Same procedures for the Frames, Panels, Buttons.Any Idea, any links, any resources please let me know.Please if any one already implemented this kind of thing plz help me out, and let me know.RegardsArunkumar.H.G

Share this post


Link to post
Share on other sites

Hi,This is the Some code snippet that what i expect to be at the final stage to build the menu bar.######################import javax.swing.*;public class XMenuDemo { public XMenuDemo() { CreateMenuBar CreateMenuBar = new CreateMenuBar(); JFrame frame = new JFrame(); frame.setJMenuBar(CreateMenuBar.getMenuBar("C:/SampleMenu.xml",frame)); frame.setSize(300,300); frame.show(); } public static void main(String args[]) { XMenuDemo XMenuDemo = new XMenuDemo(); }}##############################CreateMenuBar.getMenuBar method should take the XML file path and the parent frame and gimme back the JMenubar with all menu and Menu items.Please help me out .PLz....................

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.