Newbie: should I use a JDialog or JPanel ?

I have inherited an app that is 50% complete and I need to add a new popup window that is displayed in response to a Pulldown menu selection.
The popup window will have 5 different text fields that will need to be passed back to the calling routine.
In the source code that I inherited, similar windows are created using a JDialog and sometimes using a JPanel (and I can't figure out why).
What are the upsides and downsides for choosing JDialog over JPanel ?
Thank you

This is a question of convenienve vs. reusability.
If you inherit your component from JDialog, it will be easy to set up the infrastructure:
- Return closes dialog:
  rootPane().setDefaultButton(yourButton)- Closing triggers your code:
  this.addWindowListener(myWindowListener}- Menu needed:
  this.setJMenuBar(myMenuBar) - ...
But the downside is, that you can't reuse your component (possibly together with other components) inside a JFrame.
Sven

Similar Messages

  • Newbie: Should I Use PersonalJava?

    Hey Guys:
    GOAL: Get a simple app running on an IPAQ, that eventually connects to a backend database.
    PROBLEM: Which VM and technology to use.
    DETAIL: After about a week of exploring J2ME for the 1st time, I thought having PersonalJava on the IPAQ was the correct start. Now I am reading more about Personal Profile(PP) (which claims to be aimed at, among other devices, PDA's like an IPAQ). It seems PP is intended to succeed PersonalJava?
    I tried to get the Source Bundle from https://javapartner.sun.com to play with, but it seems you need to be a partner? You can't newly register?
    As a simple Joe who wants to experiment, what should I be using to get something running on the IPAQ? PersonalJava? Personal Profile? Could someone offer a guidance word to a newbie?
    Thanks!
    Rob

    Read my reply in another topic concerning Personal Java; it could be of any use to you;
    http://forum.java.sun.com/thread.jsp?forum=56&thread=361821&tstart=0&trange=100
    kind regards

  • What component Should I use?, Jpanel doesn't work

    Hi
    I need a program that has a window that can go fullscreen and windowed (I did that with a Jframe in fullscreen mode with a jpnale and a 800x600 Jpanel and destroying them with an object that maneges them), I did it with a jframe that contained a Jpanel, I used a Jpanel to avoid the flickering on the screen but I also need to change the font type and the font size, but the setFont on the Jpanel doesn't change the font (as I have realized and also read here [http://forum.java.sun.com/thread.jspa?forumID=257&threadID=150588] ), so I'm lost, I might have to redo the whole thing, but I just wanted to know what component should I use for a window that is going to have custom graphics and need diffrent fonts and diffrent font sizes and work in fullscreen without flickering
    Thank you for your attention, I would aprecciate any help given

    for example:
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import java.awt.Font;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.RenderingHints;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JSlider;
    import javax.swing.event.ChangeEvent;
    import javax.swing.event.ChangeListener;
    public class JPanelFont extends JPanel
      private Font font = getFont();
      private String myString = "Fubars Rule";
      private int fontSize = font.getSize();
      private JSlider slider = new JSlider(0, 100, fontSize);
      public JPanelFont()
        setPreferredSize(new Dimension(620, 250));
        setLayout(new BorderLayout());
        JPanel inputPanel = createInputPanel();
        add(inputPanel, BorderLayout.SOUTH);
      private JPanel createInputPanel()
        JPanel ip = new JPanel();
        slider.setMajorTickSpacing(20);
        slider.setMinorTickSpacing(5);
        slider.setPaintTicks(true);
        slider.setPaintLabels(true);
        ip.add(slider);
        slider.addChangeListener(new ChangeListener()
          public void stateChanged(ChangeEvent evt)
            fontSize = (Integer)slider.getValue();
            repaint();
        return ip;
      @Override
      protected void paintComponent(Graphics g)
        Graphics2D g2 = (Graphics2D)g;
        Object originalHint = g2.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING);
        g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        super.paintComponent(g2);
        myPaint(g2);
        g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, originalHint);
      private void myPaint(Graphics2D g2)
        font = font.deriveFont(Font.BOLD, fontSize);
        g2.setFont(font);
        g2.drawString(myString, 20, 100);
      private static void createAndShowUI()
        JFrame frame = new JFrame("Dynamic JPanel Font");
        frame.getContentPane().add(new JPanelFont());
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
      public static void main(String[] args)
        java.awt.EventQueue.invokeLater(new Runnable()
          public void run()
            createAndShowUI();
    }Edited by: Encephalopathic on May 21, 2008 9:18 PM

  • Newbie question: Should I use iDVD o iMovie?

    I use a Sony camcorder with the mini-DV tapes. I have about 20 old tapes I'd like to turn into DVDs. This is my first time using iDVD or iMovie.
    I'd like to keep things simple: Download the movies to my iMac, make a handful of chapter points and burn to DVD.
    Not interested in adding soundtracks, trimming the clips, etc etc. Just keep it simple.
    Each 1 hour tape typically has about 8-12 individual clips of a few minutes each (all video is my little kids). I want to be able to access each clip via an upfront menu selection (like a normal movie DVD).
    Should I use iDVD to do this or iMovie??
    If iDVD, what are some starter tips for me. Thanks!!

    I am trying to download imovie06 but can only find updates? How do I find the actual program
    More info here.
    http://www.macworld.com/article/138476/goodbye_imovie6.html
    http://arstechnica.com/apple/news/2009/01/imovie-hd-fading-into-the-ether-as-app le-removes-download.ars

  • ProcesskeyEvent not invoked in JDialog andin JPanel

    I have overriden processKeyEvent in my class but this method never gets invoked on typing or pressing
    a key but the processMouseEvents are invoked properly the JDK Version which I am using is
    1.4.1_01 .Please guide what else should be done to handle key events for JDialog or Jpanel
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.KeyEvent;
    import java.awt.event.MouseEvent;
    * <p>Title: </p>
    * <p>Description: </p>
    * <p>Copyright: Copyright (c) 2004</p>
    * <p>Company: </p>
    * @author not attributable
    * @version 1.0
    public class TestDialog extends JDialog {
    public TestDialog(){
    this.getContentPane().setLayout(null);
    JButton jb = new JButton("HJHJH");
    jb.setBounds(10,10,100,30);
    this.getContentPane().add(jb);
    this.enableEvents(AWTEvent.KEY_EVENT_MASK |AWTEvent.MOUSE_EVENT_MASK);
    setSize(300,300);
    setVisible(true);
    public void processKeyEvent(KeyEvent keyEvent){
    System.out.println("Key Event Called");
    public void processMouseEvent(MouseEvent mouseEvent){
    System.out.println("Mouse Event Called");
    public static void main(String args[]){
    new TestDialog();

    Hi
    Any component is passed events through processXXX() methods only if the component has focus.
    Components like JPanel and JDialog never gain focus as the focus manager in java does not define focuses for a panel or JDialog . instead interactive comp.s like JButton , JTextField have focuses.
    Override the setVisible(boolean) method as
    public void setVisible(boolean b)
    super.setVisible(b);
    mycomp.grabFocus();
    After this do not click the mouse anywhere else , if clicked the focus will again be lost.
    try pressing keys and u'll know why it was happening.
    Have fun..
    Fire an reply trying this.
    RGDS

  • Should I use flex for my website

    Hey, I am having trouble figuring out if I should be using
    flex for a site similar to the BBC site:
    http://www.bbc.co.uk. I have
    started the site in flex but I am running into a lot of problems.
    It could be that I am a newbie to Flex, but wanted to make sure if
    I should still be going a head with this in Flex. Any advice would
    be appreciated.
    Thank you,
    Vinny

    "vinny31187" <[email protected]> wrote in
    message
    news:goaup9$9ta$[email protected]..
    > Hey, I am having trouble figuring out if I should be
    using flex for a site
    > similar to the BBC site:
    http://www.bbc.co.uk. I have
    started the site in
    > flex
    > but I am running into a lot of problems. It could be
    that I am a newbie to
    > Flex, but wanted to make sure if I should still be going
    a head with this
    > in
    > Flex. Any advice would be appreciated.
    I would say that if you don't know the answer to that
    question, then the
    answer is probably no. You need to have a pretty firm
    understanding of how
    sites like that work under the hood before trying to build
    one in Flex.

  • We have 4 iphones in our family and an Ipad.  When we purchase music I would like for the entire family to be able to use it.  Should each of us use a different apple account or should we use the same one.

    We have 4 iphones and an Ipad in our family. When we purchase music, I would like for the entire family to be able to use it and then back it up to Icloud. What is the best and cheapest way for this to happen.  Should we all have a different apple id or should we use the same one.

    You will all need to be on the same itunes account ID.
    You can however all have seperate icloud accounts aswel.

  • What type of hard disk should I use if I want to use it on mac and windows?

    Hey Forum,
    I am using windows xp on my macbook (snow leopard). I came across some dealers who say that there are hard disks for mac only and for both mac and windows. So, I wanted to buy a hard disk so that I can use it both on mac and windows xp, so what type of hard disk should I use? Must I partition into 2?
    or are there any harddisk in the market which is compatible for both mac and windows xp without screwing up the format(NTFS/Mac OS X Journaled)? Pls look into this matter and help me with it.
    All of your replies and suggestions is much appreciated.
    Thank you.
    Ala.

    Run, don't walk, from that dealer! and never look back
    Once in a very long while Apple will have customized firmware on drives, and it is possible to find SCSI/SAS or drives that are destined to be used with high end storage controllers.
    But that is the exception that makes the rule.
    SATA is SATA. Though.... there are now SATA III drives that don't work in XP, or that need a jumper, and Seagate and some drives have managed to deliver firmware that has caused trouble... and Apple has had to issue firmware updates to help compatibility....

  • Return under Warranty (Tracking Line only) Should we use MIGO - Goods Issue

    Return under Warranty (Tracking Line only) Should we use MIGO - Goods Issue when sending out Materials for repair or exchange under Warranty (Free)?

    Please post it in SD/MM forum.

  • I feel I must move beyond iMovie, what program should I use ?

    I have been happily using iMovie and iDVD from versions 1 through 6.  iMovie 08 was so bad that Apple made iMovie 06 available as a free download for buyers of iMovie 08. The newer iMovies were better, but they seemed “dumbed down” (even for me).  Now, I am shocked and horrified to learn that the latest iMovie does not even set chapter markers!
    So, I have continued to use iMovie 06 and iDVD 08 (they seem to work fine under OS 10.9.4).   iMovie 06 is now 8 years old!  I feel compelled to move forward. A lot of my work is DV.    In the past, most of my source material came out of S-Video.   I used a Canopus ADVC300 analog-to-digital converter that gave good results.   Going forward, I will have more video utilizing Component Video, or HDMI.
    I am looking into 2 possibilities,  Adobe Premiere elements 12, or.........Final Cut Pro X.
    The final result of my work is almost always a DVD.   It is hard for me to move from iMovie and iDVD.  I never read the manuals for either program, yet,  I was able to produce DVDs with nice menus and overall quality close to Hollywood.
    It looks like Final Cut Pro X 'can' make a DVD directly without other software.  However, from what I have seen on YouTube the result is primitive compared to what iDVD was doing 10 years ago.
    Adobe Premiere elements 12 can make nice DVDs and Blu-ray's directly.  I have no problem with using a separate program to make DVDs but I haven't got a clue how to do that with Final Cut Pro X.   I suppose I can still use iDVD, but now I'm back to using discontinued software.
    I do not need any of the high-powered affects capability that Final Cut Pro X  possesses.  My “movie-making” is mostly confined to simple editing (the old iMovie 06 did all I needed).
    Frankly, one motivation for choosing Final Cut Pro X, is the excellent, compassionate and understanding support that the kind people on this very forum provide.  So, what program should I use?

    Ziatron wrote:
    ...  I am shocked and horrified to learn that the latest iMovie does not even set chapter markers!
    .. I am looking into 2 possibilities,  Adobe Premiere elements 12, or.........Final Cut Pro X.
    The final result of my work is almost always a DVD. ...
    ... I do not need any of the high-powered affects capability that Final Cut Pro X  possesses.  My “movie-making” is mostly confined to simple editing (the old iMovie 06 did all I needed).
    to turn perspective for a second by 180°:
    Why do you want to switch to a new editor anyhow?
    • iM-a never did discs - that was iDVDs job = no big change in your workflow
    • iDVD is still working, and aside obsolete, complex and $$$$ DVDSP (part of obsolete FC/p) or Encore (part of Adobes CC rent package) your only option left to create disks on MacOS is indeed iDVD (...ok, there's Toast and Burn and some weird 'shareware'-stuff...)..
    • iMovie-b supports the new HDef formats (AVCHD) - you mentioned converters and DVDs = no HDef in use, in your habitat, correct?
    • if you don't need FCPX' bling-bling (I can't imagine that ) - why not using FCPX-lite = iMovie? 15$ ...
    • chapters could be done in iDVD - just to mention that ............
    • AP and FCPX are following very different concepts in usage - my personal preference is 200% on FCPX, … I was one of the loudest nay-sayers, when iM08 araised, meanwhile, FCPX is my dream!! AP (tested it) is way too complex, crowded, 'optionalized' and did I mention 'complex' for me. A bit like Windows vs. MacOS: 'everything goes' (incl. getting lost) vs. 'convenience' (incl. restrictions) ... After 2y of practice, I'm editing my weekly hobby-projects with 6-cam-Multicam, incl. tons of  custom graphics, slow-mow, effects (soccer games) in less than 2h ... awesome!
    summary:
    • why switching?
    • use iMovie10 + iDVD
    • Premiere (or Premiere Elements!) and FCPX are both avail as fee trial ... test  it - but you need iDVD anyhow
    • 'disks'  is a dwindling niché, for years!- consider to switch to 'other' distribution options
    ... what are 'chapters' anyhow??... (kid din'!)

  • Which C# Adobe library should I use to open a PDF in Acrobat Reader 9, 10, and 11?

    Hi, all.
    I have a Visual Studio C# application that writes an Adobe PDF using iText. Does anyone know how to programmatically open the PDF on client's computer and ensure it works for Adobe Reader 9, 10, and 11?
    -I have Adobe Reader XI on my machine and "Adobe Pdf Reader" is NOT showing up in my COM references. This is the library that I've heard people use for this.
    -The "Adobe Reader File Preview Type Library" is showing up there, but does not add to my project because of the following error message: "A reference to 'Adobe Reader File Preview Type Library' could not be added. Could not register the ActiveX type library....adoberfp.dll'." But I haven't persued this further becuase I'm not even convinced I should be using this library, which brings me to my next point:
    -Please don't tell me to go read the Adobe SDK spec. In searching for this answer, I found posts on here with people asking this question and getting not great answers, or half-*** answers to go read the Adobe SDK spec. I have the Adobe SDK spec, it's terrible. The example source code is laughably poor and reads like it was written by someone with bad english, with poor naming, commenting, and documentation, and there is no separate document that explains what the source code does. I think the reason people say this is because they haven't read it themselves and they don't know the answer and hope to deal with the question by handwaving. Sorry for the rant if you weren't going to do that!
    Thanks in advance, if anyone knows.
    -Brandon

    It will be from a client-side application, and I will be reviewing this further and get back on it. At this time my assembly isn't the correct type of 32-bit, which may be a deal-breaker. But downgrading it to 32-bit, I wasn't able to find or include the appropriate library for AXAcroPDF.
    Just a word about my trying to read the SDK documentation. The documentation folder has 5 items, a folder called "Javascript", an html file caled "Acrobat_11_SDK_Help_Shortcut.html", a zip file called "...HTMLHelp.zip," pdf_reference.pdf, and U3DElements.pdf. I've never heard of U3DElements, so surely that isn't meant for me. The pdf_reference.pdf, when opened, has three PDF links to two supplements to ISO 32000-1 and a document titled Document management. These describe the PDF spec, so that's not for me. So I must have to use the HTML documentation shortcut. I open it, and my browser says the redirect URL can't be found. Ah, may be that stuff in the ZIP file it's referencing. After unzipping it, you have to move the file around so that it actually references the right index.html inside the unzipped folders, and then even after this it loads up as two blank frames in my browser. I will look into why the links are all dead, but holy lord, this is just not very helpful at all.
    Thanks for your help, Test Screen Name.

  • Should I use one apple id with multiple devices?

    I have 2 iPods an iPad and a new iPhone. Should I use the same Apple ID on all decvices?  The iPods are for the kids to use. Also, will be adding apple tv soon...

    I registered my daughters two I touches using my apple I'd , but now told I should use separate IDs even though only my credit card is to be used when authorized by me.  As I try to figure this very confusing dilemma out, didninunderstand correctly that if I remove their devices now from my ID, they can't be associated with another device for 90 days?  Is their a walk thru tutorial somewhere about how to do this bc I'm beginning to think some mistakes are irreversible for 90 days if you try to figure it out and are wrong!

  • What query should I use to find all versions of Office 2013 64-bit installed on client computers?

    What query should I use to find all versions of Office 2013 64-bit installed on client computers? Could someone create a custom query? I need all of the client computers names and which ones have any Office 64-bit components. Thank you so much! I really
    appreciate it!

    Hi,
    You could edit the following query to meet your requirement.
    SELECT     dbo.v_R_System.Name0, dbo.v_GS_OPERATING_SYSTEM.Caption0 AS [Operating System],
                          dbo.v_GS_OPERATING_SYSTEM.CSDVersion0 AS [OS Service Pack], arp.DisplayName0,
                          CASE WHEN arp.version0 LIKE '11.0.6361.0' THEN 'SP1' WHEN arp.version0 LIKE '11.0.7969.0' THEN 'SP2' WHEN arp.version0 LIKE '11.0.8173.0'
    THEN 'SP3' WHEN
                           arp.version0 LIKE '12.0.6215.1000' THEN 'SP1' WHEN arp.version0 LIKE '12.0.6425.1000' THEN 'SP2' WHEN arp.version0 LIKE '14.0.6029.1000'
    THEN 'SP1' ELSE '' END
                           AS 'Service Pack', arp.Version0
    FROM         dbo.v_Add_Remove_Programs AS arp INNER JOIN
                          dbo.v_R_System ON arp.ResourceID = dbo.v_R_System.ResourceID INNER JOIN
                          dbo.v_RA_System_SMSInstalledSites AS ASSG ON dbo.v_R_System.ResourceID = ASSG.ResourceID INNER JOIN
                          dbo.v_GS_OPERATING_SYSTEM ON dbo.v_R_System.ResourceID = dbo.v_GS_OPERATING_SYSTEM.ResourceID
    WHERE     (arp.DisplayName0 LIKE '%Microsoft Office%edition%' OR
                          arp.DisplayName0 LIKE '%Microsoft Office Standard 2007%' OR
                          arp.DisplayName0 LIKE '%Microsoft Office Enterprise 2007%' OR
                          arp.DisplayName0 LIKE '%Microsoft Office Professional%2007%' OR
                          arp.DisplayName0 LIKE '%Microsoft Office Standard 2010%' OR
                          arp.DisplayName0 LIKE '%Microsoft Office Enterprise 2010%' OR
                          arp.DisplayName0 LIKE '%Microsoft Office Professional%2010%' OR
                          arp.DisplayName0 LIKE 'Microsoft Office 2000%' OR
                          arp.DisplayName0 LIKE 'Microsoft Office XP%') AND (arp.DisplayName0 NOT LIKE '%update%') AND
                          (arp.DisplayName0 NOT LIKE '%Microsoft Office XP Web Components') AND (dbo.v_R_System.Operating_System_Name_and0 NOT LIKE '%server%')
    AND
                          (arp.InstallDate0 NOT LIKE 'NULL')
    ORDER BY dbo.v_R_System.Name0, arp.DisplayName0, arp.Version0
    Full details:http://social.technet.microsoft.com/Forums/systemcenter/en-US/7baeb348-fb63-4115-8d76-2c884d18f708/sql-query-to-check-ms-office-service-pack-level?forum=configmgrreporting
    Best Regards,
    Joyce
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • I have an apple id for my ipod touch at home. My company is planning to issuing Ipads. Should I use the same apple id on the ipad for those apps I purchase and would like to purchase and use on my work ipad?

    I have an apple id for my ipod touch at home. My company is planning to issuing Ipads. Should I use the same apple id on the ipad for those apps I purchase and would like to use on my work ipad?

    Yes, otherwise you will have to pay for those apps again. If an app is purchased by one Apple ID, he/she will be able to redownload it again for no cost (note: this does apply to songs, but NOT to movies).

  • HT201088 I am considering starting Family Sharing.  Should I set up a new Apple ID for the Family Sharing or should I use my personal Apple ID?

    I am considering starting Family Sharing.  Should I set up a new Apple ID for Family Sharing or should I use my personal ID?

    On your Mac, try to access your gmail account. There should be a link you click for "Forgot My Password". Click it and try to retrieve your password.
     Cheers, Tom

Maybe you are looking for

  • Bring back iTunes syncing feature back!

    I don't mean to be the stickler, but I cannot believe Apple decided to force us to use iCloud for syncing contacts. If i had known that upgrading to Maverick would have caused such, I would never have done so. I have a lot of personal and sensitive i

  • ALV report - run in background and output to screen

    I wish to run a report in background and then output the report to screen as a standard ALV report with all the associated functionality. Can anyone tell me how to do this? Thanks.

  • How to run jsp in tomcat server

    hi this is satish1529, i am new to jsp technology,i have written small jsp file and html file,i don't know where to place jsp and html files in tomcat server and where i have to do setting in the server and how to run jsp file. pls give me step by st

  • Re: Deskjet 3070A - replaced cartridges but won't print now!

    Hello, I have the same problem. Replaced my black cartridge on my deskjet 3070A and now it won't print any black ink at all. Please can you help? Thanks, Tom

  • Photoshop_elements 11 - max number of pictures or file size

    Bonjour, J'ai actuellement environ 30 000 photos (200 Go) et environ 5000 de plus par an. J'ai 2 questions : 1) Depuis un certain temps, j'observe un ralentissement notable : lenteur au démarrage et à l'affichage du catalogue, lenteur à la reconnaiss