• 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
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

Swing graphic problem

 
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I've created a simple file editor program that just has a menubar and a JTextPane to show the text.
Problem:
- The paint/repaint method is not working properly and mouse movement and editing the text leaves "gaps".
- Using the menu leaves gaps too.
I think I should use double buffering to solve this problem, how would I go about it.. doublebuffer the whole JFrame? ( to fix the menu problem too)
Is this necessary on all Swing programs?
Thanks,
Terry
 
Terence Doyle
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ME AGAIN
I've just installed Jbuilder 5 and I get the same problem....
Could it be that it's my PC? Too little RAM ( I've only got 96Mb )?
....
 
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You might want to try posting your code, if you don't get a response.
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are mixing any AWT with your SWING components? That can cause similar problems.
------------------
Happy Coding,
Gregg Bolinger
 
Terence Doyle
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI Paul and Greg.
I managed to sort out the JBuilder problem ( the screen was on 16 bit res. and I changed it to 32 ). My program however still looks bad.
Greg:
I'm using a JFrame with a JMenuBar( which can call a JFileChooser ) and a JTextpane. There are no other graphic items.
I'm only importing java.awt.event for the menu EventListeners.
Anything else that may be causing this problem?
Thanks,
Terry
 
Terence Doyle
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI again.
This code produces bad graphics too.

Maybe its my PC.
Terry
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think I may see your problem. In your main you said menuTest mt = new menuTest. Take that out. public menuTest() is your constructor for that CLASS so it gets performed without instantiating it. I think maybe you are just doing an overkill on the JVM.

------------------
Happy Coding,
Gregg Bolinger
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not seeing it. Could you explain the gaps a little better. I copied your code and am not seeing gaps. If you want smaller text, change the font of your menu/menu items. If you want the distance between the menu items smaller use setMargin().
 
Terence Doyle
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Paul,
By 'gaps' I mean the mouse leaves a square trail behind the menu's text. That is, when the menu shades itself according to the L&F when you mouseover, in my case the shading is not complete. There is a gap in the shading which corresponds to the mouse position.
So did you see the menu's perfectly? If so, its my PC, because I tried my editor program on both W98 and Linux Suse 7.2 ( installed on separate hard disks).
Maybe its a graphic card problem.....

Terry,
 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Terence,
If it helps, I copied your code to my machine and the menu looks okay on my machine. Any problems with any other apps?
rick
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looks fine on mine too.
 
Terence Doyle
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
STRANGE!!!
Hi Greg and Paul.
I finally discovered it's nothing to do with code. If I start a swing app and then change the screen res. settings - to whatever the app looks perfect.
I'm not exactly sure why this happens but it's obviously a graphics card issue so I won't trouble this forum any longer.
Thanks for your help.
Bye,
Terry
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is no trouble. Just one of those things that make you say hmmmm.
 
Can't .... do .... plaid .... So I did this tiny ad instead:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic