Ramen

Inhoud blog
  • emnTekstverbeteringTester :: Voorbereiding :: Deel 3
  • Opmaken van een spellinglijst : emnTekstverbeteringTester :: Voorbereiding
  • emnTekstverbeteringTester Deel 2
  • TekstverbeteringsTester emn :: deel 1 Voorbereiding
  • Open and close Stage and scene. Scenes stored in Hashmap
  • JavaFX FXML voorbeelden | JavaFX FXML examples
  • Eigenschappen voorbeeld uit vorig blog | Properties sample from previous blog
  • Meervoudige fxml bestanden laden | Loading multiple fxml files and controllers
  • Move from one object to another :: JavaFX
  • JavaFX templates
  • JavaFX FXML webbrowser
  • JavaFX ProgressIndicator - ProgessBar
  • Draai scene builder vanuit eclipse - Run scene builder from within eclipse.
  • FXML voorbeeld voor eclipse | FXML sample for eclipse
  • Wapenschild Hamerlinck
  • Wapenschild Hamerlinck
  • Zelf oefeningen maken :: educatie , talen , enquetes
  • ST. PATRICKS DAY PARADE
  • Hulp programma voor het leren van vreemde talen.
  • Javascript :: tekst sorteren op unieke woorden :: sort text
  • Code sorteer tekst : sort text :: javascript
  • onze tuin
  • Aston Ariel op bezoek
  • Hulpprogramma's :: Lezen | RSS - Nieuws
  • Presentationmodel :: buffered model :: RiverLayout
  • Make a separator for RiverLayout:
  • Customize combobox (binding JGoodies):: Riverlayout
  • Test Riverlayout :: sample
  • Project pw Helpdesk
  • LookAndFeel
  • JGoodies binding - RiverLayout
  • JGoodies binding and RiverLayout
  • Enkele JAVA gebonden afkortingen
  • Java Persistence with Hibernate
  • Exel : Woorden vervangen in tekst m.b..v een macro
  • Systray : verwijderen tags taakbalk. Wijzigingen start programma's
  • Scholier kraakt pornofilter van 50 miljoen euro
  • Items Kantorenproject
  • Minimumindeling van het algemeen rekeningstelsel
  • Items Java - eclipse
    Beoordeel dit blog
      Zeer goed
      Goed
      Voldoende
      Nog wat bijwerken
      Nog veel werk aan
     
    Foto
    Foto
    Foto

    rss nieuws

    Europa voor de meeste voorstanders meer en meer een grote teleurstelling
    Zoeken in blog


    Een kijk op....
    29-05-2008
    Klik hier om een link te hebben waarmee u dit artikel later terug kunt lezen.Test Riverlayout :: sample


     
    Project Test Riverlayout :: working example jgoodies binding remove and load jpanels

    Test RiverLayout :: (pics dir: see bottom)

    Package beans
    1.SingleForm.java
    2.TripleForm.java

    Package forms.masterforms
    1.SingleMasterForm.java
    2.TripleMasterForm.java

    Package se.datadosen
    > Download riverlayout.zip


    Package src
    1.MenuBar.java
    2.OpeningForm.java


    Package testen
    1.RiverLayoutTest.java

     
    CODE:
    SingleForm.java
    package beans;
    /*
    * Copyright (c) 2008 - 2008 willems piet pwProTech All rights reserved.
    *
    * Redistribution and use in source and binary forms, with or without
    * modification, are permitted provided that the following conditions
    * are met:
    *
    * - Redistributions of source code must retain the above copyright
    * notice, this list of conditions and the following disclaimer.
    *
    * - Redistributions in binary form must reproduce the above copyright
    * notice, this list of conditions and the following disclaimer in the
    * documentation and/or other materials provided with the distribution.
    *
    *
    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
    * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
    * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
    * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
    * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
    * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    */
    import com.jgoodies.binding.beans.Model;
    //This configuration is more advanced then the tripleform bean and uses JGoodies beans.model
    public class SingleForm extends Model {
    String name, street, nr, towncity, occupation;
    	public String getName() {
    return name;
    }
    	public void setName(String name) {
    this.name = name;
    }
    	public String getNr() {
    return nr;
    }
    	public void setNr(String nr) {
    this.nr = nr;
    }
    	public String getOccupation() {
    return occupation;
    }
    	public void setOccupation(String occupation) {
    this.occupation = occupation;
    }
    	public String getStreet() {
    return street;
    }
    	public void setStreet(String street) {
    this.street = street;
    }
    	public String getTowncity() {
    return towncity;
    }
    	public void setTowncity(String towncity) {
    this.towncity = towncity;
    }
    }
    
    TripleForm.java
    package beans;
    /*
    * Copyright (c) 2008 - 2008 willems piet pwProTech All rights reserved.
    *
    * Redistribution and use in source and binary forms, with or without
    * modification, are permitted provided that the following conditions
    * are met:
    *
    * - Redistributions of source code must retain the above copyright
    * notice, this list of conditions and the following disclaimer.
    *
    * - Redistributions in binary form must reproduce the above copyright
    * notice, this list of conditions and the following disclaimer in the
    * documentation and/or other materials provided with the distribution.
    *
    *
    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
    * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
    * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
    * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
    * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
    * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    */
    import java.beans.PropertyChangeListener;
    import com.jgoodies.binding.beans.ExtendedPropertyChangeSupport;
    public class TripleForm {
    	//ToDo :: see singlemasterform : extends Model
    	String username, age, comment;
    	boolean menuItemEnabled;
    	private ExtendedPropertyChangeSupport changeSupport = new ExtendedPropertyChangeSupport(
    this);
    	public String getUsername() {
    return username;
    }
    	public void setUsername(String username) {
    String oldValue = username;
    this.username = username;
    changeSupport.firePropertyChange("stringValue", oldValue, username);
    System.out.println(username);
    }
    	public String getAge() {
    return age;
    }
    	public void setAge(String age) {
    String oldValue = age;
    this.age = age;
    changeSupport.firePropertyChange("stringValue", oldValue, age);
    System.out.println(age);
    }
    	public String getComment() {
    return comment;
    }
    	public void setComment(String comment) {
    String oldValue = comment;
    this.comment = comment;
    changeSupport.firePropertyChange("stringValue", oldValue, comment);
    System.out.println(comment);
    }
    	public void addPropertyChangeListener(PropertyChangeListener x) {
    changeSupport.addPropertyChangeListener(x);
    }
    	public void removePropertyChangeListener(PropertyChangeListener x) {
    changeSupport.removePropertyChangeListener(x);
    }
    	public boolean isMenuItemEnabled() {
    return menuItemEnabled;
    }
    	public void setMenuItemEnabled(boolean menuItemEnabled) {
    this.menuItemEnabled = menuItemEnabled;
    }
    }
     
    
    SingleMasterForm.java
    package forms.masterforms;
    /*
    * Copyright (c) 2008 - 2008 willems piet pwProTech All rights reserved.
    *
    * Redistribution and use in source and binary forms, with or without
    * modification, are permitted provided that the following conditions
    * are met:
    *
    * - Redistributions of source code must retain the above copyright
    * notice, this list of conditions and the following disclaimer.
    *
    * - Redistributions in binary form must reproduce the above copyright
    * notice, this list of conditions and the following disclaimer in the
    * documentation and/or other materials provided with the distribution.
    *
    *
    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
    * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
    * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
    * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
    * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
    * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    */
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JMenuItem;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    import se.datadosen.component.RiverLayout;
    import src.MenuBar;
    import beans.SingleForm;
    import com.jgoodies.binding.adapter.BasicComponentFactory;
    import com.jgoodies.binding.beans.BeanAdapter;
    import com.jgoodies.binding.value.ValueModel;
    import com.jgoodies.forms.factories.Borders;
    public class SingleMasterForm {
    	private String CMD_OK = "cmd.ok"/* NOI18N */;
    	private JButton okButton;
    	public JPanel buildform(final JFrame f, final JMenuItem menuitem) {
    okButton = new JButton();
    okButton.setText("ok");
    okButton.setActionCommand(CMD_OK);
    okButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent event) {
    // windowAction(event);
    System.out
    .println("ACTION : BUTTON OK WAS CLICKED and Menu item enabled");
    System.out.println(okButton.getActionCommand());
    menuitem.setEnabled(true);//and close
    MenuBar.FrameClearAction(f);
    }
    });
    		SingleForm bean = new SingleForm();
    BeanAdapter adapter = new BeanAdapter(bean, true);
    		ValueModel nameModel = adapter.getValueModel("name");
    ValueModel streetModel = adapter.getValueModel("street");
    ValueModel nrModel = adapter.getValueModel("nr");
    ValueModel towncityModel = adapter.getValueModel("towncity");
    ValueModel occupationModel = adapter.getValueModel("occupation");
    		JTextField nameinput = BasicComponentFactory.createTextField(nameModel);
    JTextField streetinput = BasicComponentFactory
    .createTextField(streetModel);
    JTextField nrinput = BasicComponentFactory.createTextField(nrModel);
    JTextField towncityinput = BasicComponentFactory
    .createTextField(towncityModel);
    JTextField occupationinput = BasicComponentFactory
    .createTextField(occupationModel);
    		// Panel
    		// SingleMasterForm
    JPanel SingleMasterForm = new JPanel();
    SingleMasterForm.setLayout(new RiverLayout());
    SingleMasterForm.add("right", new JLabel("Single Form demo"));
    SingleMasterForm.add("p left", new JLabel("Name"));
    SingleMasterForm.add("tab hfill", nameinput);
    SingleMasterForm.add("br", new JLabel("Street"));
    SingleMasterForm.add("tab hfill", streetinput);
    SingleMasterForm.add("br vtop", new JLabel("nr"));
    SingleMasterForm.add("tab", nrinput);
    nrinput.setColumns(5);
    SingleMasterForm.add("br vtop", new JLabel("Town/City"));
    SingleMasterForm.add("tab hfill", towncityinput);
    SingleMasterForm.add("br vtop", new JLabel("Occupation"));
    SingleMasterForm.add("tab hfill", occupationinput);
    SingleMasterForm.add("p right", okButton);
    SingleMasterForm.setBorder(Borders.DIALOG_BORDER);
    		return SingleMasterForm;
    }
    }
     
    
    TripleMasterForm.java
    
    package forms.masterforms;
    /*
    * Copyright (c) 2008 - 2008 willems piet pwProTech All rights reserved.
    *
    * Redistribution and use in source and binary forms, with or without
    * modification, are permitted provided that the following conditions
    * are met:
    *
    * - Redistributions of source code must retain the above copyright
    * notice, this list of conditions and the following disclaimer.
    *
    * - Redistributions in binary form must reproduce the above copyright
    * notice, this list of conditions and the following disclaimer in the
    * documentation and/or other materials provided with the distribution.
    *
    *
    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
    * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
    * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
    * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
    * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
    * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    */
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JMenuItem;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JSplitPane;
    import javax.swing.JTextArea;
    import javax.swing.JTextField;
    import javax.swing.border.EmptyBorder;
    import se.datadosen.component.RiverLayout;
    import src.MenuBar;
    import beans.TripleForm;
    import com.jgoodies.binding.adapter.BasicComponentFactory;
    import com.jgoodies.binding.beans.BeanAdapter;
    import com.jgoodies.binding.value.ValueModel;
    import com.jgoodies.forms.factories.Borders;
    public class TripleMasterForm extends TripleForm {
    	private String CMD_OK = "cmd.ok"/* NOI18N */;
    	private JButton okButton, ok1Button, ok2Button;
    	public JPanel formRegistration(final JFrame f, final JMenuItem menuitem) {
    okButton = new JButton();
    okButton.setText("ok");
    okButton.setActionCommand(CMD_OK);
    		okButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent event) {
    // windowAction(event);
    System.out
    .println("ACTION : BUTTON OK WAS CLICKED and menu item enabled");
    System.out.println(okButton.getActionCommand());
    menuitem.setEnabled(true);//and close
    MenuBar.FrameClearAction(f);
    }
    });
    		ok1Button = new JButton();
    ok1Button.setText("ok 1");
    ok1Button.setActionCommand(CMD_OK);
    ok1Button.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent event) {
    // windowAction(event);
    System.out.println("ACTION : BUTTON 1 OK WAS CLICKED");
    System.out.println(ok1Button.getActionCommand());
    menuitem.setEnabled(true);//and close
    MenuBar.FrameClearAction(f);
    }
    });
    		ok2Button = new JButton(); // we'll need this soon
    ok2Button.setText("ok 2");
    ok2Button.setActionCommand(CMD_OK);
    ok2Button.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent event) {
    // windowAction(event);
    System.out.println("ACTION : BUTTON 2 OK WAS CLICKED");
    System.out.println(ok2Button.getActionCommand());
    menuitem.setEnabled(true);//and close
    MenuBar.FrameClearAction(f);
    }
    });
    		TripleForm bean = new TripleForm();
    BeanAdapter adapter = new BeanAdapter(bean, true);
    		ValueModel nameModel = adapter.getValueModel("username");
    ValueModel ageModel = adapter.getValueModel("age");
    ValueModel commentModel = adapter.getValueModel("comment");
    		JTextField userinput = BasicComponentFactory.createTextField(nameModel);
    JTextField ageinput = BasicComponentFactory.createTextField(ageModel);
    JTextArea commentinput = BasicComponentFactory
    .createTextArea(commentModel);
    		ValueModel nameModel01 = adapter.getValueModel("username");
    ValueModel ageModel01 = adapter.getValueModel("age");
    ValueModel commentModel01 = adapter.getValueModel("comment");
    		JTextField userinput01 = BasicComponentFactory
    .createTextField(nameModel01);
    JTextField ageinput01 = BasicComponentFactory
    .createTextField(ageModel01);
    JTextArea commentinput01 = BasicComponentFactory
    .createTextArea(commentModel01);
    		ValueModel nameModel02 = adapter.getValueModel("username");
    ValueModel ageModel02 = adapter.getValueModel("age");
    ValueModel commentModel02 = adapter.getValueModel("comment");
    		JTextField userinput02 = BasicComponentFactory
    .createTextField(nameModel02);
    JTextField ageinput02 = BasicComponentFactory
    .createTextField(ageModel02);
    JTextArea commentinput02 = BasicComponentFactory
    .createTextArea(commentModel02);
    		// Panel 1 = left + center
    		// left
    JPanel left = new JPanel();
    left.setLayout(new RiverLayout());
    left.add("right", new JLabel("Registration form left"));
    left.add("p left", new JLabel("Name"));
    left.add("tab hfill", userinput);
    left.add("br", new JLabel("Age"));
    ageinput.setColumns(5);
    left.add("tab", ageinput);
    left.add("br vtop", new JLabel("Comment"));
    commentinput.setRows(3);
    left.add("tab hfill vfill", new JScrollPane(commentinput));
    left.add("p right", okButton);
    // added to level the content of the 3 panels
    left.setBorder(Borders.DIALOG_BORDER);
    		// center
    JPanel center = new JPanel();
    center.setLayout(new RiverLayout());
    center.add("right", new JLabel("Registration form center"));
    center.add("p left", new JLabel("Name-center"));
    center.add("tab hfill", userinput01);
    center.add("br", new JLabel("Age-center"));
    ageinput01.setColumns(2);
    center.add("tab", ageinput01);
    center.add("br vtop", new JLabel("Comment-center"));
    center.add("tab hfill vfill", new JScrollPane(commentinput01));
    center.add("p right", ok1Button);
    center.add(left);
    // added to level the content of the 3 panels
    center.setBorder(Borders.DIALOG_BORDER);
    		JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
    left, center);
    JPanel panel1 = new JPanel();
    panel1.setLayout(new RiverLayout());
    splitPane.setBorder(new EmptyBorder(-10, -5, -20, -8));
    //splitPane.setDividerLocation(150);
    //splitPane.setOneTouchExpandable(true);
    splitPane.setDividerSize(3);
    panel1.add("hfill vfill", splitPane);
    		JPanel right = new JPanel();
    right.setLayout(new RiverLayout());
    right.add("right", new JLabel("Registration form right"));
    right.add("p left", new JLabel("Name-right"));
    right.add("tab hfill", userinput02);
    right.add("br", new JLabel("Age-right"));
    ageinput02.setColumns(3);
    right.add("tab", ageinput02);
    right.add("br vtop", new JLabel("Comment-right"));
    right.add("tab hfill vfill", new JScrollPane(commentinput02));
    right.add("p right", ok2Button);
    // added to level the content of the 3 panels
    right.setBorder(new EmptyBorder(6, 0, 6, 0));
    		JSplitPane splitPane0 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
    panel1, right);
    		splitPane0.setBorder(new EmptyBorder(-4, 0, -10, 0));
    splitPane0.setDividerSize(3);
    		//RegistrationMasterForm
    		JPanel masterform = new JPanel();
    masterform.setLayout(new RiverLayout());
    masterform.add("vfill hfill", splitPane0);
    		return masterform;
    }
    }
     
    
    MenuBar.java
    package src;
    /*
    * Copyright (c) 2008 - 2008 willems piet pwProTech All rights reserved.
    *
    * Redistribution and use in source and binary forms, with or without
    * modification, are permitted provided that the following conditions
    * are met:
    *
    * - Redistributions of source code must retain the above copyright
    * notice, this list of conditions and the following disclaimer.
    *
    * - Redistributions in binary form must reproduce the above copyright
    * notice, this list of conditions and the following disclaimer in the
    * documentation and/or other materials provided with the distribution.
    *
    *
    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
    * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
    * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
    * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
    * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
    * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    */
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.KeyEvent;
    import javax.swing.ImageIcon;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JMenu;
    import javax.swing.JMenuBar;
    import javax.swing.JMenuItem;
    import javax.swing.KeyStroke;
    import se.datadosen.component.RiverLayout;
    import forms.masterforms.SingleMasterForm;
    import forms.masterforms.TripleMasterForm;
    public class MenuBar {
    protected JMenuBar menuBar;
    	public JMenuBar MenuBarRegistration(JFrame frame) {
    //send to where the GUI is created:
    //Call : frame.setJMenuBar( MenuBarRegistration(frame));
    		JMenu menu, submenu;
    JMenuItem menuItem1, menuItem2, menuItem3, menuItem4, menuItem5, menuItem51, menuItem52;
    		//Create the menu bar.
    menuBar = new JMenuBar();
    		//Build the first menu.
    menu = new JMenu("TestMenu 1");
    menu.setMnemonic(KeyEvent.VK_A);
    //menu.getAccessibleContext().setAccessibleDescription(
    // "The only menu in this program that has menu items");
    menuBar.add(menu);
    		//a group of JMenuItems
    menuItem1 = new JMenuItem("Clear test", KeyEvent.VK_T);
    menuItem1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1,
    ActionEvent.ALT_MASK));
    menuItem1.setName("een");
    menu.add(menuItem1);
    		//  Text - icon sample
    menuItem2 = new JMenuItem("Single form", new ImageIcon(
    "images/yourpic.gif"));
    		menuItem2.setMnemonic(KeyEvent.VK_B);
    menuItem2.setName("singlemasterform");
    menu.add(menuItem2);
    		menuItem3 = new JMenuItem("Triple form", new ImageIcon(
    "images/yourpic.gif"));
    menuItem3.setMnemonic(KeyEvent.VK_B);
    menuItem3.setName("twee");
    menu.add(menuItem3);
    		menuItem5 = new JMenuItem(new ImageIcon("images/yourpic.gif"));
    //Only icon dample
    menuItem5.setMnemonic(KeyEvent.VK_D);
    menu.add(menuItem3);
    		//a submenu
    menu.addSeparator();
    submenu = new JMenu("Submenu sample");
    submenu.setMnemonic(KeyEvent.VK_S);
    		menuItem51 = new JMenuItem("Submenu item 1 sample");
    menuItem51.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_2,
    ActionEvent.ALT_MASK));
    submenu.add(menuItem51);
    		menuItem52 = new JMenuItem("Submenu item 2 sample");
    submenu.add(menuItem52);
    menu.add(submenu);
    		//Build second menu in the menu bar.
    menu = new JMenu("TestMenu 2");
    menu.setMnemonic(KeyEvent.VK_N);
    menuBar.add(menu);
    		//Adding action listener to menu items
    //------------------------------------
    menuAction(menuItem1, frame);
    menuAction(menuItem2, frame);
    menuAction(menuItem3, frame);
    		menuItem51.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    System.out.println("SubmenuItem 1 is pressed");
    }
    });
    menuItem52.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    System.out.println("SubmenuItem 2 is pressed");
    }
    });
    		return menuBar;
    	}
    	private void menuAction(final JMenuItem menuItem, final JFrame f) {
    menuItem.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    String action = menuItem.getName();
    System.out.println("action" + action);
    if (action.equals("een")) {
    menuSelectionClearContentPane(f);
    } else if (action.equals("twee")) {
    menuSelectionTripleMasterForm(menuItem, f);
    } else if (action.equals("singlemasterform")) {
    menuSelectionSingleMasterForm(menuItem, f);
    }
    }
    			private void menuSelectionClearContentPane(final JFrame f) {
    enableItemsMenu0();
    FrameClearAction(f);
    System.out.println(f.getName() + " is Cleared");
    }
    			private void menuSelectionSingleMasterForm(
    final JMenuItem menuItem, final JFrame f) {
    enableItemsMenu0();
    menuItem.setEnabled(false);
    f.getContentPane().removeAll();
    SingleMasterForm smf = new SingleMasterForm();
    f.setLayout(new RiverLayout());
    f.getContentPane().add("hfill vfill",
    smf.buildform(f, menuItem));
    System.out.println(f.getName() + " is installed");
    f.validate();
    f.repaint();
    }
    			private void menuSelectionTripleMasterForm(
    final JMenuItem menuItem, final JFrame f) {
    enableItemsMenu0();
    menuItem.setEnabled(false);
    f.getContentPane().removeAll();
    TripleMasterForm rmf = new TripleMasterForm();
    rmf.setMenuItemEnabled(false);
    f.setLayout(new RiverLayout());
    f.getContentPane().add("hfill vfill",
    rmf.formRegistration(f, menuItem));
    System.out.println(f.getName() + " is installed");
    f.validate();
    f.repaint();
    }
    			private void enableItemsMenu0() {
    //ToDo name the item indexes
    getMenuItem(0, 0).setEnabled(true);
    getMenuItem(0, 1).setEnabled(true);
    getMenuItem(0, 2).setEnabled(true);
    }
    });
    }
    	public static void FrameClearAction(JFrame f) {
    		f.getContentPane().removeAll();
    f.getContentPane().setLayout(new RiverLayout());
    f.getContentPane().add(new JLabel("Frame Cleared"));
    f.validate();
    f.repaint();
    		System.out.println("pass" + f.getContentPane().getComponents());
    }
    	protected JMenuItem getMenuItem(int menuIndex, int itemIndex) {
    //JMenuBar menuBar;
    JMenu menu = menuBar.getMenu(menuIndex);
    System.out.println(menu.getName());
    return menu.getItem(itemIndex);
    }
    }
     
    OpeningForm.java
    
    package src;
    /*
    * Copyright (c) 2008 - 2008 willems piet pwProTech All rights reserved.
    *
    * Redistribution and use in source and binary forms, with or without
    * modification, are permitted provided that the following conditions
    * are met:
    *
    * - Redistributions of source code must retain the above copyright
    * notice, this list of conditions and the following disclaimer.
    *
    * - Redistributions in binary form must reproduce the above copyright
    * notice, this list of conditions and the following disclaimer in the
    * documentation and/or other materials provided with the distribution.
    *
    *
    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
    * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
    * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
    * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
    * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
    * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    */
    import java.awt.Dimension;
    import java.awt.Font;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import se.datadosen.component.RiverLayout;
    public class OpeningForm {
    public static JPanel buildForm() {
    JPanel openingPanel = new JPanel();
    openingPanel.setLayout(new RiverLayout());

            JLabel infoLabel = new JLabel();
    JLabel gapLabel = new JLabel();
            gapLabel.setPreferredSize(new Dimension(150, 240));
    infoLabel.setPreferredSize(new Dimension(400, 240));
    infoLabel.setFont(new Font("sansserif", Font.BOLD, 32));
    infoLabel.setText("Test Riverlayout");
    openingPanel.add("p" , gapLabel);
    openingPanel.add("tab" , infoLabel);
    return openingPanel;
    }
    }
     
    
    RiverLayoutTest.java
    package testen;
    /*
    * Copyright (c) 2008 - 2008 willems piet pwProTech All rights reserved.
    *
    * Redistribution and use in source and binary forms, with or without
    * modification, are permitted provided that the following conditions
    * are met:
    *
    * - Redistributions of source code must retain the above copyright
    * notice, this list of conditions and the following disclaimer.
    *
    * - Redistributions in binary form must reproduce the above copyright
    * notice, this list of conditions and the following disclaimer in the
    * documentation and/or other materials provided with the distribution.
    *
    *
    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
    * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
    * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
    * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
    * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
    * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    */
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import com.jgoodies.forms.factories.Borders;
    import beans.TripleForm;
    import se.datadosen.component.RiverLayout;
    import src.MenuBar;
    /* TopLevelDemo.java requires no other files. */
    public class RiverLayoutTest {
    /**
    * Create the GUI and show it.
    */
    private static void createAndShowGUI() {
    //Create and set up the window.
    JFrame frame = new JFrame("Test Layout");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().setLayout(new RiverLayout());
    		//Set the menu bar and add the openingForm to the content pane.
    frame.setJMenuBar(new MenuBar().MenuBarRegistration(frame));
    frame.getContentPane().add("hfill", src.OpeningForm.buildForm());
    		//Display the window.
    frame.setLocation(150, 200);
    frame.pack();
    frame.setVisible(true);
    }
    	public static void main(String[] args) {
    //creating and showing this application's GUI.
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    createAndShowGUI();
    }
    });
    }
    }

    Tags : RiverLayout , sample , java , example , jgoodies , valuemodel, model

     




    Geef hier uw reactie door
    Uw naam *
    Uw e-mail
    URL
    Titel *
    Reactie *
      Persoonlijke gegevens onthouden?
    (* = verplicht!)
    Reacties op bericht (0)


    >

    Blog tegen de regels? Meld het ons!
    Gratis blog op http://blog.seniorennet.be - SeniorenNet Blogs, eenvoudig, gratis en snel jouw eigen blog!