First I created a menu panel
//********************************************************************
// BoxPanel.java Authors: Lewis/Loftus
//
// Represents the panel in the LayoutDemo program that demonstrates
// the box layout manager.
//********************************************************************
import java.awt.*;
import javax.swing.*;
public class MenuPanel extends JPanel
{
//-----------------------------------------------------------------
// Sets up this panel with some buttons to show how a vertical
// box layout (and invisible components) affects their position.
//-----------------------------------------------------------------
public MenuPanel()
{
setLayout (new BoxLayout (this, BoxLayout.X_AXIS));
// this is the current object, which is this BoxPanel object
// in order to work, the BoxLayout needs to access the BoxPanel object
setBackground (Color.green);
JButton b1 = new JButton ("BUTTON 1");
JButton b2 = new JButton ("BUTTON 2");
JButton b3 = new JButton ("BUTTON 3");
JButton b4 = new JButton ("BUTTON 4");
JButton b5 = new JButton ("BUTTON 5");
add (b1);
add (Box.createRigidArea (new Dimension (0, 10)));
add (b2);
add (Box.createVerticalGlue()); /// allow the area between b2 and b3 to stretch
add (b3);
add (Box.createHorizontalGlue()); /// allow the area between b2 and b3 to stretch
add (b4);
add (Box.createRigidArea (new Dimension (10, 20)));
add (b5);
JRadioButton b6 = new JRadioButton("Small Font");
JRadioButton b7 = new JRadioButton("Medium Font");
JRadioButton b8 = new JRadioButton("Large Font");
add(b6);
add(b7);
add(b8);
JTextArea myTextArea = new JTextArea();
add(myTextArea);
add(bp);
}
}
Then I created an Editor Panel
import java.awt.*;
import javax.swing.*;
public class EditorPanel extends JPanel
{
//-----------------------------------------------------------------
// Sets up this panel with a button in each area of a border
// layout to show how it affects their position, shape, and size.
//-----------------------------------------------------------------
public EditorPanel()
{
setLayout (new BorderLayout());
setBackground (Color.green);
JButton b1 = new JButton ("BUTTON 1");
JButton b2 = new JButton ("BUTTON 2");
JButton b3 = new JButton ("BUTTON 3");
JButton b4 = new JButton ("BUTTON 4");
JButton b5 = new JButton ("BUTTON 5");
MenuPanel mp = new MenuPanel();
// add (b1, BorderLayout.CENTER);
JTextArea editArea = new JTextArea();
JTextArea myTextArea = new JTextArea();
editArea.setFont (new Font ("Times", Font.PLAIN, 24));
add (editArea, BorderLayout.CENTER);
add (myTextArea, BorderLayout.CENTER);
b3.setFont (new Font ("Times", Font.PLAIN, 24));
add (b2, BorderLayout.NORTH);
add (b3, BorderLayout.SOUTH);
add (b4, BorderLayout.EAST);
// add (b5, BorderLayout.WEST);
add (mp, BorderLayout.NORTH);
}
}
I am now try to created an Editors Lab of Sorts, A Display...so It has an intro Panel (as a tab) and an Editor's Panel which stores the Panel it creates in a variable that I can pass to my Menu Panel...
I have this....but it is not compiling and I am unsure of how to proceed
import java.awt.*;
import javax.swing.*;
public class EditorPanel extends JPanel
{
//-----------------------------------------------------------------
// Sets up this panel with a button in each area of a border
// layout to show how it affects their position, shape, and size.
//-----------------------------------------------------------------
public EditorPanel()
{
setLayout (new BorderLayout());
setBackground (Color.green);
JButton b1 = new JButton ("BUTTON 1");
JButton b2 = new JButton ("BUTTON 2");
JButton b3 = new JButton ("BUTTON 3");
JButton b4 = new JButton ("BUTTON 4");
JButton b5 = new JButton ("BUTTON 5");
MenuPanel mp = new MenuPanel();
// add (b1, BorderLayout.CENTER);
JTextArea editArea = new JTextArea();
JTextArea myTextArea = new JTextArea();
editArea.setFont (new Font ("Times", Font.PLAIN, 24));
add (editArea, BorderLayout.CENTER);
add (myTextArea, BorderLayout.CENTER);
b3.setFont (new Font ("Times", Font.PLAIN, 24));
add (b2, BorderLayout.NORTH);
add (b3, BorderLayout.SOUTH);
add (b4, BorderLayout.EAST);
// add (b5, BorderLayout.WEST);
add (mp, BorderLayout.NORTH);
}
}
If anyone can Help it would be appreciated.

New Topic/Question
Reply



MultiQuote



|