Example usage for javax.swing SwingConstants BOTTOM

List of usage examples for javax.swing SwingConstants BOTTOM

Introduction

In this page you can find the example usage for javax.swing SwingConstants BOTTOM.

Prototype

int BOTTOM

To view the source code for javax.swing SwingConstants BOTTOM.

Click Source Link

Document

Box-orientation constant used to specify the bottom of a box.

Usage

From source file:uk.chromis.pos.forms.JRootApp.java

/**
 *
 * @param props//from  ww w  . j  ava 2s .  com
 * @return
 */
public int initApp(AppProperties props) {

    m_props = props;
    m_jPanelDown.setVisible(!AppConfig.getInstance().getBoolean("till.hideinfo"));

    // support for different component orientation languages.
    applyComponentOrientation(ComponentOrientation.getOrientation(Locale.getDefault()));

    // Database start
    int rc = INIT_FAIL_RETRY;
    while (rc == INIT_FAIL_RETRY) {
        rc = INIT_SUCCESS;
        try {
            session = AppViewConnection.createSession(m_props);
        } catch (BasicException e) {
            JOpenWarningDlg wDlg = new JOpenWarningDlg(e.getMessage(),
                    AppLocal.getIntString("message.retryorconfig"), true, true);
            wDlg.setModal(true);
            wDlg.setVisible(true);
            rc = JOpenWarningDlg.CHOICE;
        }
    }

    if (rc != INIT_SUCCESS) {
        return rc;
    }

    m_dlSystem = (DataLogicSystem) getBean("uk.chromis.pos.forms.DataLogicSystem");

    String sDBVersion = readDataBaseVersion();
    if (!AppConfig.getInstance().getBoolean("chromis.tickettype") && sDBVersion != null) {
        UpdateTicketType.updateTicketType();
    }

    if (!AppLocal.APP_VERSION.equals(sDBVersion)) {
        // Lets check if this is a historic version of the jar and it is in the database  
        /*            if (m_dlSystem.checkHistoricVersion(AppLocal.APP_VERSION) != 0) {
        StartupDialog dialog = new StartupDialog();
        JFrame frame = new JFrame("");
        JPanel dialogPanel = new JPanel();
        dialogPanel.add(dialog);
        dialog.jTextArea1.setText("\n Unable to run Chromis. \n \n You are trying to run an incompatible version of Chromis."
                + "\n\n The database found is v" + sDBVersion);
        JOptionPane.showMessageDialog(frame,
                dialogPanel,
                "Incompatible version ",
                JOptionPane.PLAIN_MESSAGE);
        System.exit(1);
                    }
                     */
        if (getDbVersion().equals("x")) {
            JMessageDialog.showMessage(this, new MessageInf(MessageInf.SGN_DANGER,
                    AppLocal.getIntString("message.databasenotsupported", session.DB.getName())));
        } else {
            String changelog = (sDBVersion == null) || ("0.00".equals(sDBVersion))
                    ? "uk/chromis/pos/liquibase/create/chromis.xml"
                    : "uk/chromis/pos/liquibase/upgradeorig/updatesystem.xml";
            JProcessingDlg dlg = new JProcessingDlg(
                    AppLocal.getIntString(
                            sDBVersion == null ? "message.createdatabase" : "message.updatedatabase"),
                    (sDBVersion == null), changelog);
            dlg.setModal(true);
            dlg.setVisible(true);
            if (JProcessingDlg.CHOICE == -1 || JProcessingDlg.DBFAILED) {
                session.close();
                JOpenWarningDlg wDlg;
                if (!"".equals(JProcessingDlg.ERRORMSG)) {
                    wDlg = new JOpenWarningDlg(JProcessingDlg.ERRORMSG,
                            AppLocal.getIntString(
                                    sDBVersion == null ? "message.createfailure" : "message.updatefailure"),
                            false, false);
                    wDlg.setModal(true);
                    wDlg.setVisible(true);
                }
                System.exit(0);
            }
        }
    }

    // Clear the cash drawer table as required, by setting 
    try {
        if ("d".equals(getDbVersion())) {
            SQL = "DELETE FROM DRAWEROPENED WHERE OPENDATE < {fn TIMESTAMPADD(SQL_TSI_DAY ,-"
                    + AppConfig.getInstance().getProperty("dbtable.retaindays") + ", CURRENT_TIMESTAMP)}";
        } else {
            SQL = "DELETE FROM DRAWEROPENED WHERE OPENDATE < (NOW() - INTERVAL '"
                    + AppConfig.getInstance().getProperty("dbtable.retaindays") + "' DAY)";
        }
        stmt.execute(SQL);
    } catch (Exception e) {
    }

    m_propsdb = m_dlSystem.getResourceAsProperties(AppConfig.getInstance().getHost() + "/properties");

    try {
        String sActiveCashIndex = m_propsdb.getProperty("activecash");
        Object[] valcash = sActiveCashIndex == null ? null : m_dlSystem.findActiveCash(sActiveCashIndex);
        if (valcash == null || !AppConfig.getInstance().getHost().equals(valcash[0])) {
            setActiveCash(UUID.randomUUID().toString(),
                    m_dlSystem.getSequenceCash(AppConfig.getInstance().getHost()) + 1, new Date(), null);
            m_dlSystem.execInsertCash(new Object[] { getActiveCashIndex(), AppConfig.getInstance().getHost(),
                    getActiveCashSequence(), getActiveCashDateStart(), getActiveCashDateEnd(), 0 });
        } else {
            setActiveCash(sActiveCashIndex, (Integer) valcash[1], (Date) valcash[2], (Date) valcash[3]);
        }
    } catch (BasicException e) {
        session.close();
        JOpenWarningDlg wDlg = new JOpenWarningDlg(e.getMessage(),
                AppLocal.getIntString("message.retryorconfig"), false, true);
        wDlg.setModal(true);
        wDlg.setVisible(true);
        return JOpenWarningDlg.CHOICE;
    }

    m_sInventoryLocation = m_propsdb.getProperty("location");
    if (m_sInventoryLocation == null) {
        m_sInventoryLocation = "0";
        m_propsdb.setProperty("location", m_sInventoryLocation);
        m_dlSystem.setResourceAsProperties(AppConfig.getInstance().getHost() + "/properties", m_propsdb);
    }

    // setup the display
    m_TP = new DeviceTicket(this, m_props);

    // Inicializamos 
    m_TTP = new TicketParser(getDeviceTicket(), m_dlSystem);

    printerStart();

    // Inicializamos la bascula
    m_Scale = new DeviceScale(this, m_props);

    // Inicializamos la scanpal
    m_Scanner = DeviceScannerFactory.createInstance(m_props);

    new javax.swing.Timer(250, new PrintTimeAction()).start();

    String sWareHouse;

    try {
        sWareHouse = m_dlSystem.findLocationName(m_sInventoryLocation);
    } catch (BasicException e) {
        sWareHouse = null; // no he encontrado el almacen principal
    }

    // Show Hostname, Warehouse and URL in taskbar
    String url;

    try {
        url = session.getURL();
    } catch (SQLException e) {
        url = "";
    }

    m_jHost.setText("<html>" + AppConfig.getInstance().getHost() + " - " + sWareHouse + "<br>" + url);

    // display the new logo if set
    String newLogo = AppConfig.getInstance().getProperty("start.logo");
    if (newLogo != null) {
        if ("".equals(newLogo)) {
            jLabel1.setIcon(
                    new javax.swing.ImageIcon(getClass().getResource("/uk/chromis/fixedimages/chromis.png")));
        } else {
            jLabel1.setIcon(new javax.swing.ImageIcon(newLogo));
        }
    }

    // change text under logo
    String newText = AppConfig.getInstance().getProperty("start.text");
    if (newText != null) {
        if (newText.equals("")) {
            jLabel1.setText("<html><center>Chromis POS - The New Face of Open Source POS<br>"
                    + "Copyright \u00A9 (c) 2015-2016Chromis <br>" + "<br>" + "http://www.chromis.co.uk<br>"
                    + "<br>"
                    + " Chromis POS is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.<br>"
                    + "<br>"
                    + " Chromis POS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.<br>"
                    + "<br>"
                    + "You should have received a copy of the GNU General Public License along with Chromis POS.  If not, see http://www.gnu.org/licenses/<br>"
                    + "</center>");
        } else {
            try {
                String newTextCode = new Scanner(new File(newText), "UTF-8").useDelimiter("\\A").next();
                jLabel1.setText(newTextCode);
            } catch (Exception e) {
            }

            jLabel1.setAlignmentX(0.5F);
            jLabel1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
            jLabel1.setMaximumSize(new java.awt.Dimension(800, 1024));
            jLabel1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        }
    }

    // Lets copy any database specific reports to the reports folder
    // Get the database version first
    File dbReportsSource = null;
    String currentPath = new File("").getAbsolutePath();

    if (OSValidator.isMac()) {
        try {
            currentPath = new File(
                    JRootApp.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath())
                            .toString();
            currentPath = currentPath.replaceAll("/chromispos.jar", "");
        } catch (URISyntaxException ex) {
            currentPath = "/Applications/chromispos";
        }
    } else {
        currentPath = System.getProperty("user.dir");
    }

    switch (getDbVersion()) {
    case "d":
        dbReportsSource = new File(currentPath + "/reports/uk/chromis/derby");
        break;
    case "m":
        dbReportsSource = new File(currentPath + "/reports/uk/chromis/mysql");
        break;
    case "p":
        dbReportsSource = new File(currentPath + "/reports/uk/chromis/postgresql");
        break;
    }

    File reportsDestination = new File(currentPath + "/reports/uk/chromis/reports");

    try {
        File reportsSource = new File(currentPath + "/reports/uk/chromis/default");
        FileUtils.copyDirectory(reportsSource, new File(currentPath + "/reports/uk/chromis/reports"));
        if ((dbReportsSource) != null) {
            FileUtils.copyDirectory(dbReportsSource, new File(currentPath + "/reports/uk/chromis/reports"));
        }
    } catch (IOException ex) {
        Logger.getLogger(JRootApp.class.getName()).log(Level.SEVERE, null, ex);
    }

    showLogin();

    return INIT_SUCCESS;
}

From source file:uk.chromis.pos.forms.JRootApp.java

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

    m_jPanelTitle = new javax.swing.JPanel();
    m_jLblTitle = new javax.swing.JLabel();
    poweredby = new javax.swing.JLabel();
    jLabel2 = new javax.swing.JLabel();
    m_jPanelContainer = new javax.swing.JPanel();
    m_jPanelLogin = new javax.swing.JPanel();
    jPanel4 = new javax.swing.JPanel();
    filler2 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 10),
            new java.awt.Dimension(32767, 0));
    jLabel1 = new javax.swing.JLabel();
    jPanel5 = new javax.swing.JPanel();
    m_jLogonName = new javax.swing.JPanel();
    jPanel2 = new javax.swing.JPanel();
    jPanel8 = new javax.swing.JPanel();
    jScrollPane1 = new javax.swing.JScrollPane();
    jPanel1 = new javax.swing.JPanel();
    m_txtKeys = new javax.swing.JTextField();
    m_jClose = new javax.swing.JButton();
    m_jPanelDown = new javax.swing.JPanel();
    panelTask = new javax.swing.JPanel();
    m_jHost = new javax.swing.JLabel();
    jPanel3 = new javax.swing.JPanel();

    setEnabled(false);
    setPreferredSize(new java.awt.Dimension(1024, 768));
    setLayout(new java.awt.BorderLayout());

    m_jPanelTitle.setBorder(javax.swing.BorderFactory.createMatteBorder(0, 0, 1, 0,
            javax.swing.UIManager.getDefaults().getColor("Button.darkShadow")));
    m_jPanelTitle.setLayout(new java.awt.BorderLayout());

    m_jLblTitle.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
    m_jLblTitle.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    m_jLblTitle.setText("Window.Title");
    m_jPanelTitle.add(m_jLblTitle, java.awt.BorderLayout.CENTER);

    poweredby.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
    poweredby.setIcon(
            new javax.swing.ImageIcon(getClass().getResource("/uk/chromis/fixedimages/poweredby.png"))); // NOI18N
    poweredby.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 5, 0, 5));
    poweredby.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
    poweredby.setMaximumSize(new java.awt.Dimension(222, 34));
    poweredby.setPreferredSize(new java.awt.Dimension(180, 34));
    poweredby.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            poweredbyMouseClicked(evt);
        }
    });
    m_jPanelTitle.add(poweredby, java.awt.BorderLayout.LINE_END);

    jLabel2.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
    jLabel2.setForeground(new java.awt.Color(102, 102, 102));
    jLabel2.setPreferredSize(new java.awt.Dimension(280, 34));
    jLabel2.setRequestFocusEnabled(false);
    m_jPanelTitle.add(jLabel2, java.awt.BorderLayout.LINE_START);

    add(m_jPanelTitle, java.awt.BorderLayout.NORTH);

    m_jPanelContainer.setLayout(new java.awt.CardLayout());

    m_jPanelLogin.setLayout(new java.awt.BorderLayout());

    jPanel4.setMinimumSize(new java.awt.Dimension(518, 177));
    jPanel4.setPreferredSize(new java.awt.Dimension(518, 177));
    jPanel4.setLayout(new javax.swing.BoxLayout(jPanel4, javax.swing.BoxLayout.Y_AXIS));
    jPanel4.add(filler2);

    jLabel1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
    jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uk/chromis/fixedimages/chromis.png"))); // NOI18N
    jLabel1.setText("<html><center>Chromis POS - The New Face of open source POS<br>"
            + "Copyright \u00A9 2015 Chromis <br>" + "http://www.chromis.co.uk<br>" + "<br>"
            + "Chromis POS is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.<br>"
            + "<br>"
            + "Chromis POS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.<br>"
            + "<br>"
            + "You should have received a copy of the GNU General Public License along with Chromis POS.  If not, see http://www.gnu.org/licenses/<br>"
            + "</center>");
    jLabel1.setAlignmentX(0.5F);
    jLabel1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    jLabel1.setMaximumSize(new java.awt.Dimension(800, 1024));
    jLabel1.setMinimumSize(new java.awt.Dimension(518, 177));
    jLabel1.setPreferredSize(new java.awt.Dimension(518, 177));
    jLabel1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    jPanel4.add(jLabel1);

    m_jPanelLogin.add(jPanel4, java.awt.BorderLayout.CENTER);

    jPanel5.setPreferredSize(new java.awt.Dimension(300, 400));

    m_jLogonName.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
    m_jLogonName.setLayout(new java.awt.BorderLayout());

    jPanel2.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 5, 0, 5));
    jPanel2.setPreferredSize(new java.awt.Dimension(100, 100));
    jPanel2.setLayout(new java.awt.BorderLayout());

    jPanel8.setLayout(new java.awt.GridLayout(0, 1, 5, 5));
    jPanel2.add(jPanel8, java.awt.BorderLayout.NORTH);

    m_jLogonName.add(jPanel2, java.awt.BorderLayout.LINE_END);

    jScrollPane1.setBackground(new java.awt.Color(255, 255, 255));
    jScrollPane1.setBorder(null);
    jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    jScrollPane1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N

    m_txtKeys.setPreferredSize(new java.awt.Dimension(0, 0));
    m_txtKeys.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyTyped(java.awt.event.KeyEvent evt) {
            m_txtKeysKeyTyped(evt);
        }
    });

    m_jClose.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
    m_jClose.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uk/chromis/images/exit.png"))); // NOI18N
    m_jClose.setText(AppLocal.getIntString("Button.Close")); // NOI18N
    m_jClose.setFocusPainted(false);
    m_jClose.setFocusable(false);
    m_jClose.setPreferredSize(new java.awt.Dimension(100, 50));
    m_jClose.setRequestFocusEnabled(false);
    m_jClose.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            m_jCloseActionPerformed(evt);
        }
    });

    org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                    .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(m_txtKeys, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(m_jClose, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 289,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addContainerGap(24, Short.MAX_VALUE)));
    jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                    .add(m_txtKeys, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                            org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED,
                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(m_jClose, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                            org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)));

    org.jdesktop.layout.GroupLayout jPanel5Layout = new org.jdesktop.layout.GroupLayout(jPanel5);
    jPanel5.setLayout(jPanel5Layout);
    jPanel5Layout.setHorizontalGroup(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel5Layout.createSequentialGroup().addContainerGap()
                    .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                            .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .add(jScrollPane1))
                    .add(104, 104, 104)
                    .add(m_jLogonName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                            org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(0, 0, Short.MAX_VALUE)));
    jPanel5Layout.setVerticalGroup(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel5Layout.createSequentialGroup().add(15, 15, 15)
                    .add(m_jLogonName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                            org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(434, 565, Short.MAX_VALUE))
            .add(jPanel5Layout.createSequentialGroup().add(jScrollPane1)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                            org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap()));

    m_jPanelLogin.add(jPanel5, java.awt.BorderLayout.EAST);

    m_jPanelContainer.add(m_jPanelLogin, "login");

    add(m_jPanelContainer, java.awt.BorderLayout.CENTER);

    m_jPanelDown.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 0, 0, 0,
            javax.swing.UIManager.getDefaults().getColor("Button.darkShadow")));
    m_jPanelDown.setLayout(new java.awt.BorderLayout());

    m_jHost.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
    m_jHost.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uk/chromis/images/display.png"))); // NOI18N
    m_jHost.setText("*Hostname");
    panelTask.add(m_jHost);

    m_jPanelDown.add(panelTask, java.awt.BorderLayout.LINE_START);
    m_jPanelDown.add(jPanel3, java.awt.BorderLayout.LINE_END);

    add(m_jPanelDown, java.awt.BorderLayout.SOUTH);
}