Article View: borland.public.jbuilder.java.swing
Article #1354Re: jpanel and borders stange behauviour
From: Sven Goetgeluck
Date: Mon, 19 Jan 2004 08:16
Date: Mon, 19 Jan 2004 08:16
525 lines
19490 bytes
19490 bytes
Found the solution
thanks
"Sven Goetgeluck" <sven.goetgeluck@pandora.be> schreef in bericht
news:4008630b@newsgroups.borland.com...
> thanks for answer ,
> whet exactly is my problem
>
> when i add a button to my panel
> the button is displayed just perfect , the top of button is equal to the
top
> of the pannel added to
> but when is add this panel to another panel there is a border around the
> panel with my button on it
> this problem comes when running application in jdk 1.4 but i dont have
this
> when running on 1.2
>
> hereby the code of the videocontrolpanel , this pannel has 9 buttons on it
> to control an video
>
> the panel is added to another panel (lets call menubuttonpanel) wich i use
> as a buttonpanel on my mainframe just below the menubar
> where there is also a jlabel on it and in the future a jcombobox the
reason
> for grouping the other buttons is because i reuse the panel somewhere else
>
> package video;
>
> import java.util.*;
>
> import java.awt.*;
> import java.awt.event.*;
> import javax.swing.*;
> import javax.swing.border.EmptyBorder;
> import vrex4.*;
>
> public class VideoControllPanel
> extends JPanel {
> JButton menubarplayButton = new JButton();
> JButton menubarmuteButton = new JButton();
> JButton menubarloopButton = new JButton();
> JButton menubarstopButton = new JButton();
> JButton menubarreverseButton = new JButton();
> JButton menubarfotoButton = new JButton();
> JButton menubarforwardButton = new JButton();
> JButton menubarendButton = new JButton();
> JButton menubarbackwardButton = new JButton();
> private ResourceBundle recources;
> private ResourceBundle images;
> VideoWindow videopanel = null;
> boolean mute = false;
> boolean loopmode = false;
> private ImageIcon loopinimage = null;
> private ImageIcon loopimage = null;
> Frame1 parent = null;
> GridLayout gridLayout = new GridLayout(1,9);
> JToolBar toolbar = new JToolBar();
> Color bcolor = new Color(76,90,109);
> public VideoControllPanel(Frame1 p, ResourceBundle r, ResourceBundle i)
{
> try {
> parent = p;
> images = i;
> recources = r;
>
> jbInit();
> }
> catch (Exception ex) {
> ex.printStackTrace();
> }
> }
>
> public void setVideoWindow(VideoWindow video) {
> videopanel = video;
> }
>
> private void jbInit() throws Exception {
> loopinimage = new ImageIcon(images.getString("LOOPIN"));
> loopimage = new ImageIcon(images.getString("LOOP"));
> toolbar.setLayout(gridLayout);
> toolbar.setFloatable(false);
>
> setBackground(bcolor);
> setForeground(bcolor);
> toolbar.setBackground(bcolor);
> toolbar.setForeground(bcolor);
>
> this.setBorder(new EmptyBorder(0,0,0,0));
> toolbar.setBorder(new EmptyBorder(0,0,0,0));
>
> menubarplayButton.setBackground(bcolor);
> menubarplayButton.setMaximumSize(new Dimension(50, 20));
> menubarplayButton.setMinimumSize(new Dimension(50, 20));
> menubarplayButton.setPreferredSize(new Dimension(50, 20));
> menubarplayButton.setMargin(new Insets(0, 0, 0, 0));
> menubarplayButton.setIcon(new ImageIcon(images.getString("PLAY")));
> menubarplayButton.setPressedIcon(new
> ImageIcon(images.getString("PLAY_IN")));
> menubarplayButton.setRolloverIcon(new
> ImageIcon(images.getString("PLAY_OUT")));
> menubarplayButton.setBorderPainted(false);
> menubarplayButton.setContentAreaFilled(false);
>
> menubarplayButton.setFocusPainted(false);
> menubarplayButton.setToolTipText(recources.getString("PLAY_TOOLTIP"));
> menubarplayButton.addActionListener(new
java.awt.event.ActionListener()
> {
>
> public void actionPerformed(ActionEvent e) {
> menubarplayButton_actionPerformed(e);
> }
> });
>
> menubarmuteButton.setBackground(bcolor);
> menubarmuteButton.setMaximumSize(new Dimension(50, 20));
> menubarmuteButton.setMinimumSize(new Dimension(50, 20));
> menubarmuteButton.setPreferredSize(new Dimension(50, 20));
> menubarmuteButton.setMargin(new Insets(0, 0, 0, 0));
> menubarmuteButton.setIcon(new ImageIcon(images.getString("MUTE")));
> menubarmuteButton.setPressedIcon(new
> ImageIcon(images.getString("MUTE_IN")));
> menubarmuteButton.setRolloverIcon(new
> ImageIcon(images.getString("MUTE_OUT")));
> menubarmuteButton.setBorderPainted(false);
> menubarmuteButton.setFocusPainted(false);
> menubarmuteButton.setToolTipText(recources.getString("PLAY_TOOLTIP"));
>
> menubarmuteButton.addActionListener(new
java.awt.event.ActionListener()
> {
>
> public void actionPerformed(ActionEvent e) {
> menubarmuteButton_actionPerformed(e);
> }
> });
> menubarloopButton.setBackground(bcolor);
> menubarloopButton.setMaximumSize(new Dimension(50, 20));
> menubarloopButton.setMinimumSize(new Dimension(50, 20));
> menubarloopButton.setPreferredSize(new Dimension(50, 20));
> menubarloopButton.setMargin(new Insets(0, 0, 0, 0));
> menubarloopButton.setIcon(new ImageIcon(images.getString("LOOP")));
> menubarloopButton.setPressedIcon(new
> ImageIcon(images.getString("LOOP_IN")));
> menubarloopButton.setRolloverIcon(new
> ImageIcon(images.getString("LOOP_OUT")));
> menubarloopButton.setBorderPainted(false);
> menubarloopButton.setFocusPainted(false);
> menubarloopButton.setToolTipText(recources.getString("LOOP_TOOLTIP"));
> menubarloopButton.addActionListener(new
java.awt.event.ActionListener()
> {
>
> public void actionPerformed(ActionEvent e) {
> menubarloopButton_actionPerformed(e);
> }
> });
>
> menubarstopButton.setBackground(bcolor);
> menubarstopButton.setMaximumSize(new Dimension(50, 20));
> menubarstopButton.setMinimumSize(new Dimension(50, 20));
> menubarstopButton.setPreferredSize(new Dimension(50, 20));
> menubarstopButton.setMargin(new Insets(0, 0, 0, 0));
> menubarstopButton.setIcon(new ImageIcon(images.getString("STOP")));
> menubarstopButton.setPressedIcon(new
> ImageIcon(images.getString("STOP_IN")));
> menubarstopButton.setRolloverIcon(new
> ImageIcon(images.getString("STOP_OUT")));
> menubarstopButton.setBorderPainted(false);
> menubarstopButton.setFocusPainted(false);
> menubarstopButton.setToolTipText(recources.getString("STOP_TOOLTIP"));
> menubarstopButton.addActionListener(new
java.awt.event.ActionListener()
> {
>
> public void actionPerformed(ActionEvent e) {
> menubarstopButton_actionPerformed(e);
> }
> });
>
> menubarreverseButton.setBackground(bcolor);
> menubarreverseButton.setMaximumSize(new Dimension(50, 20));
> menubarreverseButton.setMinimumSize(new Dimension(50, 20));
> menubarreverseButton.setPreferredSize(new Dimension(50, 20));
> menubarreverseButton.setMargin(new Insets(0, 0, 0, 0));
> menubarreverseButton.setIcon(new
> ImageIcon(images.getString("REVERSE")));
> menubarreverseButton.setPressedIcon(new ImageIcon(images.getString(
> "REVERSE_IN")));
> menubarreverseButton.setRolloverIcon(new ImageIcon(images.getString(
> "REVERSE_OUT")));
> menubarreverseButton.setBorderPainted(false);
> menubarreverseButton.setFocusPainted(false);
>
>
menubarreverseButton.setToolTipText(recources.getString("REVERSE_TOOLTIP"));
> menubarreverseButton.addActionListener(new
> java.awt.event.ActionListener() {
>
> public void actionPerformed(ActionEvent e) {
> menubarreverseButton_actionPerformed(e);
> }
> });
> menubarreverseButton.addMouseListener(new
java.awt.event.MouseAdapter()
> {
>
> public void mousePressed(MouseEvent e) {
> videopanel.doSomething("FastBackwardBegin");
>
> }
>
> public void mouseReleased(MouseEvent e) {
> videopanel.doSomething("FastBackwardEnd");
> }
> });
>
> menubarfotoButton.setBackground(bcolor);
> menubarfotoButton.setBorder(null);
> menubarfotoButton.setMaximumSize(new Dimension(50, 20));
> menubarfotoButton.setMinimumSize(new Dimension(50, 20));
> menubarfotoButton.setPreferredSize(new Dimension(50, 20));
> menubarfotoButton.setMargin(new Insets(0, 0, 0, 0));
> menubarfotoButton.setIcon(new ImageIcon(images.getString("PHOTO")));
> menubarfotoButton.setPressedIcon(new
> ImageIcon(images.getString("PHOTO_IN")));
> menubarfotoButton.setRolloverIcon(new ImageIcon(images.getString(
> "PHOTO_OUT")));
> menubarfotoButton.setBorderPainted(false);
> menubarfotoButton.setFocusPainted(false);
>
> menubarfotoButton.setToolTipText(recources.getString("SNAPSHOT_TOOLTIP"));
> menubarfotoButton.addActionListener(new
java.awt.event.ActionListener()
> {
>
> public void actionPerformed(ActionEvent e) {
> menubarfotoButton_actionPerformed(e);
> }
> });
>
> menubarforwardButton.setBackground(bcolor);
> menubarforwardButton.setMaximumSize(new Dimension(50, 20));
> menubarforwardButton.setMinimumSize(new Dimension(50, 20));
> menubarforwardButton.setPreferredSize(new Dimension(50, 20));
> menubarforwardButton.setMargin(new Insets(0, 0, 0, 0));
> menubarforwardButton.setIcon(new
> ImageIcon(images.getString("FORWARD")));
> menubarforwardButton.setPressedIcon(new ImageIcon(images.getString(
> "FORWARD_IN")));
> menubarforwardButton.setRolloverIcon(new ImageIcon(images.getString(
> "FORWARD_OUT")));
> menubarforwardButton.setBorderPainted(false);
> menubarforwardButton.setFocusPainted(false);
>
>
menubarforwardButton.setToolTipText(recources.getString("FORWARD_TOOLTIP"));
> menubarforwardButton.addActionListener(new
> java.awt.event.ActionListener() {
>
> public void actionPerformed(ActionEvent e) {
> menubarforwardButton_actionPerformed(e);
> }
> });
> menubarforwardButton.addMouseListener(new
java.awt.event.MouseAdapter()
> {
>
> public void mousePressed(MouseEvent e) {
> videopanel.doSomething("FastForwardBegin");
>
> }
>
> public void mouseReleased(MouseEvent e) {
> videopanel.doSomething("FastForwardEnd");
> }
> });
> menubarbackwardButton.setBackground(bcolor);
> menubarbackwardButton.setMaximumSize(new Dimension(50, 20));
> menubarbackwardButton.setMinimumSize(new Dimension(50, 20));
> menubarbackwardButton.setPreferredSize(new Dimension(50, 20));
> menubarbackwardButton.setMargin(new Insets(0, 0, 0, 0));
> menubarbackwardButton.setIcon(new
> ImageIcon(images.getString("BACKWARD")));
> menubarbackwardButton.setPressedIcon(new ImageIcon(images.getString(
> "BACKWARD_IN")));
> menubarbackwardButton.setRolloverIcon(new ImageIcon(images.getString(
> "BACKWARD_OUT")));
> menubarbackwardButton.setBorderPainted(false);
> menubarbackwardButton.setFocusPainted(false);
>
>
menubarbackwardButton.setToolTipText(recources.getString("BACKWARD_TOOLTIP")
> );
> menubarbackwardButton.addActionListener(new
> java.awt.event.ActionListener() {
>
> public void actionPerformed(ActionEvent e) {
> menubarbackwardButton_actionPerformed(e);
> }
> });
>
> menubarendButton.setBackground(bcolor);
> menubarendButton.setMaximumSize(new Dimension(50, 20));
> menubarendButton.setMinimumSize(new Dimension(50, 20));
> menubarendButton.setPreferredSize(new Dimension(50, 20));
> menubarendButton.setMargin(new Insets(0, 0, 0, 0));
> menubarendButton.setIcon(new ImageIcon(images.getString("END")));
> menubarendButton.setPressedIcon(new
> ImageIcon(images.getString("END_IN")));
> menubarendButton.setRolloverIcon(new
> ImageIcon(images.getString("END_OUT")));
> menubarendButton.setBorderPainted(false);
> menubarendButton.setFocusPainted(false);
> menubarendButton.setToolTipText(recources.getString("END_TOOLTIP"));
> menubarendButton.addActionListener(new java.awt.event.ActionListener()
{
>
> public void actionPerformed(ActionEvent e) {
> menubarendButton_actionPerformed(e);
> }
> });
>
> toolbar.add(menubarloopButton, null);
> toolbar.add(menubarreverseButton, null);
> toolbar.add(menubarbackwardButton, null);
> toolbar.add(menubarstopButton, null);
> toolbar.add(menubarplayButton, null);
>
> toolbar.add(menubarendButton, null);
> toolbar.add(menubarforwardButton, null);
> toolbar.add(menubarfotoButton, null);
> toolbar.add(menubarmuteButton, null);
> this.add(toolbar);
> }
>
> void menubarbackwardButton_actionPerformed(ActionEvent e) {
> videopanel.doSomething("Backward");
>
> }
>
> void menubarendButton_actionPerformed(ActionEvent e) {
> videopanel.doSomething("Forward");
> }
>
> void menubarforwardButton_actionPerformed(ActionEvent e) {
>
> }
>
> void menubarfotoButton_actionPerformed(ActionEvent e) {
> videopanel.doSomething("SnapShot");
> }
>
> void menubarreverseButton_actionPerformed(ActionEvent e) {
>
> }
>
> void menubarstopButton_actionPerformed(ActionEvent e) {
> videopanel.doSomething("Stop");
> }
>
> void menubarloopButton_actionPerformed(ActionEvent e) {
> loopmode = !loopmode;
> parent.loopmode = loopmode;
>
> if (loopmode == true) {
> menubarloopButton.setIcon(loopinimage);
> }
> else {
> menubarloopButton.setIcon(loopimage);
> }
> videopanel.setLoop(loopmode);
> }
>
> void menubarmuteButton_actionPerformed(ActionEvent e) {
> mute = !mute;
> parent.mute = mute;
> videopanel.setMuteMode(mute);
> if (mute == false) {
> menubarmuteButton.setIcon(new
ImageIcon(images.getString("MUTE_IN")));
> }
> else {
> menubarmuteButton.setIcon(new ImageIcon(images.getString("MUTE")));
> }
> videopanel.doSomething("Mute");
>
> }
>
> void menubarplayButton_actionPerformed(ActionEvent e) {
> videopanel.doSomething("Play");
>
> }
>
> public void hideMovieButtons() {
> menubarplayButton.setVisible(false);
> menubarmuteButton.setVisible(false);
> menubarloopButton.setVisible(false);
> menubarstopButton.setVisible(false);
> menubarreverseButton.setVisible(false);
> menubarfotoButton.setVisible(false);
> menubarforwardButton.setVisible(false);
> menubarendButton.setVisible(false);
> menubarbackwardButton.setVisible(false);
> }
>
>
>
> }
>
>
> this is my mainframe where i add this panel to
> // the panel with all my buttons on it
>
> videocontrol = new VideoControllPanel(this, this.recources,
this.images);
> videocontrol.setBorder(null);
>
> // a jtoolbar where there a ljabel is on it and the videocontrol
> JLabel betaButton = new JLabel("testlabel");
>
> JToolBar movieToolBar = new JToolBar();
> movieToolBar.add(betaButton);
> // separator
> movieToolBar.add(sp, null);
> //the videocontrol
> movieToolBar.add(videocontrol, null);
> movieToolBar.setBackground(new java.awt.Color(76, 90, 109));
> movieToolBar.setForeground(new java.awt.Color(76, 90, 109));
> movieToolBar.setAlignmentX( (float) 0.0);
> movieToolBar.setBorder(null);
> movieToolBar.setBorderPainted(false);
> movieToolBar.setMargin(new Insets(0, 0, 0, 0));
> movieToolBar.setFloatable(false);
>
> this is what we have
> || <JLABEL> <- space ->
> [button1][button2][button3][button4] ||
>
> second jtoolbar is general toolbar
> [buttonA][buttonB][buttonC][buttonD][buttonE]
>
>
> //now i add the panel to the frame on this panel i have 2 jtoolbars
> this.getContentPane().add(buttonpanel, BorderLayout.NORTH);
> buttonpanel.add(toolbar, new PaneConstraints("toolbar", "toolbar",
> PaneConstraints.ROOT, 0.6f));
> buttonpanel.add(movieToolBar, new PaneConstraints("jToolBar1",
> "toolbar", PaneConstraints.BOTTOM, 0.3f));
>
> so this must be the total look of my buttonpanels
>
> <menu>
> || [buttonA][buttonB][buttonC][buttonD][buttonE]
> ||
> || <JLABEL> <- space ->
> [button1][button2][button3][button4] ||
>
> hope this is better expained
>
> greetings Sven
>
>
> "Paul Furbacher" <pfurbacher@mac.com> schreef in bericht
> news:40084176$2@newsgroups.borland.com...
> > Sven Goetgeluck wrote:
> >
> > > I have a jpanel where i add a jpanel component to
> > > but ther is a border around the last panel
> > > short explanation what i want to do
> > >
> > > a have a buttonpanel where i have put some buttons on it
> > > this pannel is added to another panel where there is also a jlabel on
it
> so
> > > i can display tips to the label when i pass the buttons but the
anoyong
> > > thing is that adding a panel to the other panel there is a border
around
> and
> > > so the buttons arent alignt top to the upper paneltop
> > >
> > > hope this is clear what i mean
> >
> > Sort of, but not exactly.
> >
> > > did started when using jdk 1.4 didn't never had it in 1.2
> > >
> > > hereby some code that may help
> >
> > Actually, it would be more help if the
> > code were complete, and the barest example
> > possible. You presented code which depended
> > on a lot of things that a reader would have
> > to guess at. The code should be such
> > that a reader could snip it, paste
> > it into a few files in a new project,
> > compile and run ... without extensive
> > editing or imagining.
> >
> > Try to post the barebones example of
> > what is going on, if you can. By working
> > up such an example, you may discover
> > what is causing the problem.
> >
> >
> > --
> >
> >
> > Paul Furbacher (TeamB)
> >
> > Save time, search the archives:
> > http://www.borland.com/newsgroups/ngsearch.html
> >
> > Is it in Joi Ellis's Faq-O-Matic?
> > http://www.visi.com/~gyles19/fom-serve/cache/1.html
> >
> > Finally, please send responses to the newsgroup only.
> > That means, do not send email directly to me.
> > Thank you.
>
>
Technical Details
Message-ID:
<400b9244$0$320$ba620e4c@news.skynet.be>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!news-out.visi.com!petbe.visi.com!skynet.be!skynet.be!louie!tjb!not-for-mailReferences:
<40072ea6$1@newsgroups.borland.com> <40084176$2@newsgroups.borland.com> <4008630b@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,bdf82a54cfa1b9fa X-Google-Attributes: gid111d45,public X-Google-ArrivalTime: 2004-01-19 00:16:19 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!news-out.visi.com!petbe.visi.com!skynet.be!skynet.be!louie!tjb!not-for-mail From: "Sven Goetgeluck" <sven.goetgeluck@pandora.be> Newsgroups: borland.public.jbuilder.java.swing References: <40072ea6$1@newsgroups.borland.com> <40084176$2@newsgroups.borland.com> <4008630b@newsgroups.borland.com> Subject: Re: jpanel and borders stange behauviour Date: Mon, 19 Jan 2004 09:16:02 +0100 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Lines: 527 Message-ID: <400b9244$0$320$ba620e4c@news.skynet.be> Organization: -= Belgacom Usenet Service =- NNTP-Posting-Host: 217.136.183.76 X-Trace: 1074500166 reader0.news.skynet.be 320 217.136.183.76:1127 X-Complaints-To: usenet-abuse@skynet.be