hw to split the jpanel to 3 jpanels
843806Mar 25 2009 — edited Mar 25 2009Hello frnds,
In the below mentioned code I need to split the teller panel to three teller can you give any suggestions.
thank you
suraw
package guis.views;
import guis.controllers.GeneralController;
import java.awt.Dimension;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.beans.PropertyChangeEvent;
import java.util.LinkedList;
import javax.swing.DefaultListModel;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
/**
* This is a custom view panel that displays a "document" consisting of a single
* text element. Both the document and the text element respond to changes in
* the model state.
*
* @author Robert Eckstein
*/
public class TellerPanelView extends View
{
private JPanel tellerPanel,tellerSubPanel;
private JList teller;
private JLabel tellerInfo;
private JSplitPane SplitPane;
private LinkedList<String> customerAtTeller;
private JScrollPane listScroller;
private DefaultListModel tellerlist;
// The controller used by this view
private GeneralController controller;
/**
* Creates new form TextElementDisplayPanel
* @param controller An object implenting the controller interface that
* this view can use to process GUI actions
*/
public TellerPanelView(GeneralController controller) {
this.controller = controller;
initComponents();
localInitialization();
}
/**
* Initialization method called from the constructor
*/
public void localInitialization() {
}
/** This method is called from within the constructor to
* initialize the form.
*/
private void initComponents() {
tellerPanel = new JPanel(new GridLayout(2,1));
tellerInfo = new JLabel("Teller1: Teller2: Teller3:");
teller = new JList();
tellerlist = new DefaultListModel();
teller.setModel(tellerlist);
SplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
for (int a = 0; a <= 2; a++)
{
listScroller = new JScrollPane(teller,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
}
customerAtTeller = new LinkedList<String>();
tellerPanel.add(tellerInfo);
tellerPanel.add(listScroller);
}
public JPanel getTellerPanel() {
return tellerPanel;
}
/**
* Called by the controller when it needs to pass along a property change
* from a model.
* @param evt The property change event
*/
public void modelPropertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals(GeneralController.ADD_TRANSACTION)) {
String cust = (String) evt.getNewValue();
customerAtTeller.addLast(cust);
tellerlist.addElement(cust);
}
revalidate();
repaint();
}
}