Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JFrame covering taskbar in maximized mode....

 
Manoj Amrutkar
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am having following problem in my swing gui based application.
When i maximized my JFrame It's covering taskbar. I have found out half the solution. I am using
JFrame.setDefaultLookAndFeelDecorated(true);
in constructor. And when i commented that thing the issue has been solved but only partially. Now the problem is the look and feel of the frame is chaged to window which was motif previously.
So can i get that motif look and feel somewhere else.(If without frame covering taskbar).

Thanks in Advance...

Manoj Amrutkar
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try this, but the 30 is just a guess at the taskbar height

 
Manoj Amrutkar
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your response but still it does not solve the problem as soon as i maximize the window the taskbar gets covered up.
After some more r and d i found out this if i do like this
import javax.swing.*;
import java.awt.*;

public class Testing
{
public Testing()
{
JFrame.setDefaultLookAndFeelDecorated(true);
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setExtendedState(JFrame.MAXIMIZED_BOTH);////<--------covers taskbar
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
f.setSize(d.width, d.height-30);//<---take 30 off the height
f.setVisible(true);
Rectangle r = new Rectangle(0,0,d.width, d.height-30);
f.setMaximizedBounds(r);
}
public static void main(String[] args){new Testing();}
}

that solved my problem but some how the borders of the frame are looking thiker. I anybody has any solution plz suggest it to me

thanks in advance

Manoj Amrutkar
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> it does not solve the problem as soon as i maximize the window....

if you just want the frame to be at either maximized-30, or iconified,
change
f.setSize(d.width, d.height-30);
Rectangle r = new Rectangle(0,0,d.width, d.height-30);
f.setMaximizedBounds(r);
f.setVisible(true);

to
f.setSize(d.width, d.height-30);
f.setResizable(false);//<-----------
f.setVisible(true);

now, all you can do is minimize to task bar or at maximized-30
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic