import java.awt.Frame; 
import java.awt.GraphicsConfiguration; 
import java.awt.Insets; 
import java.awt.Rectangle; 

import javax.swing.JFrame; 
import javax.swing.JLabel; 

public class TestMaximizedBounds { 

    public static void main( String[] args ) { 
        JFrame.setDefaultLookAndFeelDecorated( true ); 
        JFrame frame = new JFrame( "TestMaximizedBounds" ); 
        frame.getContentPane().add( new JLabel("TestMaximizedBounds") ); 
        frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); 

        // set a maximum bounds without the task bar 
        GraphicsConfiguration graphicsConfiguration = frame.getGraphicsConfiguration(); 
        Rectangle screenbounds = graphicsConfiguration.getBounds(); 
        Insets screenInsets = frame.getToolkit().getScreenInsets( graphicsConfiguration ); 
        frame.setMaximizedBounds( new Rectangle( screenInsets.left, screenInsets.top, screenbounds.width - screenInsets.left - screenInsets.right, screenbounds.height - screenInsets.top - screenInsets.bottom ) ); 
        frame.setExtendedState( Frame.MAXIMIZED_BOTH ); 

        frame.pack(); 
        frame.setVisible( true ); 
    } 
} 
