suggestions for declarative GUI programming in Java

前端 未结 14 1048
有刺的猬
有刺的猬 2020-12-07 09:39

I wonder if there are any suggestions for declarative GUI programming in Java. (I abhor visual-based GUI creator/editor software, but am getting a little tired of manually i

相关标签:
14条回答
  • 2020-12-07 10:26

    WindowBuilder, it a very nice plugin, which included GWT,XWT,SWT,Swing etc

    0 讨论(0)
  • 2020-12-07 10:28

    If conciseness is important you might want to consider the double brace idiom:

    new JFrame("My Frame") {{
        setName("myFrame");
        add(new JLabel("My First Label") {{
             setName("myLabel2");
        }};
        add(new JLabel("My Second Label") {{
             setName("myLabel2");
        }};
    }}
    

    You then don't lose any of the power of a well known general purpose programming language (you know you are going to need it, and JellyTags suck). All you need is the one little extra idiom.

    It's not used very much, because actually people pissing around with XML weren't solving real pain points.

    In general you can use builder layers to abstract repeated code. GUI code doesn't have to be badly written, it's just that almost all of it is (including in text books).

    0 讨论(0)
  • 2020-12-07 10:30

    You might have a look at javabuilders; it uses YAML to build Swing UIs.

    A simple example from the manual [PDF]:

    JFrame:
        name: myFrame
        title: My Frame
        content:
            - JLabel:
                name: myLabel2
                text: My First Label
            - JLabel:
                name: myLabel2
                text: My Second Label
    

    Alternatively:

    JFrame:
        name: myFrame
        title: My Frame
        content:
            - JLabel: {name: myLabel2, text: My First Label}
            - JLabel: {name: myLabel2, text: My Second Label}
    

    Or even:

    JFrame(name=myFrame,title=My Frame):
        - JLabel(name=myLabel2, text=My First Label)
        - JLabel(name=myLabel2, text=My Second Label)
    
    0 讨论(0)
  • 2020-12-07 10:33

    give Swiby a try: http://swiby.codehaus.org/

    "Swiby is a blend of Swing and Ruby for truly rich distributed applications." In other words Swiby is a domain specific language mixing swing and ruby.

    0 讨论(0)
  • 2020-12-07 10:33

    I can find the following examples of what you're asking for:

    • SWIXML
    • SwiXAT The Swing-XML Authoring Tool (based on SWIXML)
    • CookSwing: XML to Swing GUI
    • JFCML - JFC/Swing XML Markup Language
    • possibly JEasy, I'm not sure
    0 讨论(0)
  • 2020-12-07 10:34

    something new...XWT, will be included in eclipse e4

    0 讨论(0)
提交回复
热议问题