🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #10021

JToolbar Help

#10021
From: Kenneth Sloane
Date: Sun, 21 Nov 1999 00:00
42 lines
2047 bytes
I was trying to add a JToolbar to my frame but I'm having trouble sizing it
to accomodate my gif.  I have  a gif which is 16 x 16but when I add the
Content Pane and the Toolbar, the height of it seems to be too big for the
icon.  I was wondering what I was doing wrong.  Here are the classes for the
content pane and the toolbar.  I instantiate the content pane from the frame
class and the toolbar from the content pane.  Any help would be appreciated.
In short, I want to make the height of the content pane (and the toolbar)
the same as my icons which is 16 pixels.  It seems the JToolbar (or Content
Pane) it resides in is 32 pixels when I want it to be 16.

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

class StoryToolBar extends JToolBar {
 public StoryToolBar() {
    Dimension d = new Dimension(16, 16);

  JButton button = new JButton(new ImageIcon("exit.gif"));
    button.setMinimumSize(d);
    button.setMaximumSize(d);
    button.setSize(d);
    this.add(button);
    this.setMargin(new Insets(0,0,0,0));
    this.setMaximumSize(d);
    this.setMinimumSize(d);
    this.setSize(d);
    this.setFloatable(false);
 }
}

class StoryToolBarContentPane extends JPanel {

 public StoryToolBarContentPane() {
    Dimension d = new Dimension(16, 16);

    this.setSize(d);
    this.setMinimumSize(d);
    this.setMaximumSize(d);
  this.setLayout(new BorderLayout());
  this.add(new StoryToolBar(), BorderLayout.CENTER);
 }
}
Technical Details
Message-ID: <819k2o$9if$2@nntp9.atl.mindspring.net>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,659cd3e2ee8c4fd2,start
X-Google-Attributes: gid111d45,public
From: "Kenneth Sloane" <ksloane31@mindspring.com>
Subject: JToolbar Help
Date: 1999/11/21
Message-ID: <819k2o$9if$2@nntp9.atl.mindspring.net>
X-Deja-AN: 551361848
X-Priority: 3
X-Server-Date: 21 Nov 1999 20:18:32 GMT
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200
Organization: MindSpring Enterprises
X-MSMail-Priority: Normal
Reply-To: "Kenneth Sloane" <ksloane31@mindspring.com>
Newsgroups: borland.public.jbuilder.java.swing