Results 1 to 3 of 3
  1. #1
    jicxicmic is offline Member
    Join Date
    Aug 2009
    Location
    Costa Brava
    Posts
    5
    Rep Power
    0

    Default Open jDialog problem

    Hi,

    I have a jDialog that I use to search over several tables depending on parameters. So I can instantiate to search customer, departments, etc.

    Now I want to add a new parameter to be able to add a button that opens the maintenance JDialog for the selected table, so if I instantiate the search jDialog to look for customers, when I press the button open the customers table jDialog,
    if I'm looking for departments, open the departments table jDialog.

    I think the best way should be pass the class to search dialog and from there instantiate the class, but my problem is I couldn't instantiate a class with two parameters the owner of window and the modal. Any knows how to do ?, I'm trying to avoid to have a hardcoded list of table dialogs nor pass and instantiated JDialog that most of the times wouldn't be used.

    and easy view that I want is this
    Class.forName(maintenancedialogname).newInstance(o wner,modal);

    PD:sorry for my poor english
    Last edited by jicxicmic; 11-13-2009 at 12:25 PM.

  2. #2
    sudquoslop is offline Member
    Join Date
    Nov 2009
    Posts
    1
    Rep Power
    0

    Default

    I think this is enough .....
    I do agree with you. Those are the most effective way

  3. #3
    jicxicmic is offline Member
    Join Date
    Aug 2009
    Location
    Costa Brava
    Posts
    5
    Rep Power
    0

    Default

    I've found the trick, here is the summary, of course need to Try/Catch.

    Java Code:
    //assign  to a variable the class of JDialog
    Class<? extends JDialog> mant = MyJDialog.class;
    
    //look for the constructor of the parameters I need
    Constructor<? extends JDialog> manteniment = mant.getConstructor(Frame.class, Boolean.TYPE);
    
    // instantiate the JDialog
    JDialog dialeg = manteniment.newInstance(MyApp.getMainFrame(), true);

Similar Threads

  1. Any workarounds for JPasswordField in JDialog bug?
    By dtmansy in forum Advanced Java
    Replies: 5
    Last Post: 02-24-2010, 12:56 AM
  2. window.open problem
    By praveenkumar14 in forum NetBeans
    Replies: 2
    Last Post: 10-12-2009, 12:18 PM
  3. Different Files Open in File -> Open Workspace
    By mgm2010 in forum JCreator
    Replies: 0
    Last Post: 04-11-2009, 03:14 PM
  4. setLocation on a JDialog is ignored
    By ScottVal in forum AWT / Swing
    Replies: 7
    Last Post: 01-13-2009, 08:35 AM
  5. help with jdialog
    By leonard in forum AWT / Swing
    Replies: 1
    Last Post: 08-05-2007, 06:37 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
  •