Good Day-
I'm working on JApplets
in which I have two tabbedPanel
. Now for the first tabbed
I need to further divide the parent JPanel
into two parts. For this I created two sub panels and also have used the JSplitPane
class to split those into two parts.
- eastPanel
- westPanel
The windows looks like the following:
This is Resizeable
as we can see the maximize button is enable. I have tried to set this method setResizeable()
but I think it's only available for JFRAME
.
The desired UI which I'm try to create is as following:
What I need is to restrict its size so that it won't be maximize anymore and the content is placed as it is in the JPanel
. Could you please guide me which approach I should follow to achieve the desired results? Furthermore the source is as following:
public class CreatePanel extends JPanel
{
private Vector athleteList;
private JButton button1;
private CountPanel cPanel;
private TextField firstName;
private TextArea textArea;
//Constructor initializes components and organize them using certain layouts
public CreatePanel(Vector athleteList, CountPanel cPanel)
{
this.athleteList = athleteList;
this.cPanel = cPanel;
//inner Jpanels to Split the parent panel
JPanel eastPanel = new JPanel();
JPanel westPanel = new JPanel();
button1 = new JButton("Create an Athlete");
textArea = new TextArea("No Athlete");
textArea.setEditable(false);
eastPanel.setBackground(Color.RED);
westPanel.setBackground(Color.BLUE);
eastPanel.add(button1);
/* p1.add(firstName);
p2.add(textArea);*/
JSplitPane sp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
sp.setResizeWeight(0.5);
sp.setDividerSize(0);
sp.add(eastPanel);
sp.add(westPanel);
//organize components here
setLayout( new GridLayout(1, 2));
// add(firstName,BorderLayout.WEST);
add(sp);
}
//ButtonListener is a listener class that listens to
//see if the button "Create an Athlete" is pushed.
//When the event occurs, it adds an athlete using the information
//entered by a user.
//It also performs error checking.
private class ButtonListener implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
//TO BE COMPLETED
} //end of actionPerformed method
} //end of ButtonListener class
}
DriveClass
public class Test extends JApplet
{
private int APPLET_WIDTH = 500, APPLET_HEIGHT = 400;
private JTabbedPane tPane;
private CreatePanel createPanel;
private CountPanel countPanel;
private Vector athleteList;
//The method init initializes the Applet with a Pane with two tabs
public void init()
{
//list of athletes to be used in every panel
athleteList = new Vector();
//register panel uses the list of athletes
countPanel = new CountPanel(athleteList);
createPanel = new CreatePanel(athleteList, countPanel);
//create a tabbed pane with two tabs
tPane = new JTabbedPane();
tPane.addTab("Athlete Creation", createPanel);
tPane.addTab("Medal Count", countPanel);
getContentPane().add(tPane);
setSize (APPLET_WIDTH, APPLET_HEIGHT); //set Applet size
setPreferredSize(new Dimension(APPLET_WIDTH, APPLET_HEIGHT));
setMaximumSize(this.getPreferredSize());
setMinimumSize(this.getPreferredSize());
}
}
Help will be appreciated.Many Thanks