Swing size/resize issue

S

SirThanxALot

hello,

i have this crazy mindbreaking problem with swing
i try to make a window divided in 2 parts, a presentation pane and a
controllerpane
but i want to set the size of my compnents

according to several APIdocs and tutorials
i should use yyy.setSize(java awt.Dimension(x,y)) for this
but all i seem to get is my menubar neatly lined out, but no content panes

what do i do wrong?
is it because there is no actual 'content' on my panes, say an image or a
label?

thx in advance
SirThanxALot

here's the code
----------------------------------------
import java.awt.Color;
import java.awt.Dimension;

import javax.swing.Box;
import javax.swing.JFrame;
import javax.swing.JLayeredPane;
import javax.swing.JPanel;

/**
* To change the template for this generated type comment go to
* Window - Preferences - Java - Code Generation - Code and Comments
**/
public class SMILPlayerFrame extends JFrame
{
public SMILPlayerFrame()
{
super();
init();
}

public SMILPlayerFrame(String title)
{
super(title);
init();
}

private void init()
{
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

setJMenuBar(new SMILMenuBar());
Box layout = Box.createVerticalBox();
JLayeredPane presentation = new JLayeredPane();
JPanel control = new JPanel();
control.setSize(new Dimension(800,200));

presentation.setPreferredSize(new Dimension(800,600));
presentation.setBackground(new Color(100,200,100));

layout.add(control);
layout.add(presentation);
pack();
setVisible(true);
}
}

--------------------------
import javax.swing.JMenuBar;
import javax.swing.JMenu;

public class SMILMenuBar extends JMenuBar
{
private JMenu $file,
$view,
$playback,
$options,
$help;

public SMILMenuBar()
{
super();
setFile(new JMenu("File"));

setView(new JMenu("View"));

setPlayback(new JMenu("Playback"));

setOptions(new JMenu("Options"));

setHelp(new JMenu("Help"));

add(getFile());
add(getView());
add(getPlayback());
add(getOptions());
add(getHelp());

}

public void setFile(JMenu file)
{
$file = file;
}

public JMenu getFile()
{
return $file;
}

public void setView(JMenu view)
{
$view = view;
}

public JMenu getView()
{
return $view;
}

public void setPlayback(JMenu playback)
{
$playback = playback;
}

public JMenu getPlayback()
{
return $playback;
}

public void setHelp(JMenu help)
{
$help = help;
}

public JMenu getHelp()
{
return $help;
}

public void setOptions(JMenu options)
{
$options = options;
}

public JMenu getOptions()
{
return $options;
}

}
 
L

Lee Weiner

You create a Box, add your components to the box, but I don't see where you
add the Box to the JFrame.

Lee Weiner
lee AT leeweiner DOT org
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,045
Latest member
DRCM

Latest Threads

Top