Example usage for javax.swing JLabel getX

List of usage examples for javax.swing JLabel getX

Introduction

In this page you can find the example usage for javax.swing JLabel getX.

Prototype

@BeanProperty(bound = false)
public int getX() 

Source Link

Document

Returns the current x coordinate of the component's origin.

Usage

From source file:labr_client.xml.ObjToXML.java

public static void saveProfile(Component[] comps, String profile) {

    try {//from  w  w  w  .ja  v  a  2 s. c  om
        if (comps != null) {
            JAXBContext context = JAXBContext.newInstance(LabrRequest.class);
            Marshaller m = context.createMarshaller();
            //for pretty-print XML in JAXB
            m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
            LabrRequest request = new LabrRequest();
            for (Component comp : comps) {

                if (comp.getName() != null) {

                    if (comp.getName().equals("name")) {
                        request.patient.name.setValue(((JTextField) comp).getText());
                        request.patient.name.setX(comp.getX());
                        request.patient.name.setY(comp.getY());
                        request.patient.name.setWidth(comp.getWidth());
                    } else if (comp.getName().equals("firstName")) {
                        request.patient.firstName.setValue(((JTextField) comp).getText());
                        request.patient.firstName.setX(comp.getX());
                        request.patient.firstName.setY(comp.getY());
                        request.patient.firstName.setWidth(comp.getWidth());
                    } else if (comp.getName().equals("birthDate")) {
                        request.patient.birthDate.setValue(((JFormattedTextField) comp).getText());
                        request.patient.birthDate.setX(comp.getX());
                        request.patient.birthDate.setY(comp.getY());
                        request.patient.birthDate.setWidth(comp.getWidth());
                    } else if (comp.getName().equals("gender")) {
                        request.patient.gender.setValue((String) (((JComboBox) comp).getSelectedItem()));
                        request.patient.gender.setX(comp.getX());
                        request.patient.gender.setY(comp.getY());
                    } else if (comp.getName().equals("straatAndNumber")) {
                        request.patient.straatAndNumber.setValue(((JTextField) comp).getText());
                        request.patient.straatAndNumber.setX(comp.getX());
                        request.patient.straatAndNumber.setY(comp.getY());
                        request.patient.straatAndNumber.setWidth(comp.getWidth());
                    } else if (comp.getName().equals("zip")) {
                        request.patient.zip.setValue(((JTextField) comp).getText());
                        request.patient.zip.setX(comp.getX());
                        request.patient.zip.setY(comp.getY());
                        request.patient.zip.setWidth(comp.getWidth());
                    } else if (comp.getName().equals("city")) {
                        request.patient.city.setValue(((JTextField) comp).getText());
                        request.patient.city.setX(comp.getX());
                        request.patient.city.setY(comp.getY());
                        request.patient.city.setWidth(comp.getWidth());
                    } else if (comp.getName().equals("country")) {
                        request.patient.country.setValue((String) (((JComboBox) comp).getSelectedItem()));
                        request.patient.country.setX(comp.getX());
                        request.patient.country.setY(comp.getY());
                    } else if (comp.getName().equals("nationalNumber")) {
                        request.patient.nationalNumber.setValue(((JTextField) comp).getText());
                        request.patient.nationalNumber.setX(comp.getX());
                        request.patient.nationalNumber.setY(comp.getY());
                        request.patient.nationalNumber.setWidth(comp.getWidth());
                    } else if (comp.getName().equals("Save")) {
                        JButton jbut = (JButton) comp;
                        ImageIcon icon = (ImageIcon) jbut.getIcon();
                        request.buttons.save.setX(comp.getX());
                        request.buttons.save.setY(comp.getY());
                        request.buttons.save.setValue("Save");
                        if (icon != null) {
                            request.buttons.save.setIcon(icon.getDescription());
                        }
                    } else if (comp.getName().equals("Search")) {
                    } else if (comp.getName().equals("saveAndSend")) {
                        request.patient.nationalNumber.setValue(((JTextField) comp).getText());
                        request.patient.nationalNumber.setX(comp.getX());
                        request.patient.nationalNumber.setY(comp.getY());
                        request.patient.nationalNumber.setWidth(comp.getWidth());
                    } else if (comp.getName().equals("print")) {
                        request.patient.nationalNumber.setValue(((JTextField) comp).getText());
                        request.patient.nationalNumber.setX(comp.getX());
                        request.patient.nationalNumber.setY(comp.getY());
                        request.patient.nationalNumber.setWidth(comp.getWidth());
                    } else {
                        Class<? extends Component> c = comp.getClass();
                        if (c.getSimpleName().equals("JLabel")) {
                            JLabel lbl = (JLabel) comp;
                            LabrXMLLabel l = new LabrXMLLabel();
                            l.setColor(String.valueOf(lbl.getForeground().getRGB()));
                            l.setSize(lbl.getFont().getSize());
                            l.setId(lbl.getName());
                            l.setValue(lbl.getText());
                            l.setX(lbl.getX());
                            l.setY(lbl.getY());
                            request.labels.getLabel().add(l);
                        }
                        ;
                        if (c.getSimpleName().equals("JCheckBox")) {
                            JCheckBox chbx = (JCheckBox) comp;
                            LabrXMLRequest req = new LabrXMLRequest();
                            req.setX(chbx.getX());
                            req.setY(chbx.getY());
                            req.setLoinc(chbx.getName());
                            req.setValue(chbx.getText());
                            req.setSelected(chbx.isSelected());
                            request.requests.getRequest().add(req);
                        }
                        ;
                        if (c.getSimpleName().equals("JTextBox")) {

                        }
                        ;
                    }
                }

            }
            m.marshal(request, new File(PublicVars.getUserData()[9] + "\\" + profile + ".xml"));
        }
    } catch (JAXBException e) {
        e.printStackTrace();
    }
}

From source file:labr_client.xml.ObjToXML.java

public static LabrRequest saveLabrRequest(Component[] comps) {

    try {// ww w.  j  a  v  a  2 s.  c o  m
        if (comps != null) {
            JAXBContext context = JAXBContext.newInstance(LabrRequest.class);
            Marshaller m = context.createMarshaller();
            //for pretty-print XML in JAXB
            m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
            LabrRequest request = new LabrRequest();
            for (Component comp : comps) {

                if (comp.getName() != null) {

                    if (comp.getName().equals("name")) {
                        request.patient.name.setValue(((JTextField) comp).getText());
                        request.patient.name.setX(comp.getX());
                        request.patient.name.setY(comp.getY());
                        request.patient.name.setWidth(comp.getWidth());
                    } else if (comp.getName().equals("firstName")) {
                        request.patient.firstName.setValue(((JTextField) comp).getText());
                        request.patient.firstName.setX(comp.getX());
                        request.patient.firstName.setY(comp.getY());
                        request.patient.firstName.setWidth(comp.getWidth());
                    } else if (comp.getName().equals("birthDate")) {
                        request.patient.birthDate.setValue(((JFormattedTextField) comp).getText());
                        request.patient.birthDate.setX(comp.getX());
                        request.patient.birthDate.setY(comp.getY());
                        request.patient.birthDate.setWidth(comp.getWidth());
                    } else if (comp.getName().equals("gender")) {
                        request.patient.gender.setValue((String) (((JComboBox) comp).getSelectedItem()));
                        request.patient.gender.setX(comp.getX());
                        request.patient.gender.setY(comp.getY());
                    } else if (comp.getName().equals("straatAndNumber")) {
                        request.patient.straatAndNumber.setValue(((JTextField) comp).getText());
                        request.patient.straatAndNumber.setX(comp.getX());
                        request.patient.straatAndNumber.setY(comp.getY());
                        request.patient.straatAndNumber.setWidth(comp.getWidth());
                    } else if (comp.getName().equals("zip")) {
                        request.patient.zip.setValue(((JTextField) comp).getText());
                        request.patient.zip.setX(comp.getX());
                        request.patient.zip.setY(comp.getY());
                        request.patient.zip.setWidth(comp.getWidth());
                    } else if (comp.getName().equals("city")) {
                        request.patient.city.setValue(((JTextField) comp).getText());
                        request.patient.city.setX(comp.getX());
                        request.patient.city.setY(comp.getY());
                        request.patient.city.setWidth(comp.getWidth());
                    } else if (comp.getName().equals("country")) {
                        request.patient.country.setValue((String) (((JComboBox) comp).getSelectedItem()));
                        request.patient.country.setX(comp.getX());
                        request.patient.country.setY(comp.getY());
                    } else if (comp.getName().equals("nationalNumber")) {
                        request.patient.nationalNumber.setValue(((JTextField) comp).getText());
                        request.patient.nationalNumber.setX(comp.getX());
                        request.patient.nationalNumber.setY(comp.getY());
                        request.patient.nationalNumber.setWidth(comp.getWidth());
                    } else if (comp.getName().equals("Save")) {
                        JButton jbut = (JButton) comp;
                        ImageIcon icon = (ImageIcon) jbut.getIcon();
                        request.buttons.save.setX(comp.getX());
                        request.buttons.save.setY(comp.getY());
                        request.buttons.save.setValue("Save");
                        if (icon != null) {
                            request.buttons.save.setIcon(icon.getDescription());
                        }
                    } else if (comp.getName().equals("Search")) {
                    } else if (comp.getName().equals("saveAndSend")) {
                        request.patient.nationalNumber.setValue(((JTextField) comp).getText());
                        request.patient.nationalNumber.setX(comp.getX());
                        request.patient.nationalNumber.setY(comp.getY());
                        request.patient.nationalNumber.setWidth(comp.getWidth());
                    } else if (comp.getName().equals("print")) {
                        request.patient.nationalNumber.setValue(((JTextField) comp).getText());
                        request.patient.nationalNumber.setX(comp.getX());
                        request.patient.nationalNumber.setY(comp.getY());
                        request.patient.nationalNumber.setWidth(comp.getWidth());
                    } else {
                        Class<? extends Component> c = comp.getClass();
                        if (c.getSimpleName().equals("JLabel")) {
                            JLabel lbl = (JLabel) comp;
                            LabrXMLLabel l = new LabrXMLLabel();
                            l.setColor(String.valueOf(lbl.getForeground().getRGB()));
                            l.setSize(lbl.getFont().getSize());
                            l.setId(lbl.getName());
                            l.setValue(lbl.getText());
                            l.setX(lbl.getX());
                            l.setY(lbl.getY());
                            request.labels.getLabel().add(l);
                        }
                        ;
                        if (c.getSimpleName().equals("JCheckBox")) {
                            JCheckBox chbx = (JCheckBox) comp;
                            LabrXMLRequest req = new LabrXMLRequest();
                            req.setX(chbx.getX());
                            req.setY(chbx.getY());
                            req.setLoinc(chbx.getName());
                            req.setValue(chbx.getText());
                            req.setSelected(chbx.isSelected());
                            request.requests.getRequest().add(req);
                        }
                        ;
                        if (c.getSimpleName().equals("JTextBox")) {

                        }
                        ;
                    }
                }
            }
            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddhhmm");
            String date = dateFormat.format(Calendar.getInstance().getTime());
            request.attributes.setTitle("LABR-" + PublicVars.getUserData()[5] + "-" + date);
            return request;
        }
        return null;
    } catch (JAXBException e) {
        e.printStackTrace();
        return null;
    }
}

From source file:org.encog.workbench.dialogs.common.ChartField.java

public int createField(JPanel panel, int x, int y, int width) {
    this.chartHolder = new JPanel();

    XYDataset dataset = generator.createDataset();
    JFreeChart chart = generator.createChart(dataset);
    ChartPanel chartPanel = new ChartPanel(chart);
    chartHolder.setLayout(new BorderLayout());
    chartHolder.add(chartPanel, BorderLayout.CENTER);
    chartHolder.add(this.refreshButton = new JButton("Refresh Chart"), BorderLayout.SOUTH);

    this.refreshButton.addActionListener(this);
    this.setField(chartHolder);

    this.getField().setLocation(5, y);
    this.getField().setSize(this.getOwner().getWidth() - 5, height);

    JLabel label = createLabel();
    label.setVisible(false);//from   ww w  .  j  a va  2  s. c o m
    label.setLocation(label.getX(), y);
    panel.add(label);
    panel.add(this.getField());

    return y + this.getField().getHeight();
}