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....
    06-06-2008
    Klik hier om een link te hebben waarmee u dit artikel later terug kunt lezen.Presentationmodel :: buffered model :: RiverLayout








    CustomerBean.java
    Structure

    package samples.s01
       
    CustomerBean.java
       
    PresentationModelBuild.java
       
    CustomerPresentationModel.java
       
    CustomBeanlaunch.java



    ----------------------------------------------------------------
    CustomerBean.java
    -----------------------------------------------------------------

    package samples.s01;

    *
     * Copyright (c) 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.
     *
     */

    import com.jgoodies.binding.beans.Model;

    public class CustomerBean extends Model {
        public static final String NAME_PROPERTY = "name";
        public static final String OCCUPATION_PROPERTY = "occupation";
        private String name;
        private String occupation;

        public String getName() {
            return name;
        }

        public void setName(String name) {
            String oldValue = name;
            this.name = name;
            firePropertyChange(NAME_PROPERTY, oldValue, name);
        }

        public String getOccupation() {
            return occupation;
        }

        public void setOccupation(String occupation) {
            String oldValue = occupation;
            this.occupation = occupation;
            firePropertyChange(OCCUPATION_PROPERTY, oldValue, occupation);
        }

    }


    PresentationModelBuild.java


    package samples.s01;

    *
     * Copyright (c) 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.
     *
     */

    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.TextField;

    import javax.swing.JButton;
    import javax.swing.JCheckBox;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JTextField;

    import se.datadosen.component.RiverLayout;

    import com.jgoodies.binding.adapter.BasicComponentFactory;

    public class PresentationModelBuild extends JPanel {

        static JTextField nameInput,occupationInput;
        static JButton commitButton;
        static JButton resetButton;
        JButton sendButton;
        static CustomerPresentationModel presentationModel;

        public void createComponents() {

            presentationModel = new CustomerPresentationModel(
                    new CustomerBean());

            nameInput = BasicComponentFactory.createTextField(presentationModel
                    .getBufferedModel(CustomerBean.NAME_PROPERTY));
            occupationInput = BasicComponentFactory
                    .createTextField(presentationModel
                            .getBufferedModel(CustomerBean.OCCUPATION_PROPERTY));

            commitButton = new JButton(presentationModel.getCommitAction());
            resetButton = new JButton(presentationModel.getResetAction());
            sendButton = new JButton(presentationModel.getSendAction());
        }

        public void constructGui() {
            JFrame frame = new JFrame();
            JPanel CustomBeanFrm = new JPanel();
            frame.getContentPane().setLayout(new RiverLayout());
            frame.getContentPane().add(CustomBeanFrm);

            CustomBeanFrmGui(CustomBeanFrm);
            commitButton.setEnabled(false);
            commitButton.setEnabled(false);
            frame.pack();
            frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
            frame.setVisible(true);
        }

        private void CustomBeanFrmGui(JPanel CustomBeanFrm) {
            createComponents();
            CustomBeanFrm.setLayout(new RiverLayout());
            CustomBeanFrm.add("br left", new JLabel("PresentationModel"));
            CustomBeanFrm.add("br hfill", separator(Color.RED));


            CustomBeanFrm.add("br", new JLabel("Name"));
            CustomBeanFrm.add("tab hfill", nameInput);

            CustomBeanFrm.add("br", new JLabel("Occupation"));
            CustomBeanFrm.add("tab hfill", occupationInput);
            CustomBeanFrm.add("br hfill", separator(Color.GRAY));

           
            CustomBeanFrm.add("p br left", resetButton); // The button ins't really located to the left side
            CustomBeanFrm.add("center", sendButton);
            CustomBeanFrm.add("right", commitButton);
            CustomBeanFrm.add("br hfill", separator(Color.GRAY));

        }

        public static void clearForm() {
            commitButton.setEnabled(false);
            nameInput.setText("");
            occupationInput.setText("");

        }

        private static TextField separator(Color c) {
            TextField separator = new TextField();
            separator.setBackground(c);
            separator.setPreferredSize(new Dimension(20, 2));
            return separator;
        }
    }


    CustomerPresentationModel.java


    package samples.s01;

    *
     * Copyright (c) 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.
     *
     */

    import java.awt.event.ActionEvent;
    import javax.swing.AbstractAction;
    import javax.swing.Action;
    import com.jgoodies.binding.PresentationModel;

    public class CustomerPresentationModel extends PresentationModel {

        private static final long serialVersionUID = 1L;
        CommitAction commitAction;
        ResetAction resetAction;
        SendAction sendAction;
        ClearAction clearAction;
        private final CustomerBean customerBean;

        @SuppressWarnings("unchecked")
        public CustomerPresentationModel(CustomerBean customerBean) {
            super(customerBean);
            this.customerBean = customerBean;
            commitAction = new CommitAction();
            resetAction = new ResetAction();
            sendAction = new SendAction();
            clearAction = new ClearAction();

        }

        public Action getCommitAction() {
            return commitAction;
        }

        public Action getSendAction() {
            return sendAction;
        }

        public Action getResetAction() {
            return resetAction;
        }

        public Action getClearAction() {
            return clearAction;
        }
       
        private class CommitAction extends AbstractAction {
            /**
             *
             */
            private static final long serialVersionUID = 1L;

            public CommitAction() {
                super("Commit");
            }

            public void actionPerformed(ActionEvent e) {

                triggerCommit();
                //getBean();
                displayBufferAndBean("COMMIT action:");
                PresentationModelBuild.clearForm();// disable commitbutton

            }
        }

        private class SendAction extends AbstractAction {

            public SendAction() {
                super("Send");
            }

            public void actionPerformed(final ActionEvent e) {

                // getBean();
                if (PresentationModelBuild.resetButton.isEnabled()) {
                    PresentationModelBuild.resetButton.setEnabled(true);
                }

                if (isBuffering()) {
                    PresentationModelBuild.commitButton.setEnabled(true);

                    displayBufferAndBean("SEND Bufferd :true :: Not yet committed");
                } else {
                    PresentationModelBuild.commitButton.setEnabled(false);
                    displayBufferAndBean("SEND Bufferd :true :: yet Committed");
                    //Bufferd still true so by a reset the bufferd values are still available
                }

            }

        }

        private class ResetAction extends AbstractAction {

            public ResetAction() {
                super("Reset");
            }

            public void actionPerformed(ActionEvent e) {

                // release():
                // Removes the PropertyChangeHandler from the observed bean, if the
                // bean is not null. Also removes all listeners from the bean that
                // have been registered with #addBeanPropertyChangeListener before.
                if (isBuffering()) {
                    triggerFlush();
                    resetChanged();
                    System.out.println("RESET action : If changes : Previous restored");
                    PresentationModelBuild.commitButton.setEnabled(false);
                }
            }
        }

        private class ClearAction extends AbstractAction {
            // Not Used

            public ClearAction() {
                super("Clear Form");
            }

            public void actionPerformed(ActionEvent e) {

                PresentationModelBuild.resetButton.setEnabled(false);
                PresentationModelBuild.clearForm();
                System.out.println("clearform");
            }
        }

        private void displayBufferAndBean(String buffering) {
            System.out.println("" + "Result " + buffering + "n"
                    + "-------------------------------------------------n"
                    + "Bufferd values :" + "n"
                    + "Buffered beanvalue name :" + getBufferedValue("name") + "n"
                    + "Buffered beanvalue occupation :"+ getBufferedValue("occupation") + "n"
                    + "" + "n"
                    + "Bean values :" + "n"
                    + "CustomerBean value name :" + customerBean.getName() + "n"
                    + "CustomerBean value occupation :" + customerBean.getOccupation() + "n"
                    + "---------------------------------------------------");
        }
    }



    CustomBeanlaunch.java
    --------------------------------------------------------------------------------------------

    package samples.s01;

    *
     * Copyright (c) 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.
     *
     */

    public class CustomBeanlaunch {

        /**
         * @param args
         */
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            PresentationModelBuild pme = new PresentationModelBuild();
            pme.constructGui();
        }
    }


    RESULTAAT



    Result SEND Bufferd :true :: Not yet committed
    -------------------------------------------------
    Bufferd values :
    Buffered beanvalue name :piet
    Buffered beanvalue occupation :job

    Bean values :
    CustomerBean value name :null
    CustomerBean value occupation :null
    ---------------------------------------------------
    RESET action : If changes : Previous restored
    Result SEND Bufferd :true :: Not yet committed
    -------------------------------------------------
    Bufferd values :
    Buffered beanvalue name :piet
    Buffered beanvalue occupation :job

    Bean values :
    CustomerBean value name :null
    CustomerBean value occupation :null
    ---------------------------------------------------
    Result COMMIT action:
    -------------------------------------------------
    Bufferd values :
    Buffered beanvalue name :piet
    Buffered beanvalue occupation :job

    Bean values :
    CustomerBean value name :piet
    CustomerBean value occupation :job
    ---------------------------------------------------

    Tags :: RiverLayout , JGoodies , Valueholder , bindings, formmodel , model , sample, samples, java


    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!