JDIalog, HTML Code, setLocationRelativeTo; not centered

Hi,
I am building my own modal dialog; it's a JLabel with formatted HTML Code - I only use the bold <b> and break <br> tag in the default font size and -type.
I use setLocationRelativeTo() to center the dialog to my main JFrame; however, the dialog is not centered, it's shifted down to the right. Even if I just use some letters in my HTML code the dialog isn't centered. Here is my code:
public class TDDialog extends JDialog implements ActionListener, WindowListener {
     private JPanel exercisePanel, containerPanel;
     private JLabel exerciseLabel;
     private JButton readyButton = new JButton("Ready");
     private JButton showSolutionButton = new JButton("Solution");
     private JTextField solutionTextfield;
     private String solutionString;
     private Font font = new Font("SansSerif", Font.PLAIN, 12);
     public TDDialog(Frame ownerFrame) {
          super(ownerFrame, true);
          addWindowListener(this);
          setTitle("Exercise");
          setLayout(new BorderLayout());
          exerciseLabel = new JLabel();
          exerciseLabel.setFont(font);
          exercisePanel = new JPanel();
          exercisePanel.add(exerciseLabel);
          solutionTextfield = new JTextField();
          solutionTextfield.addActionListener(this);
          containerPanel = new JPanel();
          containerPanel.setLayout(new BorderLayout());
          containerPanel.add(readyButton, BorderLayout.LINE_START);
          containerPanel.add(showSolutionButton, BorderLayout.CENTER);
          readyButton.setFont(font);
          showSolutionButton.setFont(font);
          readyButton.addActionListener(this);
          showSolutionButton.addActionListener(this);
          exerciseLabel.setText("<html><body>3 Lines<br><b>3 Lines</b><br>3 Lines<br></body></html>");
          add(exercisePanel, BorderLayout.PAGE_START);
          add(solutionTextfield, BorderLayout.CENTER);
          add(containerPanel, BorderLayout.PAGE_END);
          setResizable(false);
          pack();
          setLocationRelativeTo(ownerFrame);
          setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
// action- and window-listeners...Am I building the JDialog correctly? Is there a better, a more recommended or "nicer" way? Why isn't hte dialog centered?
Edit: I really would like to assign Duke Stars to my question, however, since the last forum maintenance, I can't do this any more "Server Error
This server has encountered an internal error which prevents it from fulfilling your request. The most likely cause is a misconfiguration. Please ask the administrator to look for messages in the server's error log." This happens every time at different PCs with different browsers / versions / proxy-settings.
Message was edited by:
SFL

Here is the missing part for a SSCCE; I noticed that the modal dialog is centered in relation to the screen, not to the "ownerFrame", although I pass ownerFrame to the setRelativeTo statement.
import java.awt.Dimension;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class GUI_Test extends JComponent implements MouseListener {
     private static final long serialVersionUID = 1L;
     private JPanel pmPanel = new JPanel();
     private TDDialog tdd = new TDDialog(GUI_Test.frame);
     private static JFrame frame;
     public GUI_Test() {
          addMouseListener(this);
          add(pmPanel);
     private static void createAndShowGUI() {
          JFrame.setDefaultLookAndFeelDecorated(true);
          frame = new JFrame();
          frame.setTitle("GUI_Test");
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          GUI_Test newContentPane = new GUI_Test();
          newContentPane.setOpaque(true);
          frame.setPreferredSize(new Dimension(500, 500));
          frame.setResizable(false);
          frame.setContentPane(newContentPane);
          frame.pack();
          frame.setVisible(true);
     public static void main(String[] args) {
          javax.swing.SwingUtilities.invokeLater(new Runnable() {
               public void run() {
                    createAndShowGUI();
     public void mouseClicked(MouseEvent arg0) {
          tdd.setVisible(true);
     public void mouseEntered(MouseEvent arg0) {}
     public void mouseExited(MouseEvent arg0) {}
     public void mousePressed(MouseEvent arg0) {}
     public void mouseReleased(MouseEvent arg0) {}
}Thanks for your help!

Similar Messages

  • Flash player file working in HTML but same HTML code is not working in JDEV

    Hello,
    I have a flash player file which is working just fine in a plain HTML. But not working at all in Jdeveloper's .jspx file. I have no idea what is the issue. Please help.
    Below is the code snippet. There is no way I can format the code snippet for more visual clarity in this editor. So I have to live with all minified code when it displays on the posting. Sorry :(.
    Thanks, Ruchir
    <html version="-//W3C//DTD HTML 4.01 Transitional//EN">
    <link href="css/jdeveloper.css" rel="stylesheet" media="screen"/>
    <link href="css/oracle.css" rel="stylesheet" media="screen"/>
    <body bgcolor="Black">
    <br> </br>
    <table align="left">
    <tr>
    <td>
    <object classid="CLSID:D27CDB6E-AE6D-11cf-96B8-444553540000"
    codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,22,0" ID="IncrediFlash" Width="560" Height="270">
    <param name="movie" value="cxs.swf?317338960"/>
    <param name="bgcolor" value="#000000"/>
    <!--<embed name="IncrediFlash" src="cxs.swf?317338960" bgcolor="#000000" width="560" height="270" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">-->
    </object>
    </td>
    </tr>
    </table>
    </body>
    </html>

    Don't have an answer for you, but you can put tags around your code so it's more readable... just use left-bracket code right-bracket and left-bracket code slash right-bracket around your code like this:
    <html version="-//W3C//DTD HTML 4.01 Transitional//EN"> 
    <link href="css/jdeveloper.css" rel="stylesheet" media="screen"/> 
    <link href="css/oracle.css" rel="stylesheet" media="screen"/> 
    <body bgcolor="Black">
    <table align="left"> <tr> <td>
    <object classid="CLSID:D27CDB6E-AE6D-11cf-96B8-444553540000"
    codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,22,0"
    ID="IncrediFlash"
    Width="560" Height="270">
    <param name="movie" value="cxs.swf?317338960"/>
    <param name="bgcolor" value="#000000"/>
    <!--<embed name="IncrediFlash"
    src="cxs.swf?317338960"
    bgcolor="#000000"
    width="560" height="270" type="application/x-shockwave-flash"
    pluginspage="http://www.macromedia.com/go/getflashplayer">-->
    </object> </td> </tr>
    </table>
    </body>
    </html>John

  • HTML Code will not generate Thumbnail image.

    For Months I have been using this html code to generate a thumbnail image on on of the pages on my site. It essentially creates a player for the podcasts that I create on www.buzzsprout.com. Buzz sprout our the ones that provide the html code to put on your site.
    Here is the code: <script src="http://www.buzzsprout.com/XXXXX.js?player=large&limit=1" type="text/javascript" charset="utf-8"></script>.
    The XXXXX in the code represent the numbers for the individuals podcast page where the podcasts are displayed once they have been uploaded to their site. Soon after the latest update I have been unable to generate a thumbnail image on my site using this code. Why is that?

    I am not sure what you mean be sharing a sample project. The website in question is www.ccont.com. Can't you create a page and paste the html code on it and see if it generates a thumbnail image. Use this html code that include my account number: <script src="http://www.buzzsprout.com/22782.js?player=large&limit=1" type="text/javascript" charset="utf-8"></script>

  • Is It Possible to Embed a PayPal Button with HTML Code and Not Widget?

    I noticed that Muse doesn't have a PayPal Subscribe button for monthly payments.
    PayPal can give me HTML code to embed the button in the website.
    Will the HTML code work if I embed it with Muse?

    Hello,
    Yes you can do that.
    Insert code in <Body> of Page:
    To insert HTML code in Body of page
    Open the page in design mode.
    Go to Object > Insert HTML.
    Past the code in the window and hit OK.
    To insert HTML code in <Head> of Page
    Open Page in design Mode
    Go to Page > Page Properties > Metadata > HTMl for Head
    Paste the code in HTML for <head> section and click OK
    Regards
    Vivek

  • Why html code is not working in JSP

    Hi,
    Iam using Reports 10g. I have created a simple employees report. I have added a listbox in the jsp page by adding small Html and javascript code like below.
    <form action="http://www.wwt.com/reports/rwservlet?10000_reports_listing&p_extranet=p_extranet" name="First" method="post">
    <select name="p_extranet" onChange="First.submit()" >
    <rw:foreach id="RGSOURCE" src="G_SOURCE">
    <rw:getValue id="mysource" src="SOURCE"/>
    <option value=""><%= mysource %>
    </rw:foreach>
    </select>
    </form>
    When I run this report in the report builder as Web layout, Listbox is displayed with values inside.
    But when I move it to Apps server and run it through URL,
    listbox is disappeared. Could you please tell me what is the problem?
    Thanks.

    Hi himanshu1979,
    <jsp:farward> is compulsary
    String destination;
    /* construct your destination url as you like */
    this.getServletContext().getRequestDispatcher(destination).forward(request,
    response);
    Browser is showing ur jsp from the cache.
    So you can instruct the browser not to do that by using
    <code>
    response.setHeader("Expires","0");
    </code>
    or
    <code>
    response.setHeader("Pragme","no-cache");
    </code>
    Regards,
    Tirumalarao
    Developer TechnicalSupport,
    Sun MicroSystem,India.

  • When previewed in browser or on the server the path of my web site repeats folders. However the "href" in the html code does not show the repetition in the path.

    If someone could help me on this one, this would be great. I am creating a web site that has several departments. I have categorized and saved each department in a main folder called "departments" and a subfolder for each one. In the Dreamweaver code view the pop-up menu links seem to show up properly, but when I preview in browser or upload to server "page not found" comes up because for some reason the address changes. Some parts of the address seem to be appearing twice, sometimes the entire path will appear twice as shown below:
    http://www.graphicmechanic.com/DEKALBCOUNTY/departments/parks-and-recreation/departments/p arks-and-recreation/pr-arabiamtn-map.html
    that is incorrect and it takes me to "web page cannot be found".
    It is obviously repeating the folders (hence the "departments/parks-and-recreation" twice. The correct link is:
    http://www.graphicmechanic.com/DEKALBCOUNTY/departments/parks-and-recreation/pr-arabiamtn- map.html
    The link issues are happening in the pop-up menu. For example if you go to http://www.graphicmechanic.com/DEKALBCOUNTY/departments/parks-and-recreation/pr-arabiamtn. html and rollover the link called "Arabia Mountain" in the links to the left side of the page, then click the pop-up menu link entitled "Arabia Mountain Map" that's where the problem occurs.
    Can anyone tell me how I can fix this problem. I don't know what I should do with the code since it already appears correct in html view.
    Please help if you can...
    Thanks in advance for any possible help you can provide...

    XonoBoom wrote:
    It is obviously repeating the folders (hence the "departments/parks-and-recreation" twice. The correct link is:
    http://www.graphicmechanic.com/DEKALBCOUNTY/departments/parks-and-recreation/pr- arabiamtn-map.html
    The link issues are happening in the pop-up menu.
    This problem usually happens when the menu is either a server-side include or a library item using links relative to the document. When you reference a page at a different level of the folder hierarchy, the document-relative links no longer point to the correct destination.
    Change the links in the menu to be relative to the site root.
    A document-relative link usually looks like this:
    <a href="../products/index.html">Products</a>
    A link relative to the site root begins with a forward slash like this:
    <a href="/products/index.html">Products</a>

  • HTML code does not display correctly

    Hi
    this is a common problem of mine - when i paste code into
    dreamweaver it stays code - it doesn't translate into the thing its
    suppposed to be . In this particular case, i'm trying to paste code
    in from youtube and its supposed to be an audio/visual viewer. but
    its code. I also pasted in a link from youtube and thats code too,
    any ideas?
    thanks
    patti

    This gives workarounds, and links to an extension that will
    restore a "paste
    as html" menu choice under Edit menu.
    See
    http://www.adobe.com/go/8d3c7fb0
    http://kb.adobe.com/support/dreamweaver/ts/documents/8d3c7fb0/CopyPasteHtml.
    mxp
    Alan
    Adobe Community Expert, dreamweaver
    http://www.adobe.com/communities/experts/

  • Ability to insert HTML code snippets not available

    Supposedly I can insert HTML into a file in Contribute but
    that option is grayed-out and can't be used. Does anyone know why
    that capability would not be functioning. I have the most recent
    version of Contribute and use it on a PC

    In the main menu go to:
    1. Edit, Administer Websites
    2. Users and Roles, click Edit Role Settings
    3. go to Editing
    4. check 'Allow HTML snippets insertion...' (last option)

  • Movies with iTunes Extras show only HTML code and not title screen when double clicked.

    I only noticed this after some iTunes updates.  Any movies that have iTunes Extras donot show the "Title Screen" when double clicked.  They only show HTML script.  I can still watch the movies, and can access the extras by going to the folder they are in, but thats a pain.  I have purchased other movies with extras since encountering the problem and have the same issue.  I run windows Vista on a 32-bit system. I have all updated drivers.  I have searched the web for an answer but couldnt find anything.  It is prob something insanely easy.  Any help would be appriciated.
    Example of text that appears when double clicking:
    <!doctype html>
    <html>
    <head>
         <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
         <meta name="hdtv-fullscreen" content="true" />     
         <meta name="hdtv-cursor-off" content="true" />          
         <title>Paul (Unrated) [2011]</title>          
         <!--      TuneKit      -->   
      <script type="text/javascript" src="TuneKit/src/TuneKit.js" charset="utf-8"></script>          
         <!--      Styles      -->     
         <link rel="stylesheet" href="css/shared.css" type="text/css" media="screen" />     
         <link rel="stylesheet" href="css/home.css" type="text/css" media="screen" />     
         <link rel="stylesheet" href="css/chapters.css" type="text/css" media="screen" />     
         <link rel="stylesheet" href="css/features.css" type="text/css" media="screen" />     
         <link rel="stylesheet" href="css/more.css" type="text/css" media="screen" />          
         <!--      Controllers      -->     
         <script type="text/javascript" src="controllers/data.js" charset="utf-8"></script>     
         <script type="text/javascript" src="controllers/home.js" charset="utf-8"></script>     
         <script type="text/javascript" src="controllers/chapters.js" charset="utf-8"></script>     
         <script type="text/javascript" src="controllers/features.js" charset="utf-8"></script>     
         <script type="text/javascript" src="controllers/more.js" charset="utf-8"></script>
    </head>
    <body>
         <div id="bleed">          
              <div id="navigation">             
                   <img id="pic0" class="picBLANK" src="images/home/Paul_mm_background_01.jpg"/>            
              <img id="pic1" class="picBLANK" src="images/home/Paul_mm_background_01.jpg"/>             
                   <img id="pic2" class="picBLANK" src="images/home/Paul_mm_background_02.jpg"/>            
              <img id="pic3" class="picBLANK" src="images/home/Paul_mm_background_03.jpg" />            
              <img id="pic4" class="picBLANK" src="images/home/Paul_mm_background_04.jpg" />            
              <img id="pic5" class="picBLANK" src="images/home/Paul_mm_background_05.jpg" />            
              <img id="pic6" class="picBLANK" src="images/home/Paul_mm_background_06.jpg" />            
              <img id="pic7" class="picBLANK" src="images/home/Paul_mm_background_07.jpg" />            
              <img id="pic8" class="picBLANK" src="images/home/Paul_mm_background_08.jpg" />            
              <img id="pic9" class="picBLANK" src="images/home/Paul_mm_background_09.jpg" />            
              <img id="pic10" class="picBLANK" src="images/home/Paul_mm_background_01.jpg" />             
                   <div id="vid" class="vid_bg">               
                        </div>          
              </div>     
         </div>
    </body>
    </html>

    The fix from this other post worked for me.
    https://discussions.apple.com/message/17691332#17691332
    FIX:
    Go into "Get Info" and set the Album name to the name of the movie for both the movie and the "Extra".  This will fix it.

  • PDF and column HTML code

    My report table include column with HTML format such as
    <a target="_blank" href="tableA.url">tableA.url</a>
    It works fine in dashbaord: I see the URL and when click on it, I got the URL in new window.
    When I export to PDF, the resulting PDF display the HTML code and not just the URL.
    Any ideas?

    user8257465 wrote:
    Hi,
    I tried to achieve this before without success. My conclussion was that the pdf converssion engine that OBIEE uses is not able to generate HTML code inside the pdf.
    Me too I will like to know if someone achieved this.
    Thanks,Unfortunately, your assessment is correct: when printing to pdf, the HTML codes are exposed rather than maintaining the functionality of the coding.

  • Some Mail messages show html code

    I am using Mail 6.2 and Gmail IMAP.  Some Mail that I move from my Inbox to another Mail folder part of the message appears in html code in the folder where I moved the message.  The html code did not appera while the message was in my In Box.  If I look at the message in Gmail, no html code appears and the message has the same lable as the Mail folder where I moved the message.  If i look at the message on my iPad there is no html code.  The problem only appears to happen within Apple Mail

    By the way, also, the html code is interpreted correctly by the html tester on the following web site:
    http://www.webtutorialplus.com/html-code-tester.aspx
    So it seems that perhaps a simple edit should make it compatible with Mail App.
    I have verified that all uninterpreted messages where all I see is html raw code, are interpreted and rendered beautifully by the tool at the link above.  All I need do is to coy and paste the body of the message.   So it seems that what is missing is something to trigger the interpretation in Mail App.   Right?

  • I have created a 468x60 animated banner in Edge Animate. How do I save the animated image to my desktop? (not in html code)

    I have created a 468x60 animated banner in Edge Animate. How do I save the animated image to my desktop? (not in html code)

    Hi,
    This feature is not available in Adobe Edge animate. You can not export as image from Edge animate.
    Publish options available in edge describe here
    Edge Animate Help | Publish your content
    Regards,
    Devendra

  • While in Edit Mode in Moodle - page content does not render at all, but I am able to display the underlying HTML code. Happens only after upgrade to Firefox 11.0.

    While in edit mode in the Moodle course management system, the Page Content window should display the page as it will appear to the user. If you click on the "Edit" button, you are able to view the HTML code for the page. However, when you return to the normal display mode, the page is blank. This has occurred after the upgrade to Firefox 11.0. Page is normally rendered in Internet Explorer.

    A possible cause is security software (firewall,anti-virus) that blocks or restricts Firefox or the plugin-container process without informing you, possibly after detecting changes (update) to the Firefox program.
    Remove all rules for Firefox and the plugin-container from the permissions list in the firewall and let your firewall ask again for permission to get full unrestricted access to internet for Firefox and the plugin-container process and the updater process.
    See:
    *https://support.mozilla.org/kb/Server+not+found
    *https://support.mozilla.org/kb/Firewalls
    See also:
    *http://kb.mozillazine.org/Error_loading_websites
    *https://support.mozilla.org/kb/Error+loading+web+sites

  • I started to learn HTML, and I'm using text edit and everything is going fine, when I save the file with a .html extension and open it with safari I only view the code and not the webpage that was supposed to be created.

    I started to learn HTML, and I'm using text edit and everything is going fine, when I save the file with a .html extension and open it with safari I only view the code and not the webpage that was supposed to be created.

    That is because you don't have a web server configured and running to serve the html page. In order to see the page in a browser you need to access it using a url similar to http://localhost/~yourUserName if you are serving the page from your user account.
    Prior to Mountain Lion you could go into web sharing and turn on the web server. With Mountain Lion there is no option, other than using terminal, to turn on the web server. The web sharing menu item has been removed in Mountain Lion. Apache is still on your computer but it will take a little searching these forums or the Internet to find how to turn it on.
    If you want a graphic user interface to turn on/off the Apache server you could download and install a server application like xampp, http://www.apachefriends.org/en/xampp.html. I use this and it works well.

  • I embedded some HTML code into adobe Muse but not displaying when the pages are Exporting to HTML

    I embedded some HTML code into adobe Muse and when I published the remote site on business catalyst the (Add This widget) HTML code shows up but when I exported the site to HTML pages and view the index page in the browser (Safari, Chrome, Firefox) the (Add this widget) HTML code wouldn't display on any of the pages. I've used this code before on other Muse sites not sure what could have happened. Thnx!!!

    Hi,
    Please take a look at this post for a similar discussion : Re: When i export my muse website my youtube video links stop working. Why is this?
    Regards,
    Aish

Maybe you are looking for

  • What's with the slow gets from my ResultSets?

    I have two databases, an Omnis and a MySQL. I'm trying to copy the data from the Omnis into the mysql, but the getXXX(int i) methods acting on my ResultSet are LUDICROUSLY slow... to transcribe a meager 2660 entires (with 15 columns) takes a staggeri

  • FAGLGVTR

    Dears        I need your help regarding the following issue; I used transaction FAGLGVTR  to carry fwd balance, the system stated that balance carry forward completed successfully, however, when I went to Tcode FBL3N, I found the balance of the RE  a

  • Why do I not have perspective warp?  I just downloaded the newest version of ps yesterday.

    I have the most recent version of photoshop ( Just downloaded it yesterday) and it is definitely up to date but cannot access perspective warp on the edit menu, the words are there in light grey but are not a link to anything. :/

  • Show/hide lots of layer, image swaps and page size

    Hi - I am working on a webpage that requires 39 thumbnails to show 39 large images when clicked and to also show some text on mouseover - take a look. http://www.redsea.co.nz/lipitor/slidekit.shtml I have been asked to use scrolling divs to house the

  • Software corrupt when installing LaView6.1 and IVI

    I have two problems. My computer operating system is Windows2000, Pentium 4. 1. When I installed LabView 6.1, a error message box showed the following information.I chose "Yes" to complete installation. Repeat trials were the same situations. MAX wor