Example usage for java.text DateFormat getDateInstance

List of usage examples for java.text DateFormat getDateInstance

Introduction

In this page you can find the example usage for java.text DateFormat getDateInstance.

Prototype

public static final DateFormat getDateInstance(int style) 

Source Link

Document

Gets the date formatter with the given formatting style for the default java.util.Locale.Category#FORMAT FORMAT locale.

Usage

From source file:com.sample.partnerprofile.portlet.JSPPortlet.java

public void processAction(ActionRequest req, ActionResponse res) throws IOException, PortletException {

    String command = req.getParameter("command");

    int id = 0;/*from ww  w. j a v  a 2  s .c o  m*/
    long userId = 0;
    userId = PortalUtil.getUserId(req);
    System.out.println("userId in action request este " + String.valueOf(userId));

    try {
        id = Integer.parseInt(req.getParameter("id"));
        //userId = Integer.parseInt(req.getParameter("userId"));
    } catch (Exception e) {
    }

    // user relatesd
    String name = req.getParameter("first_name");
    String userLastName = req.getParameter("last_name");
    String userCompanyName = req.getParameter("userCompanyName");
    String userPositionCompany = req.getParameter("userPositionCompany");
    String userMobilePhone = req.getParameter("telephone_user");
    String userWorkPhone = req.getParameter("telefax_user");
    // company related
    String partnerDescription = req.getParameter("partnerDescription");
    int partnerNumber = 1;
    if (req.getParameter("partnerNumber") != null)
        partnerNumber = Integer.parseInt(req.getParameter("partnerNumber"));
    String telephone = req.getParameter("telephone");
    String telefax = req.getParameter("telefax");
    String mail = req.getParameter("mail");
    String street1 = req.getParameter("street1");
    String street2 = req.getParameter("street2");
    String zipcode = req.getParameter("zipcode");
    String city = req.getParameter("city");
    String state_province = req.getParameter("state_province");
    String country = req.getParameter("country");
    String micrositeAdress = req.getParameter("micrositeAdress");
    String company_website = req.getParameter("company_website");
    String noemployees = req.getParameter("noemployees");
    String geographic_coverage = req.getParameter("geographic_coverage");
    String parent_company_name = req.getParameter("parent_company_name");
    String country_parent_company = req.getParameter("country_parent_company");
    String channel_partner_since = req.getParameter("channel_partner_since");
    String primary_business_type = req.getParameter("primary_business_type");
    String secondary_business_type = req.getParameter("secondary_business_type");
    String sap_solution_focus = req.getParameter("sap_solution_focus");
    String industry_micro_vertical_focus = req.getParameter("industry_micro_vertical_focus");

    String last_review_Date = req.getParameter("last_review_Date");
    String reviewed_by = req.getParameter("reviewed_by");
    String profile_added = "";//req.getParameter("profile_added");
    String date_updated = "";//req.getParameter("date_updated");
    String modified_by = req.getParameter("modified_by");
    String[] SAPitems = req.getParameterValues("sap_solution_focus");
    String[] industry = req.getParameterValues("industry");
    String[] countryCoverage = req.getParameterValues("country_coverage");

    //search related
    String[] SAPitems_search = req.getParameterValues("sap_solution_focus_search");
    String industrySearch = req.getParameter("industry_search");
    String[] countryCoverage_search = req.getParameterValues("country_coverage_search");
    String country_search = req.getParameter("country_search");
    String primary_business_type_search = req.getParameter("primary_business_type_search");
    try {
        SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy");
        DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);

        if (command.equals("add")) {
            // user
            // user adress + phone

            // company
            CompanyItem companyItem = new CompanyItem();

            companyItem.setName(userCompanyName);
            companyItem.setDescription(partnerDescription);
            companyItem.setCompanyNo(partnerNumber);
            companyItem.setCompanyFriendlySite(micrositeAdress);
            companyItem.setCompanySite(company_website);
            if (noemployees != null && !noemployees.isEmpty())
                companyItem.setCompanyEmpNo(Integer.parseInt(noemployees));
            companyItem.setParentCompanyName(parent_company_name);
            if (channel_partner_since != null && !channel_partner_since.isEmpty())
                companyItem.setYear(Integer.parseInt(channel_partner_since));
            if (country_parent_company != "") {
                CountryItem countryItemTemp = CountryItemDAO.getCountryItemByName(country_parent_company);
                if (countryItemTemp != null)
                    companyItem.setCountryRegistrationId(countryItemTemp.getId());
            }

            Date tempDate = new Date();

            companyItem.setDateUpdated(new Date());
            companyItem.setDateLastReview(new Date());
            companyItem.setDateUpdated(new Date());

            if (last_review_Date != null && !last_review_Date.isEmpty()) {
                try {
                    tempDate = format.parse(last_review_Date);
                    String value = tempDate.toString();
                    companyItem.setDateLastReview(tempDate);
                } catch (ParseException ex) {
                }
            }

            companyItem.setReviewedBy(reviewed_by);
            companyItem.setModifiedBy(modified_by);
            companyItem.setCompanyUserId(userId);

            CompanyItemDAO.addCompanyItem(companyItem);

            int adressId = companyItem.getAdressId();
            AdressItem adressItem = null;
            if (adressId <= 0) {
                adressItem = new AdressItem();
                adressItem.setCompanyId(companyItem.getId());
                adressItem.setStreet1(street1);
                adressItem.setStreet2(street2);
                adressItem.setCity(city);
                adressItem.setZip(zipcode);
                adressItem.setStateregionname(state_province);
                adressItem.setMail(mail);
                // countryId
                if (country != "") {
                    CountryItem countryItemTemp = CountryItemDAO.getCountryItemByName(country);
                    adressItem.setCountryId(countryItemTemp.getId());
                }
                AdressItemDAO.addAdressItem(adressItem);

                companyItem.setAdressId(adressItem.getId());

                if (telephone != "")
                    AdressItemDAO.updatePhoneItem(adressItem, telephone, 1);
                if (telefax != "")
                    AdressItemDAO.updatePhoneItem(adressItem, telefax, 2);
                AdressItemDAO.updateAdressItem(adressItem);
            }
            // Do update in main table
            CompanyItemDAO.updateCompanyItem(companyItem);

            //2 . SAP solution focus
            CompanyUtil.updateCompanySAPSolutionList(companyItem, SAPitems);
            // 3. Industry
            CompanyUtil.updateCompanyIndustriesList(companyItem, industry);
            //4. primary business type -- primary_business_type
            if (primary_business_type != null)
                CompanyUtil.updateBusinessType(companyItem, primary_business_type, 1);
            //5. secondary business type - secondary_business_type
            if (secondary_business_type != null)
                CompanyUtil.updateBusinessType(companyItem, secondary_business_type, 2);
            //6. country coverage

            if (countryCoverage != null) {
                for (int loopIndex = 0; loopIndex < countryCoverage.length; loopIndex++) {
                    System.out.println(countryCoverage[loopIndex]);
                }
            }
            CompanyUtil.updateCompanyCountryCoverage(companyItem, countryCoverage);

        } else if (command.equals("edit")) {
            //user
            CompanyItem companyItem = CompanyItemDAO.getCompanyItem(id);

            companyItem.setName(userCompanyName);
            companyItem.setDescription(partnerDescription);
            companyItem.setCompanyNo(partnerNumber);
            companyItem.setCompanyFriendlySite(micrositeAdress);
            companyItem.setCompanySite(company_website);
            if (noemployees != null && !noemployees.isEmpty())
                companyItem.setCompanyEmpNo(Integer.parseInt(noemployees));
            companyItem.setParentCompanyName(parent_company_name);
            if (channel_partner_since != null && !channel_partner_since.isEmpty())
                companyItem.setYear(Integer.parseInt(channel_partner_since));
            if (country_parent_company != "") {
                CountryItem countryItemTemp = CountryItemDAO.getCountryItemByName(country_parent_company);
                if (countryItemTemp != null)
                    companyItem.setCountryRegistrationId(countryItemTemp.getId());
            }

            Date date = new Date();
            try {
                date = format.parse(last_review_Date);
            } catch (ParseException ex) {
            }
            companyItem.setDateLastReview(date);
            /*try {date = df.parse(profile_added);
            }catch (ParseException ex){
            }
            companyItem.setDateCreated(date);*/
            companyItem.setDateUpdated(new Date());
            companyItem.setReviewedBy(reviewed_by);
            companyItem.setModifiedBy(modified_by);

            // update childs
            //1 . adress + phone
            int adressId = companyItem.getAdressId();
            AdressItem adressItem = null;
            boolean bIsNew = false;
            if (adressId > 0) {
                adressItem = AdressItemDAO.getAdressItem(adressId);
            } else {
                adressItem = new AdressItem();
                bIsNew = true;
            }
            if (adressItem != null) {
                adressItem.setCompanyId(id);
                adressItem.setStreet1(street1);
                adressItem.setStreet2(street2);
                adressItem.setCity(city);
                adressItem.setZip(zipcode);
                adressItem.setStateregionname(state_province);
                adressItem.setMail(mail);
                // countryId
                if (country != "") {
                    CountryItem countryItemTemp = CountryItemDAO.getCountryItemByName(country);
                    adressItem.setCountryId(countryItemTemp.getId());
                }

                if (bIsNew) {
                    AdressItemDAO.addAdressItem(adressItem);
                    companyItem.setAdressId(adressItem.getId());
                }
                if (telephone != "")
                    AdressItemDAO.updatePhoneItem(adressItem, telephone, 1);
                if (telefax != "")
                    AdressItemDAO.updatePhoneItem(adressItem, telefax, 2);
                AdressItemDAO.updateAdressItem(adressItem);
            }
            // Do update in main table
            CompanyItemDAO.updateCompanyItem(companyItem);

            //2 . SAP solution focus
            CompanyUtil.updateCompanySAPSolutionList(companyItem, SAPitems);
            // 3. Industry
            CompanyUtil.updateCompanyIndustriesList(companyItem, industry);
            //4. primary business type -- primary_business_type
            if (primary_business_type != null)
                CompanyUtil.updateBusinessType(companyItem, primary_business_type, 1);
            //5. secondary business type - secondary_business_type
            if (secondary_business_type != null)
                CompanyUtil.updateBusinessType(companyItem, secondary_business_type, 2);
            //6. country coverage
            CompanyUtil.updateCompanyCountryCoverage(companyItem, countryCoverage);
        } else if (command.equals("delete")) {
            CompanyItemDAO.deleteCompanyItem(id);
        } else if (command.equals("search")) {
            ;
        } else if (command.equals("viewall")) {
            ;
        }
    } catch (SQLException sqle) {
        throw new PortletException(sqle);
    }

}

From source file:org.ambraproject.freemarker.AmbraFreemarkerConfig.java

/**
 * Constructor that loads the list of css and javascript files and page titles for pages which follow the standard
 * templates.  Creates its own composite configuration by iterating over each of the configs in the config to assemble
 * a union of pages defined.//www .  j  a  v a 2 s.  c o m
 *
 * @param configuration Ambra configuration
 * @throws Exception Exception
 */
public AmbraFreemarkerConfig(Configuration configuration) throws Exception {
    if (log.isDebugEnabled()) {
        log.debug("Creating FreeMarker configuration");
    }
    debug = configuration.getBoolean("struts.devMode");
    dirPrefix = configuration.getString("ambra.platform.appContext");
    subdirPrefix = configuration.getString("ambra.platform.resourceSubDir");
    host = configuration.getString("ambra.platform.host");
    casLoginURL = configuration.getString("ambra.services.cas.url.login");
    casLogoutURL = configuration.getString("ambra.services.cas.url.logout");
    registrationURL = configuration.getString("ambra.services.registration.url.registration");
    changePasswordURL = configuration.getString("ambra.services.registration.url.change-password");
    changeEmailURL = configuration.getString("ambra.services.registration.url.change-email");
    doiResolverURL = configuration.getString("ambra.services.crossref.plos.doiurl");
    defaultJournalName = configuration.getString(DEFAULT_JOURNAL_NAME_CONFIG_KEY);
    journals = new HashMap<String, JournalConfig>();
    journalsByIssn = new HashMap<String, JournalConfig>();
    orgName = configuration.getString("ambra.platform.name");
    feedbackEmail = configuration.getString("ambra.platform.email.feedback");
    cache_storage_strong = configuration.getInt("ambra.platform.template_cache.strong",
            DEFAULT_TEMPLATE_CACHE_STRONG);
    cache_storage_soft = configuration.getInt("ambra.platform.template_cache.soft",
            DEFAULT_TEMPLATE_CACHE_SOFT);
    templateUpdateDelay = configuration.getInt("ambra.platform.template_cache.update_delay",
            DEFAULT_TEMPLATE_UPDATE_DELAY);
    String date = configuration.getString("ambra.platform.cisStartDate");
    freemarkerProperties = configuration.subset("ambra.platform.freemarker");
    nedProfileURL = configuration.getString("ned.profile");
    nedRegistrationURL = configuration.getString("ned.registration");

    if (date == null) {
        throw new Exception("Could not find the cisStartDate node in the "
                + "ambra platform configuration.  Make sure the " + "ambra/platform/cisStartDate node exists.");
    }

    try {
        cisStartDate = DateFormat.getDateInstance(DateFormat.SHORT).parse(date);
    } catch (ParseException ex) {
        throw new Exception("Could not parse the cisStartDate value of \"" + date
                + "\" in the ambra platform configuration.  Make sure the cisStartDate is in the "
                + "following format: dd/mm/yyyy", ex);
    }

    loadConfig(configuration);

    processVirtualJournalConfig(configuration);

    // Now that the "journals" Map exists, index that map by Eissn to populate "journalsByEissn".
    if (journals.entrySet() != null && journals.entrySet().size() > 0) {
        for (Entry<String, JournalConfig> e : journals.entrySet()) {
            JournalConfig j = e.getValue();
            journalsByIssn.put(j.getIssn(), j);
        }
    }

    journalUrls = buildUrlMap(journals);
    journalsUrlsByIssn = buildUrlMap(journalsByIssn);

    if (log.isTraceEnabled()) {
        for (Entry<String, JournalConfig> e : journals.entrySet()) {
            JournalConfig j = e.getValue();
            log.trace("Journal: " + e.getKey());
            log.trace("Journal url: " + j.getUrl());
            log.trace("Default Title: " + j.getDefaultTitle());
            log.trace("Default CSS: " + printArray(j.getDefaultCss()));
            log.trace("Default JavaScript: " + printArray(j.getDefaultCss()));
            Map<String, String[]> map = j.getCssFiles();
            for (Entry<String, String[]> entry : map.entrySet()) {
                log.trace("PageName: " + entry.getKey());
                log.trace("CSS FILES: " + printArray(entry.getValue()));
            }
            map = j.getJavaScriptFiles();
            for (Entry<String, String[]> entry : map.entrySet()) {
                log.trace("PageName: " + entry.getKey());
                log.trace("JS FILES: " + printArray(entry.getValue()));
            }

            for (Entry<String, String> entry : j.getTitles().entrySet()) {
                log.trace("PageName: " + entry.getKey());
                log.trace("Title: " + entry.getValue());
            }
        }
        log.trace("Dir Prefix: " + dirPrefix);
        log.trace("SubDir Prefix: " + subdirPrefix);
        log.trace("Host: " + host);
        log.trace("Cas url login: " + casLoginURL);
        log.trace("Case url logout: " + casLogoutURL);
        log.trace("Registration URL: " + registrationURL);
        log.trace("Registration Change Pass URL: " + changePasswordURL);
        log.trace("Registration Change EMail URL: " + changeEmailURL);
        log.trace("DOI Resolver URL: " + doiResolverURL);
        log.trace("Default Journal Name: " + defaultJournalName);
        log.trace("NED Profile URL: " + nedProfileURL);
        log.trace("NED Registration URL: " + nedRegistrationURL);
    }
    if (log.isDebugEnabled()) {
        log.debug("End FreeMarker Configuration Reading");
    }
}

From source file:org.kuali.kra.rules.SaveCustomAttributeRule.java

/**
 * Validates the format/length of custom attribute.
 * @param customAttribute The custom attribute to validate
 * @param errorKey The error key on the interface
 * @return/*  w  ww  . ja  v  a2s . c o  m*/
 */
private boolean validateAttributeFormat(CustomAttribute customAttribute,
        CustomAttributeDataType customAttributeDataType, String errorKey) {
    boolean isValid = true;

    Integer maxLength = customAttribute.getDataLength();
    String attributeValue = customAttribute.getValue();
    if ((maxLength != null) && (maxLength.intValue() < attributeValue.length())) {
        reportError(errorKey, RiceKeyConstants.ERROR_MAX_LENGTH, customAttribute.getLabel(),
                maxLength.toString());
        isValid = false;
    }

    final ValidationPattern validationPattern = VALIDATION_CLASSES
            .get(customAttributeDataType.getDescription());

    // if there is no data type matched, then set error ?
    Pattern validationExpression = validationPattern.getRegexPattern();

    String validFormat = getValidFormat(customAttributeDataType.getDescription());

    if (validationExpression != null && !ALL_REGEX.equals(validationExpression.pattern())) {
        if (customAttributeDataType.getDescription().equalsIgnoreCase(DATE)) {
            if (!attributeValue.matches(DATE_REGEX)) {
                reportError(errorKey, RiceKeyConstants.ERROR_INVALID_FORMAT, customAttribute.getLabel(),
                        attributeValue, validFormat);
                isValid = false;
            }
        } else if (!validationExpression.matcher(attributeValue).matches()) {
            reportError(errorKey, KeyConstants.ERROR_INVALID_FORMAT_WITH_FORMAT, customAttribute.getLabel(),
                    attributeValue, validFormat);
            isValid = false;
        }
    }

    if (isValid && customAttributeDataType.getDescription().equals("Date")) {
        if (!StringUtils.isEmpty(attributeValue)) {
            try {
                DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT);
                dateFormat.setLenient(false);
                dateFormat.parse(attributeValue);
            } catch (ParseException e) {
                reportError(errorKey, KeyConstants.ERROR_DATE, attributeValue, customAttribute.getLabel());
                isValid = false;
            }
        }
    }
    // validate BO data against the database contents 
    String lookupClass = customAttribute.getLookupClass();
    if (lookupClass != null && lookupClass.equals("org.kuali.kra.bo.KcPerson")) {
        if (customAttribute.getDataTypeCode().equals("1")
                && customAttribute.getLookupReturn().equals("userName")) {
            validFormat = getValidFormat(customAttributeDataType.getDescription());
            KcPersonService kps = getKcPersonService();
            KcPerson customPerson = kps.getKcPersonByUserName(customAttribute.getValue());
            if (customPerson == null) {
                GlobalVariables.getErrorMap().putError(errorKey, RiceKeyConstants.ERROR_EXISTENCE,
                        customAttribute.getLabel(), attributeValue, validFormat);
                return false;
            } else {
                return true;
            }
        } else {
            // can only validate for userName, if fullName, etc is used then a lookup
            // is assumed that a lookup is being used, in which case validation 
            // is not necessary
            return true;
        }
    } else if (lookupClass != null && lookupClass.equals("org.kuali.kra.bo.ArgValueLookup")) {
        ArgValueLookupValuesFinder finder = new ArgValueLookupValuesFinder();
        finder.setArgName(customAttribute.getLookupReturn());
        List<KeyLabelPair> kv = finder.getKeyValues();
        Iterator<KeyLabelPair> i = kv.iterator();
        while (i.hasNext()) {
            KeyLabelPair element = (KeyLabelPair) i.next();
            String label = element.getLabel().toLowerCase();
            if (label.equals(attributeValue.toLowerCase())) {
                return true;
            }
        }
        validFormat = getValidFormat(customAttributeDataType.getDescription());
        GlobalVariables.getErrorMap().putError(errorKey, RiceKeyConstants.ERROR_EXISTENCE,
                customAttribute.getLabel(), attributeValue, validFormat);
        return false;
    } else if (lookupClass != null) {
        Class boClass = null;
        try {
            boClass = Class.forName(lookupClass);
        } catch (ClassNotFoundException cnfE) {
            /* Do nothing, checked on input */ }

        if (isInvalid(boClass, keyValue(customAttribute.getLookupReturn(), customAttribute.getValue()))) {
            validFormat = getValidFormat(customAttributeDataType.getDescription());
            GlobalVariables.getErrorMap().putError(errorKey, RiceKeyConstants.ERROR_EXISTENCE,
                    customAttribute.getLabel(), attributeValue, validFormat);
            return false;
        }
    }

    return isValid;
}

From source file:org.jamienicol.episodes.NextEpisodeFragment.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    if (data != null && data.moveToFirst()) {

        final int episodeIdColumnIndex = data.getColumnIndexOrThrow(EpisodesTable.COLUMN_ID);
        episodeId = data.getInt(episodeIdColumnIndex);

        final int seasonNumberColumnIndex = data.getColumnIndexOrThrow(EpisodesTable.COLUMN_SEASON_NUMBER);
        final int seasonNumber = data.getInt(seasonNumberColumnIndex);
        final int episodeNumberColumnIndex = data.getColumnIndexOrThrow(EpisodesTable.COLUMN_EPISODE_NUMBER);
        final int episodeNumber = data.getInt(episodeNumberColumnIndex);

        final int titleColumnIndex = data.getColumnIndexOrThrow(EpisodesTable.COLUMN_NAME);
        final String title = data.getString(titleColumnIndex);

        String titleText = "";
        if (seasonNumber != 0) {
            titleText += getActivity().getString(R.string.season_episode_prefix, seasonNumber, episodeNumber);
        }//from  w w  w .j  a va2 s. co  m
        titleText += title;
        titleView.setText(titleText);

        final int overviewColumnIndex = data.getColumnIndexOrThrow(EpisodesTable.COLUMN_OVERVIEW);
        if (data.isNull(overviewColumnIndex)) {
            overviewView.setText("");
        } else {
            overviewView.setText(data.getString(overviewColumnIndex));
        }

        final int firstAiredColumnIndex = data.getColumnIndexOrThrow(EpisodesTable.COLUMN_FIRST_AIRED);
        if (data.isNull(firstAiredColumnIndex)) {
            dateView.setText("");
        } else {
            final Date date = new Date(data.getLong(firstAiredColumnIndex) * 1000);
            final String dateText = DateFormat.getDateInstance(DateFormat.LONG).format(date);
            dateView.setText(dateText);
        }

        final int watchedColumnIndex = data.getColumnIndexOrThrow(EpisodesTable.COLUMN_WATCHED);
        watched = data.getInt(watchedColumnIndex) > 0 ? true : false;
        watchedCheckBox.setChecked(watched);

        rootView.setVisibility(View.VISIBLE);
    } else {
        episodeId = -1;
        rootView.setVisibility(View.INVISIBLE);
    }
}

From source file:com.pos.spatobiz.app.view.karyawan.HapusKaryawan.java

/** This method is called from within the constructor to
 * initialize the form.// w  ww  .  ja  v  a  2s  .  c  om
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    jeniskelamin = new ButtonGroup();
    labelKode = new WhiteLabel();
    labelNama = new WhiteLabel();
    labelTanggalLahir = new WhiteLabel();
    labelAlamat = new WhiteLabel();
    textKode = new TextBoxTransfer();
    textNama = new TextBoxTransfer();
    textTanggalLahir = new DateBox();
    textAlamat = new WhiteTextArea();
    textTelepon = new TextBoxTransfer();
    labelTelepon = new WhiteLabel();
    labelEmail = new WhiteLabel();
    labelJenisKelamin = new WhiteLabel();
    labelPhoto = new WhiteLabel();
    textEmail = new TextBoxTransfer();
    radioPria = new JRadioButton();
    radioWanita = new JRadioButton();
    imageChooser = new ImageChooser();
    buttonBatal = new Button();
    buttonHapus = new Button();
    buttonCari = new Button();

    setBackground(new Color(0, 0, 0));

    labelKode.setHorizontalAlignment(SwingConstants.RIGHT);
    labelKode.setText("Kode :");

    labelNama.setHorizontalAlignment(SwingConstants.RIGHT);
    labelNama.setText("Nama :");

    labelTanggalLahir.setHorizontalAlignment(SwingConstants.RIGHT);
    labelTanggalLahir.setText("Tanggal Lahir :");

    labelAlamat.setHorizontalAlignment(SwingConstants.RIGHT);
    labelAlamat.setText("Alamat :");

    textNama.setEnabled(false);

    textTanggalLahir.setEnabled(false);
    textTanggalLahir.setFormatterFactory(
            new DefaultFormatterFactory(new DateFormatter(DateFormat.getDateInstance(DateFormat.LONG))));
    textTanggalLahir.setPreferredSize(new Dimension(120, 24));
    textTanggalLahir.setValue(new Date());

    textAlamat.setEnabled(false);

    textTelepon.setEnabled(false);

    labelTelepon.setHorizontalAlignment(SwingConstants.RIGHT);
    labelTelepon.setText("Telepon :");

    labelEmail.setHorizontalAlignment(SwingConstants.RIGHT);
    labelEmail.setText("Email :");

    labelJenisKelamin.setHorizontalAlignment(SwingConstants.RIGHT);
    labelJenisKelamin.setText("Jenis Kelamin :");

    labelPhoto.setHorizontalAlignment(SwingConstants.RIGHT);
    labelPhoto.setText("Photo :");

    textEmail.setEnabled(false);

    jeniskelamin.add(radioPria);
    radioPria.setFont(new Font("Tahoma", 1, 11));
    radioPria.setForeground(new Color(255, 255, 255));
    radioPria.setSelected(true);
    radioPria.setText("Pria");
    radioPria.setEnabled(false);
    radioPria.setOpaque(false);

    jeniskelamin.add(radioWanita);
    radioWanita.setFont(new Font("Tahoma", 1, 11));
    radioWanita.setForeground(new Color(255, 255, 255));
    radioWanita.setText("Wanita");
    radioWanita.setEnabled(false);
    radioWanita.setOpaque(false);

    imageChooser.setEnabled(false);

    buttonBatal.setMnemonic('B');
    buttonBatal.setText("Batal");

    buttonHapus.setMnemonic('H');
    buttonHapus.setText("Hapus");

    buttonCari.setText("Cari");

    GroupLayout layout = new GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(
            layout.createParallelGroup(Alignment.LEADING)
                    .addGroup(
                            Alignment.TRAILING, layout
                                    .createSequentialGroup().addContainerGap().addGroup(layout
                                            .createParallelGroup(Alignment.TRAILING).addGroup(layout
                                                    .createSequentialGroup().addComponent(
                                                            buttonHapus, GroupLayout.PREFERRED_SIZE,
                                                            GroupLayout.DEFAULT_SIZE,
                                                            GroupLayout.PREFERRED_SIZE)
                                                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(
                                                            buttonBatal, GroupLayout.PREFERRED_SIZE,
                                                            GroupLayout.DEFAULT_SIZE,
                                                            GroupLayout.PREFERRED_SIZE))
                                            .addGroup(layout.createSequentialGroup().addGroup(layout
                                                    .createParallelGroup(Alignment.LEADING).addGroup(layout
                                                            .createParallelGroup(Alignment.TRAILING, false)
                                                            .addComponent(labelPhoto, Alignment.LEADING,
                                                                    GroupLayout.DEFAULT_SIZE,
                                                                    GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                            .addComponent(labelJenisKelamin, Alignment.LEADING,
                                                                    GroupLayout.DEFAULT_SIZE,
                                                                    GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                            .addComponent(
                                                                    labelEmail, Alignment.LEADING,
                                                                    GroupLayout.DEFAULT_SIZE,
                                                                    GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                                    .addGroup(layout
                                                            .createParallelGroup(Alignment.TRAILING, false)
                                                            .addComponent(labelTelepon,
                                                                    GroupLayout.DEFAULT_SIZE,
                                                                    GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                            .addComponent(labelTanggalLahir, Alignment.LEADING,
                                                                    GroupLayout.DEFAULT_SIZE,
                                                                    GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                            .addComponent(labelAlamat, Alignment.LEADING,
                                                                    GroupLayout.DEFAULT_SIZE,
                                                                    GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                            .addComponent(labelNama, Alignment.LEADING,
                                                                    GroupLayout.DEFAULT_SIZE,
                                                                    GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                            .addComponent(
                                                                    labelKode, Alignment.LEADING,
                                                                    GroupLayout.DEFAULT_SIZE,
                                                                    GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                                                    .addPreferredGap(ComponentPlacement.RELATED)
                                                    .addGroup(layout.createParallelGroup(Alignment.TRAILING)
                                                            .addComponent(textAlamat, Alignment.LEADING,
                                                                    GroupLayout.DEFAULT_SIZE,
                                                                    GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                            .addComponent(textNama, Alignment.LEADING,
                                                                    GroupLayout.DEFAULT_SIZE, 552,
                                                                    Short.MAX_VALUE)
                                                            .addComponent(textTanggalLahir, Alignment.LEADING,
                                                                    GroupLayout.DEFAULT_SIZE, 552,
                                                                    Short.MAX_VALUE)
                                                            .addComponent(textTelepon, GroupLayout.DEFAULT_SIZE,
                                                                    552, Short.MAX_VALUE)
                                                            .addGroup(Alignment.LEADING, layout
                                                                    .createSequentialGroup()
                                                                    .addComponent(radioPria)
                                                                    .addPreferredGap(
                                                                            ComponentPlacement.UNRELATED)
                                                                    .addComponent(radioWanita))
                                                            .addComponent(
                                                                    imageChooser, Alignment.LEADING,
                                                                    GroupLayout.PREFERRED_SIZE, 253,
                                                                    GroupLayout.PREFERRED_SIZE)
                                                            .addComponent(textEmail, GroupLayout.DEFAULT_SIZE,
                                                                    552, Short.MAX_VALUE)
                                                            .addGroup(layout.createSequentialGroup()
                                                                    .addComponent(textKode,
                                                                            GroupLayout.DEFAULT_SIZE, 488,
                                                                            Short.MAX_VALUE)
                                                                    .addPreferredGap(
                                                                            ComponentPlacement.UNRELATED)
                                                                    .addComponent(buttonCari,
                                                                            GroupLayout.PREFERRED_SIZE,
                                                                            GroupLayout.DEFAULT_SIZE,
                                                                            GroupLayout.PREFERRED_SIZE)))))
                                    .addContainerGap()));
    layout.setVerticalGroup(layout.createParallelGroup(Alignment.LEADING).addGroup(layout
            .createSequentialGroup().addContainerGap()
            .addGroup(layout.createParallelGroup(Alignment.BASELINE)
                    .addComponent(labelKode, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(textKode, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(buttonCari, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(layout.createParallelGroup(Alignment.BASELINE)
                    .addComponent(labelNama, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(textNama, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(layout.createParallelGroup(Alignment.BASELINE)
                    .addComponent(labelTanggalLahir, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(textTanggalLahir, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(layout.createParallelGroup(Alignment.LEADING)
                    .addComponent(labelAlamat, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(textAlamat, GroupLayout.PREFERRED_SIZE, 88, GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(layout.createParallelGroup(Alignment.BASELINE)
                    .addComponent(textTelepon, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(labelTelepon, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(layout.createParallelGroup(Alignment.BASELINE)
                    .addComponent(labelEmail, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(textEmail, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(layout.createParallelGroup(Alignment.BASELINE)
                    .addComponent(labelJenisKelamin, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(radioPria).addComponent(radioWanita))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(layout.createParallelGroup(Alignment.LEADING)
                    .addComponent(labelPhoto, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(imageChooser, GroupLayout.PREFERRED_SIZE, 189, GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createParallelGroup(Alignment.BASELINE)
                    .addComponent(buttonBatal, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(buttonHapus, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE))
            .addContainerGap()));
}

From source file:com.pos.spatobiz.app.view.karyawan.TambahKaryawan.java

/** This method is called from within the constructor to
 * initialize the form.//from   w w  w .ja va2  s. com
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    jeniskelamin = new ButtonGroup();
    labelKode = new WhiteLabel();
    labelNama = new WhiteLabel();
    labelTanggalLahir = new WhiteLabel();
    labelAlamat = new WhiteLabel();
    textKode = new TextBoxTransfer();
    textNama = new TextBoxTransfer();
    textTanggalLahir = new DateBox();
    textAlamat = new WhiteTextArea();
    errorKode = new RedLabel();
    errorNama = new RedLabel();
    errorTanggalLahir = new RedLabel();
    errorAlamat = new RedLabel();
    textTelepon = new TextBoxTransfer();
    labelTelepon = new WhiteLabel();
    labelEmail = new WhiteLabel();
    labelJenisKelamin = new WhiteLabel();
    labelPhoto = new WhiteLabel();
    textEmail = new TextBoxTransfer();
    radioPria = new JRadioButton();
    radioWanita = new JRadioButton();
    errorTelepon = new RedLabel();
    errorEmail = new RedLabel();
    imageChooser = new ImageChooser();
    buttonBatal = new Button();
    buttonTambah = new Button();

    setBackground(new Color(0, 0, 0));

    labelKode.setHorizontalAlignment(SwingConstants.RIGHT);
    labelKode.setText("Kode :");

    labelNama.setHorizontalAlignment(SwingConstants.RIGHT);
    labelNama.setText("Nama :");

    labelTanggalLahir.setHorizontalAlignment(SwingConstants.RIGHT);
    labelTanggalLahir.setText("Tanggal Lahir :");

    labelAlamat.setHorizontalAlignment(SwingConstants.RIGHT);
    labelAlamat.setText("Alamat :");

    textTanggalLahir.setFormatterFactory(
            new DefaultFormatterFactory(new DateFormatter(DateFormat.getDateInstance(DateFormat.LONG))));
    textTanggalLahir.setPreferredSize(new Dimension(120, 24));
    textTanggalLahir.setValue(new Date());

    errorKode.setText("error kode");

    errorNama.setText("error nama");

    errorTanggalLahir.setText("error tanggal lahir");

    errorAlamat.setText("error alamat");

    labelTelepon.setHorizontalAlignment(SwingConstants.RIGHT);
    labelTelepon.setText("Telepon :");

    labelEmail.setHorizontalAlignment(SwingConstants.RIGHT);
    labelEmail.setText("Email :");

    labelJenisKelamin.setHorizontalAlignment(SwingConstants.RIGHT);
    labelJenisKelamin.setText("Jenis Kelamin :");

    labelPhoto.setHorizontalAlignment(SwingConstants.RIGHT);
    labelPhoto.setText("Photo :");

    jeniskelamin.add(radioPria);
    radioPria.setFont(new Font("Tahoma", 1, 11)); // NOI18N
    radioPria.setForeground(new Color(255, 255, 255));
    radioPria.setSelected(true);
    radioPria.setText("Pria");
    radioPria.setOpaque(false);

    jeniskelamin.add(radioWanita);
    radioWanita.setFont(new Font("Tahoma", 1, 11));
    radioWanita.setForeground(new Color(255, 255, 255));
    radioWanita.setText("Wanita");
    radioWanita.setOpaque(false);

    errorTelepon.setText("error telepon");

    errorEmail.setText("error email");

    buttonBatal.setMnemonic('B');
    buttonBatal.setText("Batal");

    buttonTambah.setMnemonic('T');
    buttonTambah.setText("Tambah");

    GroupLayout layout = new GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(Alignment.LEADING).addGroup(layout
            .createSequentialGroup().addContainerGap()
            .addGroup(layout.createParallelGroup(Alignment.LEADING).addGroup(Alignment.TRAILING,
                    layout.createSequentialGroup().addGroup(layout.createParallelGroup(Alignment.LEADING)
                            .addGroup(layout.createParallelGroup(Alignment.TRAILING, false)
                                    .addComponent(labelPhoto, Alignment.LEADING, GroupLayout.DEFAULT_SIZE,
                                            GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(labelJenisKelamin, Alignment.LEADING,
                                            GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(labelEmail, Alignment.LEADING, GroupLayout.DEFAULT_SIZE,
                                            GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGroup(layout.createParallelGroup(Alignment.TRAILING, false)
                                    .addComponent(labelTelepon, GroupLayout.DEFAULT_SIZE,
                                            GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(labelTanggalLahir, Alignment.LEADING,
                                            GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(labelAlamat, Alignment.LEADING, GroupLayout.DEFAULT_SIZE,
                                            GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(labelNama, Alignment.LEADING, GroupLayout.DEFAULT_SIZE,
                                            GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(labelKode, Alignment.LEADING, GroupLayout.DEFAULT_SIZE,
                                            GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                            .addPreferredGap(ComponentPlacement.RELATED)
                            .addGroup(layout.createParallelGroup(Alignment.TRAILING)
                                    .addComponent(textAlamat, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 403,
                                            Short.MAX_VALUE)
                                    .addComponent(textNama, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 403,
                                            Short.MAX_VALUE)
                                    .addComponent(textTanggalLahir, Alignment.LEADING, GroupLayout.DEFAULT_SIZE,
                                            403, Short.MAX_VALUE)
                                    .addComponent(textKode, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 403,
                                            Short.MAX_VALUE)
                                    .addComponent(textTelepon, GroupLayout.DEFAULT_SIZE, 403, Short.MAX_VALUE)
                                    .addGroup(Alignment.LEADING,
                                            layout.createSequentialGroup().addComponent(radioPria)
                                                    .addPreferredGap(ComponentPlacement.UNRELATED)
                                                    .addComponent(radioWanita))
                                    .addComponent(imageChooser, Alignment.LEADING, GroupLayout.PREFERRED_SIZE,
                                            253, GroupLayout.PREFERRED_SIZE)
                                    .addComponent(textEmail, GroupLayout.DEFAULT_SIZE, 403, Short.MAX_VALUE))
                            .addGap(4, 4, 4)
                            .addGroup(layout.createParallelGroup(Alignment.LEADING)
                                    .addComponent(errorKode, GroupLayout.PREFERRED_SIZE,
                                            GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                    .addComponent(errorNama, GroupLayout.PREFERRED_SIZE,
                                            GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                    .addComponent(errorTanggalLahir, GroupLayout.PREFERRED_SIZE,
                                            GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                    .addComponent(errorAlamat, GroupLayout.PREFERRED_SIZE,
                                            GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                    .addComponent(errorTelepon, GroupLayout.PREFERRED_SIZE,
                                            GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                    .addComponent(errorEmail, GroupLayout.PREFERRED_SIZE,
                                            GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
                    .addGroup(Alignment.TRAILING, layout.createSequentialGroup()
                            .addComponent(buttonTambah, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(ComponentPlacement.RELATED).addComponent(buttonBatal,
                                    GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE)))
            .addContainerGap()));
    layout.setVerticalGroup(layout.createParallelGroup(Alignment.LEADING).addGroup(layout
            .createSequentialGroup().addContainerGap()
            .addGroup(layout.createParallelGroup(Alignment.BASELINE)
                    .addComponent(labelKode, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(textKode, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(errorKode, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(layout.createParallelGroup(Alignment.BASELINE)
                    .addComponent(labelNama, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(textNama, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(errorNama, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(layout.createParallelGroup(Alignment.BASELINE)
                    .addComponent(labelTanggalLahir, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(textTanggalLahir, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(errorTanggalLahir, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(layout.createParallelGroup(Alignment.LEADING)
                    .addComponent(labelAlamat, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(textAlamat, GroupLayout.PREFERRED_SIZE, 88, GroupLayout.PREFERRED_SIZE)
                    .addComponent(errorAlamat, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(layout.createParallelGroup(Alignment.BASELINE)
                    .addComponent(textTelepon, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(labelTelepon, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(errorTelepon, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(layout.createParallelGroup(Alignment.BASELINE)
                    .addComponent(labelEmail, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(textEmail, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(errorEmail, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(layout.createParallelGroup(Alignment.BASELINE)
                    .addComponent(labelJenisKelamin, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(radioPria).addComponent(radioWanita))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(layout.createParallelGroup(Alignment.LEADING)
                    .addComponent(labelPhoto, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(imageChooser, GroupLayout.PREFERRED_SIZE, 189, GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createParallelGroup(Alignment.BASELINE)
                    .addComponent(buttonBatal, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(buttonTambah, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE))
            .addContainerGap()));
}

From source file:org.jdal.vaadin.ui.FormUtils.java

/**
 * Create a new DateField with format for current locale and given style.
 * @param style DateFormat style/*from   w ww  . j  a v a 2 s  .c o m*/
 * @return a new DateField
 */
public static DateField newDateField(int style) {
    DateField df = new DateField();
    Locale locale = LocaleContextHolder.getLocale();
    df.setLocale(locale);
    DateFormat dateFormat = DateFormat.getDateInstance(style);

    if (dateFormat instanceof SimpleDateFormat) {
        SimpleDateFormat sdf = (SimpleDateFormat) dateFormat;
        df.setDateFormat(sdf.toPattern());
    }

    return df;
}

From source file:hornet.framework.export.fdf.FDF.java

/**
 * Fusion d'un champ FDF./*  w  ww .ja  v  a 2  s  . com*/
 *
 * @param data
 *            the data
 * @param stamper
 *            the stamper
 * @param res
 *            the res
 * @param form
 *            the form
 * @param nomField
 *            the nom field
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 * @throws DocumentException
 *             the document exception
 */
private static void fusionChamp(final Object data, final PdfStamper stamper, final FDFRes res,
        final AcroFields form, final Object nomField) throws IOException, DocumentException {

    // utilisation du ":" comme sparateur d'accs.
    // le "." tant remplac par "_" par openoffice lors
    // de la conversion PDF.
    final String nomFieldStr = nomField.toString().replace(':', '.');

    Object value = null;
    try {
        value = PropertyUtils.getProperty(data, nomFieldStr);
    } catch (final Exception ex) {
        res.getUnmerged().add(nomFieldStr);
    }

    String valueStr;

    if (value == null) {
        valueStr = ""; // itext n'accepte pas les valeurs
        // nulles
        form.setField(nomField.toString(), valueStr);
    } else if (value instanceof FDFImage) {
        final FDFImage imValue = (FDFImage) value;
        final float[] positions = form.getFieldPositions(nomField.toString());
        final PdfContentByte content = stamper.getOverContent(1);
        final Image im = Image.getInstance(imValue.getData());
        if (imValue.isFit()) {
            content.addImage(im,
                    positions[FieldBoxPositions.URX.ordinal()] - positions[FieldBoxPositions.LLX.ordinal()], 0,
                    0, positions[FieldBoxPositions.URY.ordinal()] - positions[FieldBoxPositions.LLY.ordinal()],
                    positions[FieldBoxPositions.LLX.ordinal()], positions[FieldBoxPositions.LLY.ordinal()]);
        } else {
            content.addImage(im, im.getWidth(), 0, 0, im.getHeight(), positions[1], positions[2]);
        }
    } else if (value instanceof Date) {
        // format par dfaut date
        valueStr = DateFormat.getDateInstance(DateFormat.SHORT).format(value);
        form.setField(nomField.toString(), valueStr);
    } else if (value instanceof Boolean) {
        // format par spcial pour Checkbox
        if (Boolean.TRUE.equals(value)) {
            valueStr = "Yes";
        } else {
            valueStr = "No";
        }
        form.setField(nomField.toString(), valueStr);
    } else {
        // format par dfaut
        valueStr = value.toString();
        form.setField(nomField.toString(), valueStr);
    }
}

From source file:org.ejbca.core.model.hardtoken.profiles.SVGImageManipulator.java

/**
 * Returns the message with userspecific data replaced.
 *
 *
 * @return A processed notification message.
 *     //  w w  w  .j a v a  2  s  .c om
 */
public Printable print(EndEntityInformation userdata, String[] pincodes, String[] pukcodes, String hardtokensn,
        String copyoftokensn) throws IOException, PrinterException {
    // Initialize
    DNFieldExtractor dnfields = new DNFieldExtractor(userdata.getDN(), DNFieldExtractor.TYPE_SUBJECTDN);
    // DNFieldExtractor subaltnamefields = new DNFieldExtractor(dn,DNFieldExtractor.TYPE_SUBJECTALTNAME);
    Date currenttime = new Date();
    String startdate = DateFormat.getDateInstance(DateFormat.SHORT).format(currenttime);

    String enddate = DateFormat.getDateInstance(DateFormat.SHORT)
            .format(new Date(currenttime.getTime() + (this.validityms)));
    String hardtokensnwithoutprefix = hardtokensn.substring(this.hardtokensnprefix.length());
    String copyoftokensnwithoutprefix = copyoftokensn.substring(this.hardtokensnprefix.length());

    final SVGOMDocument clone = (SVGOMDocument) svgdoc.cloneNode(true);
    // Get Text rows
    process("text", userdata, dnfields, pincodes, pukcodes, hardtokensn, hardtokensnwithoutprefix,
            copyoftokensn, copyoftokensnwithoutprefix, startdate, enddate, clone);
    process("svg:text", userdata, dnfields, pincodes, pukcodes, hardtokensn, hardtokensnwithoutprefix,
            copyoftokensn, copyoftokensnwithoutprefix, startdate, enddate, clone);

    // Add Image
    /**
    if(userdata.hasimage()){
      addImage(userdata);       
    } 
     */
    insertImage(userdata, clone); // special dravel for demo

    PrintTranscoder t = new PrintTranscoder();
    TranscoderInput input = new TranscoderInput(clone);
    TranscoderOutput output = new TranscoderOutput(new ByteArrayOutputStream());
    t.transcode(input, output);
    {
        final String aDoNot = clone.getRootElement().getAttribute("doNotScaleToPage");
        t.addTranscodingHint(PrintTranscoder.KEY_SCALE_TO_PAGE,
                Boolean.valueOf(aDoNot == null || aDoNot.trim().length() <= 0));
    }
    return t;
}

From source file:gob.dp.simco.intervencion.controller.IntervencionController.java

public boolean initJasper() throws JRException {
    List<ReportPlanIntervencionVO> lista = new ArrayList<>();
    ReportPlanIntervencionVO vo = new ReportPlanIntervencionVO();
    vo.setDescripcion(intervencion.getDescripcion());
    vo.setNombre(intervencion.getNombre());
    DateFormat df2 = DateFormat.getDateInstance(DateFormat.MEDIUM);
    DateFormat df4 = DateFormat.getDateInstance(DateFormat.FULL);
    if (intervencion.getId() != null) {
        List<IntervencionEtapa> etapasTotales = intervencionEtapaService
                .intervencionEtapaxIntervencion(intervencion.getId());
        for (IntervencionEtapa ei : etapasTotales) {
            List<IntervencionEtapaActuacion> listiea = intervencionEtapaActuacionService
                    .intervencionEtapaActuacionBuscarActividadGSA(ei.getId());
            ei.setIeas(listiea);//w  w  w. j  a v  a 2  s  .  c om
        }
        vo.setEtapasTotales(etapasTotales);

        List<IntervencionAccion> accionesSeleccionadas = intervencionAccionService
                .intervencionAccionBuscarxIntervencion(intervencion.getId());
        int j = 0;
        for (IntervencionAccion ia : accionesSeleccionadas) {
            j = ++j;
            ia.setNumero("3." + j + " Campo de accion " + j + ":");
            ia.setEtapas(intervencionEtapaService.intervencionEtapaxAccion(ia.getId()));
            int k = 0;
            for (IntervencionEtapa ie : ia.getEtapas()) {
                k = ++k;
                ie.setNumero1("3." + j + "." + k);
                String s4 = "";
                if (ie.getFechaLimite() != null) {
                    s4 = df4.format(ie.getFechaLimite());
                }
                if (ie.getDescripcion() == null) {
                    ie.setDescripcion("");
                }
                ie.setFechaLimiteString(s4);
                ie.setNumero2(ie.getNumero1() + ".1");
                ie.setNumero3(ie.getNumero1() + ".2");
                ie.setIeas(intervencionEtapaActuacionService
                        .intervencionEtapaActuacionBuscarActividad(ie.getId()));
                for (IntervencionEtapaActuacion etapaActuacion : ie.getIeas()) {
                    if (etapaActuacion.getActividadId() != null) {
                        etapaActuacion.setDetalleReporte(etapaActuacion.getDescripcion() + " (realizada el "
                                + df2.format(etapaActuacion.getFechaCulminacion()) + " - "
                                + etapaActuacion.getCodigoActividad() + " \" "
                                + etapaActuacion.getNombreActividad() + " \")");
                    } else {
                        etapaActuacion.setDetalleReporte(etapaActuacion.getDescripcion());
                    }
                }
                Integer porcentaje = defineAvanceReport(ie.getIeas());
                ie.setAvanceString("Actuaciones defensoriales planificadas(" + porcentaje + "% de avance)");
                String estadoReporte = "";
                if (porcentaje == 0) {
                    estadoReporte = "Planificado";
                }
                if (porcentaje < 100 && porcentaje > 0) {
                    estadoReporte = "En Ejecucion";
                }
                if (porcentaje == 100) {
                    estadoReporte = "Ejecutado";
                }
                ie.setDetalle(ie.getDetalle() + "(" + estadoReporte + ")");

                List<IntervencionMiembro> miembros = intervencionMiembroService
                        .intervencionMiembroBuscar(ie.getId());
                ie.setIms(miembros);
            }
        }

        vo.setAccionesSeleccionadas(accionesSeleccionadas);

        vo.setEtapas(listPlanificado);
        List<IntervencionAccion> ias = new ArrayList<>();
        int i = 0;
        for (IntervencionAccion ia : accions) {
            i++;
            ia.setNumero("2." + i);
            ias.add(ia);
        }
        vo.setAcciones(ias);
        vo.setImagePath(ConstantesUtil.BASE_URL_IMAGEPATH + "logoPlanIntervencion.png");

        lista.add(vo);

        JRBeanCollectionDataSource beanCollectionDataSource = new JRBeanCollectionDataSource(lista);
        jasperPrint = JasperFillManager.fillReport(ConstantesUtil.BASE_URL_REPORT + "planIntervencion.jasper",
                new HashMap(), beanCollectionDataSource);
        return true;
    } else {
        msg.messageAlert("No existe un plan de intervencion para este caso", null);
        return false;
    }
}