?
Solved

Hide/remove maximize button on JFrame.

Posted on 2003-11-18
8
Medium Priority
?
7,279 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
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
Course of the Month12 days, 9 hours left to enroll

777 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