MarginSelect.java :  » XML-UI » xui32 » com » xoetrope » print » Java Open Source

Java Open Source » XML UI » xui32 
xui32 » com » xoetrope » print » MarginSelect.java
package com.xoetrope.print;

import java.util.ArrayList;
import javax.swing.BorderFactory;
import net.xoetrope.swing.XComboBox;
import net.xoetrope.swing.XDialog;
import net.xoetrope.swing.XEdit;
import net.xoetrope.swing.XPanel;
import net.xoetrope.xui.data.XBaseModel;

/**
 * <p> Copyright (c) Xoetrope Ltd., 2001-2007, This software is licensed under
 * the GNU Public License (GPL), please see license.txt for more details. If
 * you make commercial use of this software you must purchase a commercial
 * license from Xoetrope.</p>
 */
public class MarginSelect extends XDialog
{
  XPanel pagePanel, marginPanel;

  /** Creates a new instance of MarginSelect */
  public MarginSelect ()
  {
  }

  public void pageCreated()
  {
    pagePanel = (XPanel)findComponent("pagePanel");
    marginPanel = (XPanel)findComponent("marginPanel");

    pagePanel.setBorder (BorderFactory.createTitledBorder ("Page Size"));
    marginPanel.setBorder (BorderFactory.createTitledBorder ("Margins (millimeters)"));
  }

  public void setMargin()
  {
    XComboBox marginBox = (XComboBox)findComponent("marginBox");
    XEdit left = (XEdit)findComponent("left");
    XEdit right = (XEdit)findComponent("right");
    XEdit top = (XEdit)findComponent("top");
    XEdit bottom = (XEdit)findComponent("bottom");

    String s1 = marginBox.getSelectedItem ().toString ();
    double d1 = Double.valueOf (left.getText ()).doubleValue () * 2.83464567;
    double d2 = Double.valueOf (right.getText ()).doubleValue () * 2.83464567;
    double d3 = Double.valueOf (top.getText ()).doubleValue () * 2.83464567;
    double d4 = Double.valueOf (bottom.getText ()).doubleValue () * 2.83464567;

    ArrayList marginList = new ArrayList();
    marginList.add (s1);
    marginList.add (new Float((float)d1));
    marginList.add (new Float((float)d2));
    marginList.add (new Float((float)d3));
    marginList.add (new Float((float)d4));
    rootModel.set ("margins", marginList);

    closeDlg();
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.