Appropriate or Inappropriate use of JDialog?

Hi! I'm simply trying to get some text from a JDialog as input by a user. I would like to show my code and have someone tell me if it is appropriate or not. It does work, but I want to be sure I'm doing it correctly.
Here's the code:
public class InputBox extends JDialog {
     private     JTextField mText;
     public InputBox() {
          super();
          this.setSize(260,140);
          addWidgets();
          this.setLocation(200,200);
          this.setModal(true);
     private void addWidgets() {
          SpringLayout pLyt = new SpringLayout();
          JPanel panel = new JPanel(pLyt);
          JLabel lbl = new JLabel("Enter formula...");
          mText = new JTextField(20);
          JButton ok = new JButton(" OK ");
          JButton cancel = new JButton("Cancel");
          ok.setSize(50,100);
          panel.add(lbl);
          panel.add(mText);
          panel.add(ok);
          panel.add(cancel);
          pLyt.putConstraint(SpringLayout.NORTH, lbl, 10, SpringLayout.NORTH, panel);
          pLyt.putConstraint(SpringLayout.WEST, lbl, 15, SpringLayout.WEST, panel);          
          pLyt.putConstraint(SpringLayout.NORTH, mText, 5, SpringLayout.SOUTH, lbl);
          pLyt.putConstraint(SpringLayout.WEST, mText, 15, SpringLayout.WEST, panel);
          pLyt.putConstraint(SpringLayout.WEST, ok, 50, SpringLayout.WEST, panel);
          pLyt.putConstraint(SpringLayout.NORTH, ok, 15, SpringLayout.SOUTH, mText);
          pLyt.putConstraint(SpringLayout.NORTH, cancel, 15, SpringLayout.SOUTH, mText);          
          pLyt.putConstraint(SpringLayout.WEST, cancel, 15, SpringLayout.EAST, ok);          
          this.getContentPane().add(panel);
          cancel.addActionListener(new ActionListener() {
                         public void actionPerformed(ActionEvent args) {
                              this.setVisible(false);
          ok.addActionListener(new ActionListener() {
                         public void actionPerformed(ActionEvent args) {
                              this.setVisible(false);
     public String showDialog() {
          this.setVisible(true);
          return mText.getText();          
Also,
how do I display code on this forum so it is displayed nicely?
THanks for any help!

JOptionPane.showMessageDialog(null,"<html>The important thing is that whatever<br> you do teaches you something new</html>");

Similar Messages

  • 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

  • Use a JDialog as ToolTip

    Hi,
    First, I want to thanks every contributor of these amazing forums. Secondly, I want to know if is possible to use a JDialog as a Component's Tooltip. The reason for this, its that I want to display an information and I need the be able to click on the tooltip, to go to the clicked information. Any help will be appreciate it. Thanks in advance.
    PS. Sorry for my English, hope is understandable.
    With Regards,
    Miguel

    Hi camickr,
    Thanks for your fast reply I have already override the getToolTip method (for tool tip refresh purposes). The JEditorPane is a great idea, but how i use it in the getToolTip method of my components if the expected return type shopuld be JToolTip.
    PS. I am already using HTML in the tool tip for formatting purposes and to use a icon. It is possible to call a method within the HTML? My problem is that I'm displaying (in the tool tip) information from a JTable and I want to be able to click on a part of the text (what could be a jLabel in the Editor Pane) and as soon as the click happens I want to set the select row of the JTable corresponding to the clicked information.
    Thanks in advance
    Miguel
    Edited by: miguelNieves0714 on Apr 16, 2009 2:14 PM

  • Which APP is most appropriate to be used immediately after a fresh clean Windows install?

    Hi,
    The product Name of my computer is: HP Pavilion dv6-6093ex Entertainment
    Notebook PC support
    The number of my computer is : LM610EA#A2N.
    I know to install the required drivers for my notebook computer, I will need to use the HP Recovery Manager; which will install the original software and hardware drivers that first came with my notebook. To do this, please follow this document on Using Recovery Manager to Restore Software and Drivers (Windows 7), as well as (Windows 8 and 8.1).
    To update the drivers on my computer to the latest software, I recommend following this document on Using HP Support Assistant (Windows 7) as well as (Windows 8 and 8.1).
    However, 
    First: my primary goal is to know which HP tool is most appropriate for locating, obtaining, and installing all appropriate drivers, updates, etc. immediately after a clean new Windows 7 or 8.1 installation.
    I know that HP support assistant helps to download the updates for existing sotware, and drivers. However, if I made a fresh installation of widows, there wouldn't be existing drivers or software, then  Which one is most appropriate to be used immediately after a fresh new clean Windows install?? -- to determine, retrieve, and install all the appropriate drivers??
    Second: How to save/transfer/export/move the Drivers and Application built-in HP Recovery Manager onto a HDD Or a disc(DVD/CD). So, in case I have delted the HP Recovery Manager, and installed a new Windows 7 installation, then I would be using these Drivers and Applications saved on a HDD or Disc to retrieve, and install all the appropriate dirvers and applications?
    Finally: All rivers and Application built-in HP Recovery Manager are saved as NON-SoftPaq on a folder called SwSetup. So could I download all rivers and Application built-in HP Recovery Manager as a SoftPaq.

    How are you starting X?   That shows that X started successfully, but the program that controls X, generally your desktop environment exited.
    If you are using startx or Xinit, please post your ~/.xinitrc file

  • What is an appropriate method to use spool data for further processing?

    Hello SCN!
    First of all, i am new to both: ABAP & SCN. So please be considerate
    I have a given spool and want to search for specific error lines in it to use the information for futher processing. I already serached for answers, but maybe with the wrong keywords. Therefore i have some questions:
    What is the basic principle spools are stored in the SAP-System? I already found the tables tsp01, tsp02... but i dont understand the basic concept. For example i dont know where the spool content itself is provided.
    What is the best way to get spool data in my ABAP program? I testet RSPO_RETURN_ABAP_SPOOLJOB with a positive result, but i am not sure if this is a good way for large spools. And maybe there are better ways i would be pleased to hear.
    Is it common to use spools in the way i plan it, or must i rethink my approach. Catch my lines in the spool generation process for example, but this would be pretty hard in my concrete case...
    I am looking foreward to your suggestions and i am thankful for every input.

    What is the basic principle spools are stored in the SAP-System? I already found the tables tsp01, tsp02... but i dont understand the basic concept. For example i dont know where the spool content itself is provided.
    Spools and information on those are stored in database and sometimes in file system (AL11)
    Header entry in table TST01 (TemSe objects)
    Object associated with the header entry; it can be stored in the file system or in the database table TST03 (TemSe data of the object)
    Entry in table TSP01 (spool requests)
    Entry in table TSP02, if output requests exist
    What is the best way to get spool data in my ABAP program? I testet RSPO_RETURN_ABAP_SPOOLJOB with a positive result, but i am not sure if this is a good way for large spools. And maybe there are better ways i would be pleased to hear.
    This FM will perform well for ABAP list, and you may get problem with spools generated by tools like Smartforms or Sap Script
    Is it common to use spools in the way i plan it, or must i rethink my approach. Catch my lines in the spool generation process for example, but this would be pretty hard in my concrete case...
    For error log processing, look at tools related to a transaction as SLG1, and documents like Create application log. Use of spool report if manual processing expected.
    Regards,
    Raymond

  • Appropriate pattern to use

    Hi,
    I have a class which uses various pieces of information to form an object. I'm a bit concerned that the method I've written to produce the object is rather bulky - it takes in a number of parameters so the list is quite lengthy. In terms of readability, it doesn't rate very highly. The problem is that the data required to produce the final object comes from a number of different source objects and, as such, I'm passing in each of these objects to the method which does a load of processing before constructing the final object at the end.
    Is there a better approach? I've considered splitting the method in two but then it would mean the object would be in a unfinished form.
    Thanks for any thoughts.

    Also the Builder pattern can be used. You pass the parameters separately to the builder object and at the end, provided it has all the required parameters, it'll give you out your complete object.

  • Never used JWindow&JDialog and was very happy

    Hi guys!
    I am stuck on simple task. I wanted to place my jpanel into jwin or jdialog so this panel could resize and be dragged inside the JFrame. It would look very neat. Of course I don't want the stupid title bar.
    JWindow turned out to be not resizable and non-movable. Well, I saw people put mouse listeners on it but it does not solve resizability problem.
    JDialog (1.4 jdk) when undecorated is also not resizable (.setResizable(true))and not movable.
    Do you have any idea how to accomplish this task? Will be very grateful.

    I did my best and got almost what I wanted. Some things depend on their native implementations. Nothing I could do.
    I think that JWindows and JDialog are very tricky and devious components. One should stay away from them as far as possible because it's very difficult to make them do what you want: be simple, draggable, freely resizable and stay on top of their owner.

  • Inappropriate use of SDN business card/user data

    Received this by email...note reference to the SDN site....Not sure what can be done, but if this person can be identified, perhaps can have access to user email address removed?
    Hello dearest one,
    how are you doing? i hope you are fine my name is Zenab Benson single girl never married before,i got your e-mail address on (sdn.sap.com) You have an interesting profile there.i am writing you because i believe one can find a very nice, understanding and God fearing friend in this social network created for responsible people like you.i hope to hear from you so that i can tell you more about my self with love and trust and as well give you my photo,please kindly reply me back with so that i can tell you more about my self and also for further conversation. I will be waiting for your mail soon
    My regards to your family.
    your faithfully
    Zenab

    Congrats, you also got a mail, I am still waiting
    SDN provides hide option for all email details, once check and hide your details.
    you  meet some more friends here Be AWARE-->SPAM mails being sent refering to SDN
    "but if this person can be identified"
    please share details here
    Thanks
    mahesh

  • Is there a way to use a statically defined appearance stream in a dynamically created annotation?

    Hello,
    I want to create a document with cascading 'popups'.  Not the built-in text-only popup, but an annotation containing an appearance stream that defines text and images.  I'm currently using widget annotations based on a pushbutton field.
    Each page in my document has many citations that refer to other pages in the document.  When a user hovers over the citation, I want a 'popup' to appear containing a depiction of the destination.  However, as the destination will itself have citations, I also want the 'popup' to contain citations that the user can hover over, triggering another popup, etc.  In this way, a user could navigate throughout the document without leaving the page or even clicking the mouse.
    Obviously, with even a modest number of citations per page, pre-calculating and statically defining all of these widgets causes a combinatorial explosion, making the document sluggish and very large.
    Instead, I'd like to statically define appearance streams once per document, and then dynamically create annotations and assign the appropriate appearance stream using JS as the user navigates.
    So far I've created a named AP in the names dictionary, but I haven't been able to use it to dynamically set an appearance stream of a dynamically created widget annotation.
    Also, I've called Doc.getIcon(), passing in the named AP, which returns an Icon object.  However, after field.buttonSetIcon() and passing in the named AP, the button does not display the icon.
    Is there a way to use a statically defined appearance stream in a dynamically created annotation?
    Thank you,
    Dave

    Hi George, I've gotten named APs to work, and I expect hidden buttons will follow.  Thank you very much!
    Quick follow-up - I will have many documents embedded within the same pdf file, and some of these documents will contain identical popups.  However, I don't want to store identical icons in each document on account of file size.
    Instead, I'd like to store one instance of each icon for all documents in the file.
    Can I store all of the icons in a single document, and then access them by calling <DocName>.getField().getIcon() from any document in the file?
    Thank you again,
    Dave

  • Open a JDialog from an JApplet

    Hello,
    I have an applet and I want to open a separate window. The problem is that I want this window to be modal, and therefore I have to use a JDialog, but a JDialog needs an owner that can only be a JFrame or a JDialog, so I cannot use the JApplet as an owner. I tried to set the owner to null, but then if the user changes the focus to another window in his/her OS, and then returns to the browser, the JDialog does not reappear, so the applet is stuck!
    Does anybody have an idea how I can solve this problem?
    Thanks very much.

    Yes, cuz all applets have a frame....
    Frame f =
    (Frame)SwingUtilities.getAncestorOfClass(Frame.class,
    this);Thank you very much. I will try this solution.

  • How do I set background color of cell using JTable?

    Hello all!
    I have a question on the use of JTables. I am using a JDialog consisting of a JTable and a number of buttons to insert and to select OK or cancel. Everything is working perfectly, but I now must add editing capabilities to prevent invalid data being used in a SQL query to update or insert rows.
    So far I can't figure out how to get at a cell to set the background to red if the user inputs a Date incorrectly. Upon setValueAt(), I take this value and check for standard format errors. I hope to someday convert the column altogether to a Data object (or some form since Date is deprecated):-) For the time being, I know when an error occurs, but don't have the foggiest idea how to render the error (set backround to red).
    I need to give you more info too, since the way we do things is to make it as complicated as possible for job security and to impress the newbies(or scare them back to COBOL). When I setValueAt(), I have a DefaultDataElement object that houses everything for a given column in DB2. It has column name, length, data type, is it new, original value, current value, etc. If one doesn't exist, then I create one. After all said and done, I parse thru these elements and build my update/insert query and then execute the query.
    The event starts as soon as the user presses the OK button. But, if a date cell contains an invalid date, I need to halt processing (which I've done) and somehow let the user know which cell was invalid. We consider our users dumb (they really aren't, but the assumption is made), so I can't just say "error occurred in table. Verify data and try again". That won't work:-) Gotta be able to show them what cell is bad.
    Any ideas?
    Thanks,
    Patrick

    I finally figured it out. I was always close, but it wasn't until late yesterday that the light bulb came on. I was setting the background on the component in getTableCellEditorComponent() by grabbing the super.getTableCellEditorComponent(). The problem was all this was located in an editor, not renderer. So what happened was as I edited the cell the check would be performed then, not as focus was lost. When focus was lost, the red background went back to normal.
    I ripped the code out and made a custom renderer and got closer. Problem was the whole column had a red background. Even specifying the row and column in getTableCellRendererComponent didn't apply just to that cell. That row and column is only for obtaining the data in the cell, but anything affecting the component will affect the column, since I added the renderer to my TableColumn:-) I need to add error logic to my model and when an error occurs, set a boolean flag in a 2 dimensional array where the row and column is used to get to it from the renderer.
    Thanks for the help!!!

  • SSRS 2008 R2 - Using Action to call a report with MultiValue Parameters

    I have a report uses project names as parameter(Multi value) and display some data. I want to call this report from some other report on a click (drill down). This report has a program row where it aggregates the data, underneath Programs, I have
    list of projects(group). When I use Action on the individual projects, it takes me to the appropriate project ( I used
    Fields!ProjectName.Value). However, when user clicks on the program, it should pass the group of projects within that program to the called report. With expression,  Fields!ProjectName.Value, it only select one random project (may be first/last from
    the query) and display records. I tried Join(Fields!ProjectName.Value, ",") and Fields!ProjectName.Value(0) but now it doesn't select a sengle project. Can someone help please?

    use In instead =

  • Syntax for using a variable in an equation.

    Hi all,
    Simple question here.  What is tha appropriate syntax for using a variable in a calculation equation.  Specifically, I am taking an established curve fitting equation from my channels and trying to calculate it over a lineargenerated data set to extend the curve  beyond the original data sample.  Here is the small portion of script I have that will not work.  Thanks for any help.
    dim a,b,c
    a = Data.Root.ChannelGroups(5).Channels("air consumption formula").Properties("ResultApprAnsatzCoef1").Value
    b = Data.Root.ChannelGroups(5).Channels("air consumption formula").Properties("ResultApprAnsatzCoef2").Value
    c = Data.Root.ChannelGroups(5).Channels("air consumption formula").Properties("ResultApprAnsatzCoef3").Value
    Call Calculate("Ch(""[5]/Air Consumption LG"")= ""a"" + Ch(""[5]/LinearGenerated"")*""b""+""c""*ch(""[5]/LinearGenerated"")^2")

    Hi Gloorious,
    I am using diadem script.  In my example above, for the equation, if I substitue a,b,and c with numerical values, the script runs just fine and the formula executes as desired.  Is there a way to place the variables there instead as I have tried to do (I was hoping it was just a syntax issue) or do I have to approach it a completely different way?
    This script will execute just fine:
    Call Calculate("Ch(""[5]/Air Consumption LG"")= 4 + Ch(""[5]/LinearGenerated"")*5+6*ch(""[5]/LinearGenerated"")^2")
    but this will not:
    dim a,b,c
    a = Data.Root.ChannelGroups(5).Channels("air consumption formula").Properties("ResultApprAnsatzCoef1").Value
    b = Data.Root.ChannelGroups(5).Channels("air consumption formula").Properties("ResultApprAnsatzCoef2").Value
    c = Data.Root.ChannelGroups(5).Channels("air consumption formula").Properties("ResultApprAnsatzCoef3").Value
    Call Calculate("Ch(""[5]/Air Consumption LG"")= ""a"" + Ch(""[5]/LinearGenerated"")*""b""+""c""*ch(""[5]/LinearGenerated"")^2")

  • Port Forwarding For WinXP (RDC) (Using AE 802.11n)

    I have some problem and I need some thoughts and input from someone else, Here goes.
    Here is what im looking to accomplish. From my work I want to be able to connect into my machine at home (windows XP). I cannot use the standard RDC (Remote Desktop Connection) port 3389. My work blocks all traffic coming through that port. So I need to push it through port 443. My co-worker is doing this just fine with a Netgear switch at home, so I know it should work.
    In theory it should work like this.
    (In Windows XP I have done this)
    Change the registry to move through port 443 (windows web site actually shows you how to do this). I turned off the windows firewall completely. RDC has also been turned on. A static IP has been given to this machine as well
    (Airport Extreme I have done this)
    Put a static ip and Mac address for the Windows machine. Turned on NAT and Forwarded the UDP and TCP ports for public and Private to port 443. As well as set the private IP adders in the port forwarding to the ip on the windows machine.
    (Current results)
    I think this is where the beginning of my problem and im not sure if its a windows or a AE problem. Before changing the port on the windows machine I can RDC locally. But cannot get through the AE on the default port 3389.
    After changing the port on the windows machine to 443 I can no longer RDC locally and still cannot connect from out side the AE.
    Im not sure where to take it from here. Please advise someone im dying to cruse the net from work

    Hello Preston Holder. Welcome to the Apple Discussions!
    As you are already aware RDC clients listen on port 3389 by default.
    To change the listening port will require making a Registry mod. This would be typically used if you needed to access more than one computer remotely. (ref: Microsoft Knowledge Base article 306759)
    Locate the appropriate Registry key using Regedit.exe:
    HKEYLOCALMACHINE\System\CurrentControlSet\Control\TerminalServer\WinStations\RDP-Tcp\Port Number
    From the Edit menu, click Modify and then click Decimal. Choose a new port number. In general, choosing a number between 49152 and 65535 will avoid conflict with any other apps on your system, but you could theoretically use any port on the system. Once you set the port number you also need to configure your router to pass the specified port to your computer.
    To access your computer remotely, instead of typing just the IP address, you need to type the IP address followed by the port number like this: 192.168.1.1:50001

  • Problems installing Windows 7 using Boot Camp

    I have a brand new MBP Retina laptop (late 2013) with 256GB SSD. Today I tried to use Bootcamp Assistant to partition the SSD and install Windows 7 64 bit OS.
    My first attempt was using a licensed Windows 7 64 bit installation DVD and my OWC external optical drive which is recognized in Finder:
    I started Boot Camp Assistant, selected the boxes to download latest Windows Support Software from Apple and to Install Windows 7. I was asked to specify the size for the Windows partition and hit continue. The process was moving along, the  computer restarted and then I got a black screen with a blinking white cursor (like a command line prompt) in the upper left corner of the screen and a message to press any key to reboot. Pressing any key did nothing.
    As far as I could tell, the Support Software files that were on the USB drive did get installed prior to the first reboot of the system that happens after you allocate the size for the partition. After the first reboot I never got the Windows installer though, just the hanging black screen/cursor mentioned above.
    I'm wondering if, after creating the partition and restarting, my computer can't see my external optical drive even though it does show up in Finder when booted to OSX because it was not reading the Win7 Install DVD at all.
    While on the phone with Apple Senior Tech Support we rebooted several times holding down the Alt/Option key. The boot options were the OSX, Recovery, Windows, and EFI Boot. Choosing Windows resulted in the trackpad locking up and it just hung there. I ended up reverting the SSD back to a single partition for now.
    After some discussion on the Apple forum I tried creating an ISO file from the Win7 64 bit DVD using ImgBurn software that I have installed on my Windows PC  and ImgBurn indicated it had created a bootable ISO file. I copied the ISO file to the downloads folder on the MBP, plugged the empty USB drive into the MBP and tried Boot Camp Assistant again:
    Choosing the appropriate option for use with an ISO file on a USB drive Boot Camp Assistant proceed to again create the partition, asked me to size it, and then it proceeded (over approximately an hour and a half) to work on copying the ISO file to the USB drive and downloaded the Support Software to the USB drive.
    After the restart I got another black screen, cursor, and the messages, "No bootable device/drive found", "Press any key to reboot". Again pressing any key did not do anything. I reverted back to a single partition again, rebooted to OSX and gave up for the night.
    Bottom line in either scenario is that I never get to the Windows installer screens to even attempt to install Windows on the new partition.
    QUESTIONS:
    I think in my situation it doesn't appear that ImgBurn created a bootable ISO file from my Win7 install DVD. The Apple Bootcamp Setup guide refers to downloading the ISO image from Microsoft but I couldn't find anything that I would be comfortable downloading.
    I'd rather use my installation DVD for Windows but why isn't that process of reading the DVD from the external drive working after the restart?
    Can the ISO file and Windows Support Software live on the same USB drive during installation and does the support software get installed automatically by boot camp assistant?
    What am I doing wrong here? This shouldn't be this hard especially when I own a valid copy of Windows.
    This is VERY frustrating. Any help or referrals to proper instruction is very much appreciated.

    I was able to successfully complete the installation of Windows 7 Home Premium using Boot Camp. Turns out the problem was the Windows 7 ISO image I was initially trying to use. I called Microsoft tech support and they sent me a link (see below) from which I downloaded the Windows 7 Home Premium 64 bit ISO image. After downloading the ISO image and restarting Boot Camp Assistant the process of Boot Camp preparing and transferring the ISO image and Windows Support software to the USB drive took about 45 minutes and then everything went smoothly from there. The only thing I encountered was when I was asked what drive to install Windows on I got a message that it couldn't install on the Boot Camp drive because it needed to be in NTFS format. I clicked on the format button and then the process continued. After Windows installed the Windows Support Software from Apple started to install automatically. So far it is working well.
    http://answers.microsoft.com/en-us/windows/forum/windows_7-windows_install/windo ws-7-home-premium-64bit-iso-download/709dcc12-d120-435d-91cd-52e1dd0f4c24

Maybe you are looking for

  • Windows 8 installation: expanding files stuck

    I've got a problem with the installtion of Windows 8 on my Macbook Pro (Late 2011), with (MOUNTAIN LION) i've followed the instructions with bootcamp etc, and when ever it reaches the Expanding Files section, it stucks at 19%. And i've waited for lik

  • Remove I Tunes from Hard Drive

    Sorry I am not too pc literate. I am freeing up some space on my hard drive and have found the following programs: ipod for Windows 2005-03-23 Size 163MB ipod for Windows 2005-06-26 Size 163MB and ipod for Windows 2005-09-23 Size 163MB When I try and

  • Assigning DNS addresses from Radius on LNS

    Hi we have a router which acts as an LNS and authenticates LT2P sessions via radius assigning each to a tunnel interface and giving it an IP address, we would also like to assign DNS settings via radius, we are using steel belted radius which is capa

  • Strange JTable update problems

    I am having some strange issues with a JTable. I have a custom AbstractTableModel that displays various properties of a list of Objects. I am using a java.util.Vector to store this list. The user is given several JComboBox objects which contain filte

  • Can't find Detail preserving upscale effect in After Effects CC

    Hello house, I recently needed to use the detail preserving upscale effect for a project but it seems my version of After Effects CC does not have it. How can I go about getting it please? Thank you.