Results 1 to 5 of 5
  1. #1
    javahoush is offline Member
    Join Date
    Dec 2009
    Posts
    2
    Rep Power
    0

    Default How to show new window after click on button

    hello,

    I'm totally new to swt and have the following question:

    How can I create a button that if I click on it another window(dialog-shell?) appears and stays in front?
    The typical use case where you click on a button and have to fill in some data before you can continue.

    I would be very thankfull for a short codesnipplet.
    harald

  2. #2
    AndreB's Avatar
    AndreB is offline Senior Member
    Join Date
    Dec 2009
    Location
    Stuttgart, Germany
    Posts
    114
    Rep Power
    0

    Default

    yes a dialog may be suffcient; depends on how much you want to do with your ui.
    see dialogs for details (maybe TitleAreaDialog?)
    Or you can try JFace Wizards which are also very powerfull
    "There is no foolproof thing; fools are too smart."
    "Why can't you solve my Problem ?"

  3. #3
    AndreB's Avatar
    AndreB is offline Senior Member
    Join Date
    Dec 2009
    Location
    Stuttgart, Germany
    Posts
    114
    Rep Power
    0

    Default

    "There is no foolproof thing; fools are too smart."
    "Why can't you solve my Problem ?"

  4. #4
    javahoush is offline Member
    Join Date
    Dec 2009
    Posts
    2
    Rep Power
    0

    Default

    4 follow-ups:

    1. If you want to construct a new window after a Button is clicked, is it really just as easy as creating a Shell in the EventListener of that Button?

    2. Another problem is that all these references in the anonymous classes (Listeners) have to be made final - how do you get around that?

    3. You could put all the Labels, Texts, Lists and so on in one method or even in main, but obviously this is soon going to blow up. Is there a best practice for organizing your widgets/controls - e.g. each Shell in a seperate method or each composite?

    4. Generally I see now that I really don't know anything about gui-development, is there a good book/source on design principles/patterns for gui-development?

    thx!
    Last edited by javahoush; 12-29-2009 at 04:24 AM.

  5. #5
    AndreB's Avatar
    AndreB is offline Senior Member
    Join Date
    Dec 2009
    Location
    Stuttgart, Germany
    Posts
    114
    Rep Power
    0

    Default

    1. Yes. That is enough. But remember: you have to care about disposing resources yourself; don't forget to dispose the Shell if you don't need it anymore.

    2. You can provide (prtected upwards) methods in your class which return desired objects. You then can call the methods in the anonymous class. But again that can get out of hand into bad programming practice.

    3. A nice method i encountered was creating logical ui building blocks (extends Composite) which realize some self-contained application functionality. Then put various such building blocks together an privde communication beween them. But there exist some several other techniques; create another thread in java-advaced sub forum.

    4. gui development is a hard, underestimated and thankless task. :-)
    In my opinion the Eclipse SWT and Plugin Framework make it much easier (see Tutrial from vogella Eclipse RCP - Tutorial (Eclipse 3.5). But again, post these questions in java advaced sub forum. You propably get more answers.
    "There is no foolproof thing; fools are too smart."
    "Why can't you solve my Problem ?"

Similar Threads

  1. How do i show all the values in one window(JOptionPane)??
    By Antonioj1015 in forum Advanced Java
    Replies: 1
    Last Post: 11-25-2009, 04:17 PM
  2. How can I display on Button click?
    By ntagrafix in forum New To Java
    Replies: 3
    Last Post: 11-04-2009, 12:05 AM
  3. JPanel: Show Tooltip on click
    By knuth in forum New To Java
    Replies: 2
    Last Post: 10-01-2009, 04:46 PM
  4. Generate csv file on a button click
    By violeta in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 09-27-2009, 02:54 AM
  5. deselecting a button after the click.
    By ramsrocker in forum New To Java
    Replies: 10
    Last Post: 02-15-2009, 06:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •