• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Why isn't anything showing up on my JDialog?

 
Ranch Hand
Posts: 48
Firefox Browser Notepad Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have certain backgrounds with different colors to see which ones are showing up. I have called setVisible(true) on lots of components just in case that was it but it's not. What I'm not getting is why, in a similar program, everything is showing up but in this one, it's not. I did find an error I had made but I fixed it I think. But the problem is still persistent. Also, though I have BorderLayout for everything, I told it to just add it and not with the extra parameter for the layout position, then it shows my topPanel object but nothing in the topPanel object.

Why does the code below show up the stuff




but in here,




it doesn't?


The one thing I'm wondering, is, if it's because the first one has the objects all as class variables whereas the second one has all the objects local only to the constructor.

In that second, strangely not working, code sample, if I put

contentPane.add(topPanel);


it shows the yellow of the topPanel object. It doesn't show any subpanels or subcomponents. Just a blank yellow panel.


If, instead, I try and follow the BorderLayout and put

contentPane.add(topPanel, BorderLayout.NORTH);

then it shows the blue color of the content pane (meaning that my topPanel object isn't showing up at all.)

It doesn't show anything other than a blank blue panel if I do it this way.


Is this an IDE glitch (I've had such a thing happen once in JGrasp once before, where the same exact code worked in BlueJ, but JGrasp has less glitches in that area than Eclipse. )


In the class where I refer to the PageSetup class, I have a class level PageSetup object. It is declared outside the constructor, instantiated inside the constructor, and set to be visible inside of an anonymous ActionListener inside of the constructor.

No null pointers or anything, just that stuff isn't showing up on there in my JDialog subclass.


I had originally forgotten to add topPanel to the contentPane object, but even after I added it and fixed that error, it still isn't showing any of my JLabels, or even, I suspect, my other JPanel objects.

 
Paul Adcock
Ranch Hand
Posts: 48
Firefox Browser Notepad Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, I fixed it so now they all show. (I needed to look at both files at once. I saw what I had done differently in the first one. I hadn't called the add method in the second one in places I should have, and I was adding one to the West twice.)


However, now I have another question, one more important than the first one: Do I even need this for a page setup for a notepad thing?


I already have a print dialog, which, strangely enough, can do decimals for the margins even though Insets only takes integers, but my margin thing can't. I found that it already sets page headers and footers in the Page Setup tab of the print dialog.


I can still have the tab size in here, but, now I'm wondering, why does the setMargin() have to have 4 ints but when I set the margins in the print dialog, I can choose 0.15, 0,3, 0.5, 1.2 for instance, whereas I can't do that for setMargin()?

Is there some difference between the margins of the JTextComponent and the margins of the PrintDialog printout? Does setMargin() affect how the page is laid out in view or is it only visible when you print it and would have no effect on the view of the JTextComponent when merely looking at it or typing in it?

Why does one set require ints and the other allow doubles or floats?


Does setMargin only really make any visible difference in the formatting in the formatted JTextComponents (JFormattedTextField, JEditorPane, JTextPane, etc) before you print it out or does it affect the other kinds too?




 
Greenhorn
Posts: 4
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Print margins are around everything that is printed, and are in whatever print units you are using (points, mm, inches).

The margins on a text component specify the space between the border and text (space within the component), and are in screen pixels.

By the way, if you are still using jGRASP you can debug, then drag the JDialog variable out of the debug variables pane to see a "viewer" for it, which will show you the subcomponent outlines and allow you to hover over a component to see its component tree and component path to the root, along with the position and size of each component. This can be helpful in diagnosing layout problems, especially when many components have no border and the same background color.
 
Paul Adcock
Ranch Hand
Posts: 48
Firefox Browser Notepad Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Larry Barowski wrote:Print margins are around everything that is printed, and are in whatever print units you are using (points, mm, inches).

The margins on a text component specify the space between the border and text (space within the component), and are in screen pixels.

By the way, if you are still using jGRASP you can debug, then drag the JDialog variable out of the debug variables pane to see a "viewer" for it, which will show you the subcomponent outlines and allow you to hover over a component to see its component tree and component path to the root, along with the position and size of each component. This can be helpful in diagnosing layout problems, especially when many components have no border and the same background color.



That would explain why I couldn't tell a difference really just by changing the margins of the JTextComponent by 2. I fixed it so that everything is being added. (With lots of JPanels, it's easy to lose track of them and what you've done with them if you're not careful.)

 
Just let me do the talking. Ahem ... so ... you see ... we have this tiny ad...
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic