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;
}
}
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;
}
}