Example usage for com.jgoodies.forms.layout CellConstraints LEFT

List of usage examples for com.jgoodies.forms.layout CellConstraints LEFT

Introduction

In this page you can find the example usage for com.jgoodies.forms.layout CellConstraints LEFT.

Prototype

Alignment LEFT

To view the source code for com.jgoodies.forms.layout CellConstraints LEFT.

Click Source Link

Document

Put the component in the left.

Usage

From source file:torpedo.SettingsForm.java

public SettingsForm(User user) {
    this.user = user;
    ArrayList result = new ArrayList();
    result = Db.getProfile();/*from   www .java  2s  .co  m*/

    userNameLbl = new JLabel("Felhasznlnv:");
    userName = new JTextField(20);
    nickNameLbl = new JLabel("Becenv:");
    nickName = new JTextField(20);
    countryLbl = new JLabel("Orszg:");
    country = new JComboBox();
    pwdLbl = new JLabel("Jelsz:");
    pwd = new JPasswordField(20);
    confPwdLbl = new JLabel("Jelsz megerstse:");
    confPwd = new JPasswordField(20);
    errorMsgLbl = new JLabel();
    errorMsgLbl.setForeground(Color.red);
    regBtn = new JButton("Regisztrls");
    backBtn = new JButton("<< Vissza");

    for (int i = 0; i < 10; i++) {
        country.addItem(new ComboItem("Visible String " + i, "Value " + i));
    }

    this.frame = frame;
    this.setLayout(new FormLayout("100px, 350px, 200px", "70px, 70px, 70px, 70px, 70px, 70px, 70px"));
    CellConstraints c = new CellConstraints();
    this.add(errorMsgLbl, c.xy(2, 1, CellConstraints.LEFT, CellConstraints.CENTER));
    this.add(userNameLbl, c.xy(2, 2, CellConstraints.LEFT, CellConstraints.CENTER));
    this.add(userName, c.xy(2, 2, CellConstraints.LEFT, CellConstraints.BOTTOM));
    this.add(nickName, c.xy(2, 3, CellConstraints.LEFT, CellConstraints.BOTTOM));
    this.add(nickNameLbl, c.xy(2, 3, CellConstraints.LEFT, CellConstraints.CENTER));
    this.add(country, c.xy(2, 4, CellConstraints.LEFT, CellConstraints.BOTTOM));
    this.add(countryLbl, c.xy(2, 4, CellConstraints.LEFT, CellConstraints.CENTER));
    this.add(pwdLbl, c.xy(2, 5, CellConstraints.LEFT, CellConstraints.CENTER));
    this.add(pwd, c.xy(2, 5, CellConstraints.LEFT, CellConstraints.BOTTOM));
    this.add(confPwdLbl, c.xy(2, 6, CellConstraints.LEFT, CellConstraints.CENTER));
    this.add(confPwd, c.xy(2, 6, CellConstraints.LEFT, CellConstraints.BOTTOM));

    this.add(regBtn, c.xy(2, 7, CellConstraints.RIGHT, CellConstraints.BOTTOM));
    this.add(backBtn, c.xy(2, 7, CellConstraints.LEFT, CellConstraints.BOTTOM));

    int result = JOptionPane.showConfirmDialog(null, this, "Test", JOptionPane.OK_CANCEL_OPTION,
            JOptionPane.PLAIN_MESSAGE);
    if (result == JOptionPane.OK_OPTION) {
        System.out.println("asd");
    } else {
        System.out.println("Cancelled");
    }

    /*regBtn.addMouseListener(new RegEvent(this.frame));
     backBtn.addMouseListener(new MouseAdapter() {
     @Override
     public void mouseClicked(MouseEvent e) {
     frame.showCard("loginForm");
     }
     });*/
}

From source file:tvbrowser.extras.reminderplugin.ReminderFrame.java

License:Open Source License

/**
 * Creates a new instance of ReminderFrame.
 *
 * @param list/*from   w w  w  . j  a v  a2  s  .  c om*/
 *          The list of all reminders.
 * @param reminders
 *          The reminders to show.
 * @param autoCloseSecs
 *          The number seconds to wait before auto-closing the window. -1
 *          disables auto-closing.
 */
public ReminderFrame(final ReminderList list, final AbstractList<ReminderListItem> reminders,
        final int autoCloseSecs) {
    mGlobalReminderList = list;
    mReminderItems = reminders;

    // Check whether we have to use a frame or dialog
    // Workaround: If there is a modal dialog open a frame is not usable. All
    //             user interaction will be ignored.
    //             -> If there is a modal dialog open, we show this reminder as
    //                dialog, otherwise as frame.
    final Window parent = UiUtilities.getLastModalChildOf(MainFrame.getInstance());
    String title = mLocalizer.msg("title", "Reminder");

    // if this is a favorite, change the title to the name of the favorite
    if (reminders.size() == 1) {
        boolean found = false;
        for (Favorite favorite : FavoriteTreeModel.getInstance().getFavoriteArr()) {
            for (Program program : favorite.getPrograms()) {
                if (program.equals(reminders.get(0).getProgram())) {
                    title = favorite.getName();
                    found = true;
                    break;
                }
            }
            if (found) {
                break;
            }
        }
    }

    mDialog = new JDialog(parent, title);
    UiUtilities.registerForClosing(this);

    final JPanel jcontentPane = new JPanel(new BorderLayout(0, 10));
    jcontentPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    mDialog.setContentPane(jcontentPane);

    mLayout = new FormLayout("pref:grow,3dlu,pref", "pref,3dlu");
    final PanelBuilder programsPanel = new PanelBuilder(mLayout);
    CellConstraints cc = new CellConstraints();

    final Date today = Date.getCurrentDate();
    programsPanel.add(mHeader = new JLabel(""), cc.xyw(1, 1, 3));
    programsPanel.setRow(3);
    int remainingMinutesMax = 0;

    ArrayList<ProgramPanel> panels = new ArrayList<ProgramPanel>(reminders.size());

    for (ReminderListItem reminder : reminders) {
        Program program = reminder.getProgram();
        mGlobalReminderList.blockProgram(program);
        // text label
        String msg;
        final int progMinutesAfterMidnight = program.getStartTime();
        int remainingMinutes = 0;
        if (today.compareTo(program.getDate()) >= 0
                && IOUtilities.getMinutesAfterMidnight() > progMinutesAfterMidnight) {
            msg = updateRunningTime();
        } else {
            msg = mLocalizer.msg("soonStarts", "Soon starts");
            remainingMinutes = ReminderPlugin.getTimeToProgramStart(program);
        }
        mHeader.setText(msg);
        remainingMinutesMax = Math.max(remainingMinutesMax, remainingMinutes);

        List<JComponent> componentList = new ArrayList<JComponent>();
        mComponents.put(reminder, componentList);

        final ProgramPanel panel = new ProgramPanel(program,
                new ProgramPanelSettings(
                        new PluginPictureSettings(PluginPictureSettings.ALL_PLUGINS_SETTINGS_TYPE), false,
                        ProgramPanelSettings.X_AXIS));
        componentList.add(panel);
        panels.add(panel);
        panel.setMinimumSize(new Dimension(300, 50));
        panel.setWidth(300);
        // register panel with tooltip manager
        panel.setToolTipText("");
        panel.addPluginContextMenuMouseListener(ReminderPluginProxy.getInstance());

        final JPanel channelPanel = new JPanel(new BorderLayout());
        componentList.add(channelPanel);
        if (program.getLength() > 0) {
            final JLabel endTime = new JLabel(
                    mLocalizer.msg("endTime", "until {0}", program.getEndTimeString()));
            channelPanel.add(endTime, BorderLayout.PAGE_START);
        }
        String channelName = program.getChannel().getName();
        JLabel channelLabel = new JLabel();
        channelLabel.setToolTipText(channelName);
        channelLabel.setIcon(UiUtilities.createChannelIcon(program.getChannel().getIcon()));
        channelLabel.setHorizontalTextPosition(SwingConstants.RIGHT);
        channelPanel.add(channelLabel, BorderLayout.CENTER);
        channelLabel = new JLabel(channelName);
        channelPanel.add(channelLabel, BorderLayout.PAGE_END);

        int layoutStartRow = programsPanel.getRowCount();
        mLayout.appendRow(RowSpec.decode("pref"));
        programsPanel.add(panel, cc.xy(1, programsPanel.getRow(), CellConstraints.FILL, CellConstraints.FILL));
        programsPanel.add(channelPanel,
                cc.xy(3, programsPanel.getRow(), CellConstraints.LEFT, CellConstraints.TOP));
        programsPanel.nextRow();

        String comment = reminder.getComment();
        if (comment != null && comment.length() > 0) {
            mLayout.appendRow(RowSpec.decode("2dlu"));
            mLayout.appendRow(RowSpec.decode("pref"));
            mLayout.appendRow(RowSpec.decode("2dlu"));
            JLabel commentLabel = new JLabel(comment);
            componentList.add(commentLabel);
            programsPanel.add(commentLabel, cc.xyw(1, programsPanel.getRow() + 1, 3));
            programsPanel.nextRow(3);
        }
        int layoutEndRow = programsPanel.getRowCount();
        mPanelRange.put(reminder, new Integer[] { layoutStartRow, layoutEndRow });
    }

    // initialize close button with full text, so it can show the countdown later without size problems
    mRemainingSecs = autoCloseSecs;
    mAutoCloseAtMillis = System.currentTimeMillis() + 1000 * autoCloseSecs;
    final JPanel btnPanel = new JPanel(new BorderLayout(10, 0));
    mCloseBtText = Localizer.getLocalization(Localizer.I18N_CLOSE);
    int seconds = mRemainingSecs;
    if (ReminderPlugin.getInstance().getSettings().getProperty("showTimeCounter", "false")
            .compareTo("true") == 0) {
        seconds = 10;
    }
    mCloseBt = new JButton(getCloseButtonText(seconds));
    mDialog.getRootPane().setDefaultButton(mCloseBt);

    for (ReminderListItem reminder : reminders) {
        if (reminder.getMinutes() < remainingMinutesMax) {
            remainingMinutesMax = reminder.getMinutes();
        }
    }

    mReminderCB = new JComboBox();
    int i = 0;
    while (i < REMIND_VALUE_ARR.length && REMIND_VALUE_ARR[i] < remainingMinutesMax) {
        mReminderCB.addItem(REMIND_MSG_ARR[i]);
        i++;
    }
    // don't show reminder selection if it contains only the
    // entry "don't remind me"
    mReminderCB.setVisible(mReminderCB.getItemCount() > 1);

    btnPanel.add(mReminderCB, BorderLayout.WEST);
    btnPanel.add(mCloseBt, BorderLayout.EAST);

    final JScrollPane scrollPane = new JScrollPane(programsPanel.getPanel());
    scrollPane.setBorder(BorderFactory.createEmptyBorder());
    jcontentPane.add(scrollPane, BorderLayout.CENTER);
    jcontentPane.add(btnPanel, BorderLayout.SOUTH);

    mCloseBt.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            close();
        }
    });

    if (mRemainingSecs > 0) {
        updateCloseBtText();
        mAutoCloseTimer = new Timer(1000, new ActionListener() {
            public void actionPerformed(final ActionEvent evt) {
                handleTimerEvent();
            }
        });
        mAutoCloseTimer.start();
    }

    for (ProgramPanel programPanel : panels) {
        programPanel.setMinimumSize(new Dimension(300, 50));
    }
    mDialog.pack();

    mCloseBt.setText(mCloseBtText);
    mDialog.setAlwaysOnTop(ReminderPlugin.getInstance().getSettings().getProperty("alwaysOnTop", "true")
            .equalsIgnoreCase("true"));

    UiUtilities.centerAndShow(mDialog);
    mDialog.toFront();

    if (mDialog.isAlwaysOnTop()) {
        mDialog.addWindowFocusListener(new WindowFocusListener() {
            public void windowGainedFocus(final WindowEvent e) {
            }

            public void windowLostFocus(final WindowEvent e) {
                mDialog.setAlwaysOnTop(false);
                UiUtilities.getLastModalChildOf(MainFrame.getInstance()).toFront();
            }
        });
    }

    mDialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    mDialog.addWindowListener(new WindowAdapter() {
        public void windowClosing(final WindowEvent e) {
            close();
        }
    });

    for (ReminderListItem reminder : reminders) {
        reminder.getProgram().addChangeListener(this);
    }
}