Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Hide/remove maximize button on JFrame.

Posted on 2003-11-18
8
Medium Priority
?
7,373 Views
Last Modified: 2012-06-27
G'day everyone.

I have a JFrame which I wish to remove or completely hide the Maximize button (on top right hand corner) yet leave the Minimize and Close buttons still showing.

I've tried a few things such as setting resizable to false ( frame.setResizable(false); ) but that just seems to disable the button not hide it completely.

I have also tried using a JDialog instead of a JFrame but that seems to just show the close button, not the minimize.

Points to anyone who can show me the code to achieve what i want.

Cheers!

Howie
0
Comment
Question by:Howie_Ly
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
8 Comments
 
LVL 92

Expert Comment

by:objects
ID: 9776247
Think you'll need to handle painting the title bar yourself to achieve that.
0
 
LVL 4

Author Comment

by:Howie_Ly
ID: 9776277
Hi objects.  I did suspect as much.

Seems like such a simple thing though..  have you stumbled upon any code which will help me?
0
 
LVL 15

Accepted Solution

by:
Javatm earned 150 total points
ID: 9776278
>> I wish to remove or completely hide the Maximize button

     This is not possible on JFrame unless you no how to do painting method

     What you could do however is to use JInternaFrame cause Internal Frames
     is allowed to not to display the maximize button, something like this :

     // Set up the components by true or false
     JInternalFrame x = new JInternalFrame(false,true,false,true);
 
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 4

Author Comment

by:Howie_Ly
ID: 9776426
Hi Javatm, I've just had a play with JInternalFrame and as you said it does remove the minimize button.

But the main window remains open when you click minimize and close... are you suggesting i catch the event and pass it over to the parent?  also i can't seem to find where i get rid of the title bar from the parent frame.  One more thing, i have a LAF and it renders internal frames quite ugly...

I still prefer Object's proposed method at this stage.. as to avoid the above complications.  Just like someone to post some code on how to get that working.

0
 
LVL 15

Expert Comment

by:Javatm
ID: 9776551
Try this :

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class Word extends JWindow {

 public Word()
  {
  super("Word Processor . . .");
 
  JDesktopPane p1 = new JDesktopPane();
  JInternalFrame f1 = new JInternalFrame("",false,true,false,true);

  JTextArea txt1 = new JTextArea();
  txt1.setSize(300,300);

  f1.add(new JScrollPane(txt1));
  f1.show();
  p1.add(f1);
   
  getContentPane().setLayout( new BorderLayout() );
  getContentPane().add( p1, BorderLayout.CENTER);

  setSize(500, 500);
  show();
  }

 public static void main (String args[])
  {
   Word x = new Word();
   x.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }
 }
0
 
LVL 15

Expert Comment

by:Javatm
ID: 9776575
Sorry I remebered that we are JWindow for us to remove the Titlebar
Its like this actually :

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class Word extends JWindow {

 public Word()
  {
  JDesktopPane p1 = new JDesktopPane();
  JInternalFrame f1 = new JInternalFrame("Sample . . .",false,true,false,true);

  JTextArea txt1 = new JTextArea();
  txt1.setSize(300,300);

  f1.add(new JScrollPane(txt1));
  f1.show();
  p1.add(f1);
   
  getContentPane().setLayout( new BorderLayout() );
  getContentPane().add( p1, BorderLayout.CENTER);

  setSize(500, 500);
  show();
  }

 public static void main (String args[])
  {
      Word x = new Word();

      x.addWindowListener(
         new WindowAdapter() {
            public void windowClosing( WindowEvent e )
            {
               System.exit( 0 );
            }
         }
       );
    }
 }
0
 
LVL 15

Expert Comment

by:Javatm
ID: 9776622
If you want to close the entire program just click on the "x" mark on the
Internal Frame w/ this codes :

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class Word extends JWindow {

 public Word()
  {
  JDesktopPane p1 = new JDesktopPane();
  JInternalFrame f1 = new JInternalFrame("Sample . . .",false,true,false,true);

  JTextArea txt1 = new JTextArea();
  txt1.setSize(300,300);

  f1.add(new JScrollPane(txt1));
  f1.show();
  p1.add(f1);

  f1.setDefaultCloseOperation(JInternalFrame.EXIT_ON_CLOSE);
   
  getContentPane().setLayout( new BorderLayout() );
  getContentPane().add( p1, BorderLayout.CENTER);

  setSize(500, 500);
  show();
  }

 public static void main (String args[])
  {
      Word x = new Word();
  }
 }
0
 
LVL 15

Expert Comment

by:Javatm
ID: 9776660
>> I still prefer Object's proposed method at this stage.. as to avoid the above complications

    As what Object said " Think you'll need to handle painting the title bar yourself ".

    This is hard to do thats why I'm giving you a much easier way.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question