use of javax.swing.DefaultListCellRenderer in project triplea by triplea-game.
the class SelectionComponentFactory method selectionBox.
static <T> Supplier<SelectionComponent<JComponent>> selectionBox(final ClientSetting clientSetting, final List<T> availableOptions, final T selectedOption, final Function<T, ?> renderFunction) {
return () -> new AlwaysValidInputSelectionComponent() {
final JComboBox<T> comboBox = getCombobox();
private JComboBox<T> getCombobox() {
final JComboBox<T> comboBox = new JComboBox<>();
availableOptions.forEach(comboBox::addItem);
comboBox.setSelectedItem(selectedOption);
comboBox.setRenderer(new DefaultListCellRenderer() {
private static final long serialVersionUID = -3094995494539073655L;
@Override
@SuppressWarnings("unchecked")
public Component getListCellRendererComponent(final JList<?> list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) {
return super.getListCellRendererComponent(list, renderFunction.apply((T) value), index, isSelected, cellHasFocus);
}
});
return comboBox;
}
@Override
public JComponent getUiComponent() {
comboBox.setSelectedItem(clientSetting.value());
return comboBox;
}
@Override
public Map<GameSetting, String> readValues() {
final String value = String.valueOf(comboBox.getSelectedItem());
final Map<GameSetting, String> settingMap = new HashMap<>();
settingMap.put(clientSetting, value);
return settingMap;
}
@Override
public void resetToDefault() {
comboBox.setSelectedItem(clientSetting.defaultValue);
clearError();
}
@Override
public void reset() {
comboBox.setSelectedItem(clientSetting.value());
clearError();
}
};
}
use of javax.swing.DefaultListCellRenderer in project triplea by triplea-game.
the class ChatPlayerPanel method createComponents.
private void createComponents() {
listModel = new DefaultListModel<>();
players = new JList<>(listModel);
players.setFocusable(false);
players.setCellRenderer((list, node, index, isSelected, cellHasFocus) -> {
if (setCellRenderer == null) {
return new JLabel();
}
final DefaultListCellRenderer renderer;
if (setCellRenderer instanceof PlayerChatRenderer) {
renderer = (DefaultListCellRenderer) setCellRenderer.getListCellRendererComponent(list, node, index, isSelected, cellHasFocus);
} else {
renderer = (DefaultListCellRenderer) setCellRenderer.getListCellRendererComponent(list, getDisplayString(node), index, isSelected, cellHasFocus);
}
if (chat.isIgnored(node)) {
renderer.setIcon(ignoreIcon);
}
return renderer;
});
}
use of javax.swing.DefaultListCellRenderer in project gate-core by GateNLP.
the class AnnotationDiffGUI method initGUI.
protected void initGUI() {
getContentPane().setLayout(new GridBagLayout());
GridBagConstraints constraints = new GridBagConstraints();
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.anchor = GridBagConstraints.WEST;
constraints.insets = new Insets(2, 2, 2, 2);
constraints.weightx = 1;
/**
*****************************************
* First row - Settings and 'Compare' button *
******************************************
*/
constraints.gridy = 0;
JLabel keyDocLabel = new JLabel("Key doc:");
keyDocLabel.setToolTipText("Key document");
getContentPane().add(keyDocLabel, constraints);
keyDocCombo = new JComboBox<String>();
keyDocCombo.setPrototypeDisplayValue("long_document_name");
// add the value of the combobox in a tooltip for long value
keyDocCombo.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value != null) {
Rectangle textRectangle = new Rectangle(keyDocCombo.getSize().width, getPreferredSize().height);
String shortText = SwingUtilities.layoutCompoundLabel(this, getFontMetrics(getFont()), value.toString(), null, getVerticalAlignment(), getHorizontalAlignment(), getHorizontalTextPosition(), getVerticalTextPosition(), textRectangle, new Rectangle(), textRectangle, getIconTextGap());
if (shortText.equals(value)) {
// no tooltip
if (index == -1) {
keyDocCombo.setToolTipText(null);
} else {
setToolTipText(null);
}
} else {
// add tooltip because text is shortened
if (index == -1) {
keyDocCombo.setToolTipText(value.toString());
} else {
setToolTipText(value.toString());
}
}
}
return this;
}
});
constraints.weightx = 3;
getContentPane().add(keyDocCombo, constraints);
constraints.weightx = 1;
JLabel keySetLabel = new JLabel("Key set:");
keySetLabel.setToolTipText("Key annotation set");
getContentPane().add(keySetLabel, constraints);
keySetCombo = new JComboBox<String>();
keySetCombo.setPrototypeDisplayValue("long_set_name");
getContentPane().add(keySetCombo, constraints);
JLabel typeLabel = new JLabel("Type:");
typeLabel.setToolTipText("Annotation type");
getContentPane().add(typeLabel, constraints);
annTypeCombo = new JComboBox<String>();
annTypeCombo.setPrototypeDisplayValue("very_long_type");
constraints.gridwidth = 3;
getContentPane().add(annTypeCombo, constraints);
constraints.gridwidth = 1;
JLabel weightLabel = new JLabel("Weight");
weightLabel.setToolTipText("F-measure weight");
getContentPane().add(weightLabel, constraints);
diffAction = new DiffAction();
diffAction.setEnabled(false);
doDiffBtn = new JButton(diffAction);
doDiffBtn.setDisabledIcon(new RunIcon(MainFrame.ICON_DIMENSION, true));
doDiffBtn.setForeground((Color) UIManager.getDefaults().get("Button.disabledText"));
doDiffBtn.setToolTipText("Choose two annotation sets " + "that have at least one annotation type in common.");
constraints.gridheight = 2;
getContentPane().add(doDiffBtn, constraints);
constraints.gridheight = 1;
/**
***********************
* Second row - Settings *
************************
*/
constraints.gridy++;
constraints.gridx = 0;
JLabel responseDocLabel = new JLabel("Resp. doc:");
responseDocLabel.setToolTipText("Response document");
getContentPane().add(responseDocLabel, constraints);
constraints.gridx = GridBagConstraints.RELATIVE;
resDocCombo = new JComboBox<String>();
resDocCombo.setPrototypeDisplayValue("long_document_name");
resDocCombo.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value != null) {
Rectangle textRectangle = new Rectangle(resDocCombo.getSize().width, getPreferredSize().height);
String shortText = SwingUtilities.layoutCompoundLabel(this, getFontMetrics(getFont()), value.toString(), null, getVerticalAlignment(), getHorizontalAlignment(), getHorizontalTextPosition(), getVerticalTextPosition(), textRectangle, new Rectangle(), textRectangle, getIconTextGap());
if (shortText.equals(value)) {
// no tooltip
if (index == -1) {
resDocCombo.setToolTipText(null);
} else {
setToolTipText(null);
}
} else {
// add tooltip because text is shortened
if (index == -1) {
resDocCombo.setToolTipText(value.toString());
} else {
setToolTipText(value.toString());
}
}
}
return this;
}
});
constraints.weightx = 3;
getContentPane().add(resDocCombo, constraints);
constraints.weightx = 1;
JLabel responseSetLabel = new JLabel("Resp. set:");
responseSetLabel.setToolTipText("Response annotation set");
getContentPane().add(responseSetLabel, constraints);
resSetCombo = new JComboBox<String>();
resSetCombo.setPrototypeDisplayValue("long_set_name");
getContentPane().add(resSetCombo, constraints);
getContentPane().add(new JLabel("Features:"), constraints);
ButtonGroup btnGrp = new ButtonGroup();
allFeaturesBtn = new JRadioButton("all");
allFeaturesBtn.setOpaque(false);
allFeaturesBtn.setMargin(new Insets(0, 0, 0, 1));
allFeaturesBtn.setIconTextGap(1);
btnGrp.add(allFeaturesBtn);
constraints.insets = new Insets(0, 0, 0, 0);
getContentPane().add(allFeaturesBtn, constraints);
someFeaturesBtn = new JRadioButton("some");
someFeaturesBtn.setOpaque(false);
someFeaturesBtn.setMargin(new Insets(0, 0, 0, 1));
someFeaturesBtn.setIconTextGap(1);
btnGrp.add(someFeaturesBtn);
getContentPane().add(someFeaturesBtn, constraints);
noFeaturesBtn = new JRadioButton("none");
noFeaturesBtn.setOpaque(false);
noFeaturesBtn.setMargin(new Insets(0, 0, 0, 1));
noFeaturesBtn.setIconTextGap(1);
btnGrp.add(noFeaturesBtn);
getContentPane().add(noFeaturesBtn, constraints);
constraints.insets = new Insets(2, 2, 2, 2);
noFeaturesBtn.setSelected(true);
weightTxt = new JTextField("1.0");
weightTxt.setToolTipText("<html>Relative weight of precision and recall aka beta." + "<ul><li>1 weights equally precision and recall" + "<li>0.5 weights precision twice as much as recall" + "<li>2 weights recall twice as much as precision</ul></html>");
constraints.fill = GridBagConstraints.HORIZONTAL;
getContentPane().add(weightTxt, constraints);
constraints.fill = GridBagConstraints.NONE;
/**
******************************
* Third row - Comparison table *
*******************************
*/
constraints.gridy++;
constraints.gridx = 0;
diffTableModel = new DiffTableModel();
diffTable = new XJTable(diffTableModel);
diffTable.setDefaultRenderer(String.class, new DiffTableCellRenderer());
diffTable.setDefaultRenderer(Boolean.class, new DiffTableCellRenderer());
diffTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
diffTable.setComparator(DiffTableModel.COL_MATCH, new Comparator<String>() {
@Override
public int compare(String label1, String label2) {
int match1 = 0;
while (!label1.equals(matchLabel[match1])) match1++;
int match2 = 0;
while (!label2.equals(matchLabel[match2])) match2++;
return match1 - match2;
}
});
diffTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
diffTable.setRowSelectionAllowed(true);
diffTable.setColumnSelectionAllowed(true);
diffTable.setEnableHidingColumns(true);
diffTable.hideColumn(DiffTableModel.COL_KEY_COPY);
diffTable.hideColumn(DiffTableModel.COL_RES_COPY);
Comparator<String> startEndComparator = new Comparator<String>() {
@Override
public int compare(String no1, String no2) {
if (no1.trim().equals("") && no2.trim().equals("")) {
return 0;
} else if (no1.trim().equals("")) {
return -1;
} else if (no2.trim().equals("")) {
return 1;
}
int n1 = Integer.parseInt(no1);
int n2 = Integer.parseInt(no2);
if (n1 == n2)
return 0;
else if (n1 > n2)
return 1;
else
return -1;
}
};
diffTable.setComparator(DiffTableModel.COL_KEY_START, startEndComparator);
diffTable.setComparator(DiffTableModel.COL_KEY_END, startEndComparator);
diffTable.setComparator(DiffTableModel.COL_RES_START, startEndComparator);
diffTable.setComparator(DiffTableModel.COL_RES_END, startEndComparator);
diffTable.setSortable(true);
diffTable.setSortedColumn(DiffTableModel.COL_MATCH);
diffTable.setAscending(true);
scroller = new JScrollPane(diffTable);
constraints.gridwidth = GridBagConstraints.REMAINDER;
constraints.weightx = 1;
constraints.weighty = 1;
constraints.fill = GridBagConstraints.BOTH;
getContentPane().add(scroller, constraints);
constraints.gridwidth = 1;
constraints.weightx = 0;
constraints.weighty = 0;
constraints.fill = GridBagConstraints.NONE;
/**
***********************************************
* Fourth row - Tabbed panes, status and buttons *
************************************************
*/
bottomTabbedPane = new JTabbedPane(JTabbedPane.BOTTOM, JTabbedPane.WRAP_TAB_LAYOUT);
// statistics pane will be added to the bottom tabbed pane
statisticsPane = new JPanel(new GridBagLayout());
GridBagConstraints constraints2 = new GridBagConstraints();
constraints2.insets = new Insets(2, 2, 2, 2);
// first column
constraints2.gridx = 0;
constraints2.anchor = GridBagConstraints.WEST;
JLabel lbl = new JLabel("Correct:");
lbl.setToolTipText("Correct:");
lbl.setBackground(diffTable.getBackground());
statisticsPane.add(lbl, constraints2);
lbl = new JLabel("Partially correct:");
lbl.setToolTipText("Partially correct:");
lbl.setBackground(PARTIALLY_CORRECT_BG);
lbl.setOpaque(true);
statisticsPane.add(lbl, constraints2);
lbl = new JLabel("Missing:");
lbl.setToolTipText("Missing:");
lbl.setBackground(MISSING_BG);
lbl.setOpaque(true);
statisticsPane.add(lbl, constraints2);
lbl = new JLabel("False positives:");
lbl.setToolTipText("False positives:");
lbl.setBackground(FALSE_POSITIVE_BG);
lbl.setOpaque(true);
statisticsPane.add(lbl, constraints2);
// second column
constraints2.gridx++;
correctLbl = new JLabel("0");
statisticsPane.add(correctLbl, constraints2);
partiallyCorrectLbl = new JLabel("0");
statisticsPane.add(partiallyCorrectLbl, constraints2);
missingLbl = new JLabel("0");
statisticsPane.add(missingLbl, constraints2);
falsePozLbl = new JLabel("0");
statisticsPane.add(falsePozLbl, constraints2);
// third column
constraints2.gridx++;
constraints2.insets = new Insets(4, 30, 4, 4);
statisticsPane.add(Box.createGlue());
lbl = new JLabel("Strict:");
statisticsPane.add(lbl, constraints2);
lbl = new JLabel("Lenient:");
statisticsPane.add(lbl, constraints2);
lbl = new JLabel("Average:");
statisticsPane.add(lbl, constraints2);
// fourth column
constraints2.gridx++;
constraints2.insets = new Insets(4, 4, 4, 4);
lbl = new JLabel("Recall");
statisticsPane.add(lbl, constraints2);
recallStrictLbl = new JLabel("0.00");
statisticsPane.add(recallStrictLbl, constraints2);
recallLenientLbl = new JLabel("0.00");
statisticsPane.add(recallLenientLbl, constraints2);
recallAveLbl = new JLabel("0.00");
statisticsPane.add(recallAveLbl, constraints2);
// fifth column
constraints2.gridx++;
lbl = new JLabel("Precision");
statisticsPane.add(lbl, constraints2);
precisionStrictLbl = new JLabel("0.00");
statisticsPane.add(precisionStrictLbl, constraints2);
precisionLenientLbl = new JLabel("0.00");
statisticsPane.add(precisionLenientLbl, constraints2);
precisionAveLbl = new JLabel("0.00");
statisticsPane.add(precisionAveLbl, constraints2);
// sixth column
constraints2.gridx++;
lbl = new JLabel("F-measure");
lbl.setToolTipText("<html>F-measure =<br>" + " ((weight² + 1) * precision * recall)<br>" + " / (weight² * precision + recall))</html>");
statisticsPane.add(lbl, constraints2);
fmeasureStrictLbl = new JLabel("0.00");
statisticsPane.add(fmeasureStrictLbl, constraints2);
fmeasureLenientLbl = new JLabel("0.00");
statisticsPane.add(fmeasureLenientLbl, constraints2);
fmeasureAveLbl = new JLabel("0.00");
statisticsPane.add(fmeasureAveLbl, constraints2);
bottomTabbedPane.add("Statistics", statisticsPane);
// adjudication pane will be added to the bottom tabbed pane
JPanel adjudicationPane = new JPanel(new GridBagLayout());
constraints2 = new GridBagConstraints();
constraints2.insets = new Insets(2, 2, 2, 2);
// first row
constraints2.gridy = 0;
adjudicationPane.add(new JLabel("Target set:"), constraints2);
consensusASTextField = new JTextField("consensus", 15);
consensusASTextField.setToolTipText("Annotation set name where to copy the selected annotations");
adjudicationPane.add(consensusASTextField, constraints2);
// second row
constraints2.gridy++;
constraints2.gridx = 0;
copyToTargetSetAction = new CopyToTargetSetAction();
copyToTargetSetAction.setEnabled(false);
copyToConsensusBtn = new JButton(copyToTargetSetAction);
copyToConsensusBtn.setDisabledIcon(new RightArrowIcon(MainFrame.ICON_DIMENSION, true));
constraints2.gridwidth = 2;
adjudicationPane.add(copyToConsensusBtn, constraints2);
bottomTabbedPane.add("Adjudication", adjudicationPane);
JPanel bottomPanel = new JPanel(new GridBagLayout());
constraints2 = new GridBagConstraints();
constraints2.insets = new Insets(2, 2, 2, 2);
// add the bottom tabbed pane to the bottom panel
constraints2.gridx = 0;
constraints2.gridy = 0;
constraints2.gridheight = 3;
constraints2.anchor = GridBagConstraints.WEST;
bottomPanel.add(bottomTabbedPane, constraints2);
constraints2.gridheight = 1;
// status bar
constraints2.gridx++;
statusLabel = new JLabel();
statusLabel.setBackground(diffTable.getBackground());
constraints2.insets = new Insets(2, 6, 6, 2);
bottomPanel.add(statusLabel, constraints2);
// toolbar
JToolBar toolbar = new JToolBar();
toolbar.setFloatable(false);
if (!isStandalone) {
showDocumentAction = new ShowDocumentAction();
showDocumentAction.setEnabled(false);
showDocumentBtn = new JButton(showDocumentAction);
showDocumentBtn.setDisabledIcon(new DocumentIcon(MainFrame.ICON_DIMENSION, true));
showDocumentBtn.setToolTipText("Use first the \"Compare\"" + " button then select an annotation in the table.");
toolbar.add(showDocumentBtn);
}
htmlExportAction = new HTMLExportAction();
htmlExportAction.setEnabled(false);
htmlExportBtn = new JButton(htmlExportAction);
htmlExportBtn.setDisabledIcon(new DownIcon(MainFrame.ICON_DIMENSION, true));
htmlExportBtn.setToolTipText("Use first the \"Compare\" button.");
toolbar.add(htmlExportBtn);
if (!isStandalone) {
toolbar.add(new HelpAction());
}
constraints2.gridy++;
constraints2.fill = GridBagConstraints.NONE;
constraints2.anchor = GridBagConstraints.NORTHWEST;
bottomPanel.add(toolbar, constraints2);
// progress bar
progressBar = new JProgressBar();
progressBar.setMinimumSize(new Dimension(5, 5));
progressBar.setBackground(diffTable.getBackground());
progressBar.setOpaque(true);
constraints2.gridy++;
constraints2.anchor = GridBagConstraints.SOUTHWEST;
bottomPanel.add(progressBar, constraints2);
// add the bottom panel to the fourth row
constraints.gridy++;
constraints.gridx = 0;
constraints.gridwidth = GridBagConstraints.REMAINDER;
constraints.gridheight = GridBagConstraints.REMAINDER;
constraints.anchor = GridBagConstraints.WEST;
constraints.insets = new Insets(0, 0, 0, 0);
getContentPane().add(bottomPanel, constraints);
constraints.insets = new Insets(2, 2, 2, 2);
// set the background colour
Color background = diffTable.getBackground();
getContentPane().setBackground(background);
scroller.setBackground(background);
scroller.getViewport().setBackground(background);
statisticsPane.setBackground(background);
adjudicationPane.setBackground(background);
bottomPanel.setBackground(background);
bottomTabbedPane.setBackground(background);
featureslistModel = new DefaultListModel<String>();
featuresList = new JList<String>(featureslistModel);
featuresList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
keySetCombo.requestFocusInWindow();
}
use of javax.swing.DefaultListCellRenderer in project lar_361 by comitsrl.
the class PosPayment method init.
private void init() {
Font font = AdempierePLAF.getFont_Field().deriveFont(18f);
// North
CPanel mainPanel = new CPanel(new MigLayout("hidemode 3", "[100:100:300, trailing]20[200:200:300,grow, trailing]"));
getContentPane().add(mainPanel);
mainPanel.setBorder(new TitledBorder(Msg.translate(p_ctx, "Payment")));
CLabel gtLabel = new CLabel(Msg.translate(p_ctx, "GrandTotal"));
mainPanel.add(gtLabel, "growx");
mainPanel.add(fTotal, "wrap, growx");
fTotal.setEditable(false);
fTotal.setFont(font);
fTotal.setHorizontalAlignment(JTextField.TRAILING);
mainPanel.add(new CLabel(Msg.translate(p_ctx, "Balance")), "growx");
mainPanel.add(fBalance, "wrap, growx");
fBalance.setEditable(false);
fBalance.setFont(font);
fBalance.setHorizontalAlignment(JTextField.TRAILING);
mainPanel.add(new CLabel(Msg.translate(p_ctx, "TenderType"), "growx"));
// Payment type selection
// C_Payment_v.TenderType
int AD_Column_ID = 8416;
MLookup lookup = MLookupFactory.get(Env.getCtx(), 0, 0, AD_Column_ID, DisplayType.List);
ArrayList<Object> types = lookup.getData(true, false, true, true);
DefaultComboBoxModel typeModel = new DefaultComboBoxModel(types.toArray());
tenderTypePick.setModel(typeModel);
// default to cash payment
for (Object obj : types) {
if (obj instanceof ValueNamePair) {
ValueNamePair key = (ValueNamePair) obj;
if (key.getID().equals("X")) {
// Cash
tenderTypePick.setSelectedItem(key);
}
if (!"CDKXT".contains(key.getID())) {
tenderTypePick.removeItem(key);
}
if (key.getID().equals("T")) {
// Account
accountKey = key;
}
}
}
tenderTypePick.setFont(font);
tenderTypePick.addActionListener(this);
// red1 for ID purpuse during testing
tenderTypePick.setName("tenderTypePick");
tenderTypePick.setRenderer(new ListCellRenderer() {
protected DefaultListCellRenderer defaultRenderer = new DefaultListCellRenderer();
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
JLabel renderer = (JLabel) defaultRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
renderer.setPreferredSize(new Dimension(50, 50));
renderer.setHorizontalAlignment(JLabel.CENTER);
return renderer;
}
});
mainPanel.add(tenderTypePick, "wrap, h 50!, growx");
/**
* Load Payment Terms
*/
String sql = "SELECT C_PaymentTerm_ID, Name " + " FROM C_PaymentTerm " + " WHERE IsActive='Y' AND AD_Client_ID=? ORDER BY Name";
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, Env.getAD_Client_ID(p_ctx));
rs = pstmt.executeQuery();
while (rs.next()) {
int key = rs.getInt(1);
String name = rs.getString(2);
KeyNamePair pp = new KeyNamePair(key, name);
fCPaymentTerm.addItem(pp);
}
} catch (SQLException e) {
log.log(Level.SEVERE, sql, e);
} finally {
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
fCPaymentTerm.setFont(font);
lCPaymentTerm = new CLabel(Msg.translate(p_ctx, "PaymentTerms"));
mainPanel.add(lCPaymentTerm, "growx");
mainPanel.add(fCPaymentTerm, "wrap, h 50!, growx");
fPayAmt = new PosTextField(Msg.translate(p_ctx, "PayAmt"), p_posPanel, p_pos.getOSNP_KeyLayout_ID(), DisplayType.getNumberFormat(DisplayType.Amount));
lPayAmt = new CLabel(Msg.translate(p_ctx, "PayAmt"));
mainPanel.add(lPayAmt, "growx");
fPayAmt.setFont(font);
fPayAmt.setEditable(false);
fPayAmt.setHorizontalAlignment(JTextField.TRAILING);
fPayAmt.addActionListener(this);
mainPanel.add(fPayAmt, "wrap, growx");
fTenderAmt = new PosTextField(Msg.translate(p_ctx, "AmountTendered"), p_posPanel, p_pos.getOSNP_KeyLayout_ID(), DisplayType.getNumberFormat(DisplayType.Amount));
lTenderAmt = new CLabel(Msg.translate(p_ctx, "AmountTendered"));
mainPanel.add(lTenderAmt, "growx");
fTenderAmt.addActionListener(this);
fTenderAmt.setFont(font);
fTenderAmt.setHorizontalAlignment(JTextField.TRAILING);
mainPanel.add(fTenderAmt, "wrap, growx");
fReturnAmt = new PosTextField(Msg.translate(p_ctx, "AmountReturned"), p_posPanel, p_pos.getOSNP_KeyLayout_ID(), DisplayType.getNumberFormat(DisplayType.Amount));
lReturnAmt = new CLabel(Msg.translate(p_ctx, "AmountReturned"));
mainPanel.add(lReturnAmt, "growx");
fReturnAmt.setFont(font);
fReturnAmt.setHorizontalAlignment(JTextField.TRAILING);
mainPanel.add(fReturnAmt, "wrap, growx");
fReturnAmt.setEditable(false);
fCheckRouteNo = new PosTextField(Msg.translate(p_ctx, "RoutingNo"), p_posPanel, p_pos.getOSNP_KeyLayout_ID());
lCheckRouteNo = new CLabel(Msg.translate(p_ctx, "RoutingNo"));
mainPanel.add(lCheckRouteNo, "growx");
mainPanel.add(fCheckRouteNo, "wrap, growx");
fCheckRouteNo.setFont(font);
fCheckRouteNo.setHorizontalAlignment(JTextField.TRAILING);
fCheckAccountNo = new PosTextField(Msg.translate(p_ctx, "AccountNo"), p_posPanel, p_pos.getOSNP_KeyLayout_ID(), new DecimalFormat("#"));
lCheckAccountNo = new CLabel(Msg.translate(p_ctx, "AccountNo"));
mainPanel.add(lCheckAccountNo, "growx");
mainPanel.add(fCheckAccountNo, "wrap, growx");
fCheckAccountNo.setFont(font);
fCheckAccountNo.setHorizontalAlignment(JTextField.TRAILING);
fCheckNo = new PosTextField(Msg.translate(p_ctx, "CheckNo"), p_posPanel, p_pos.getOSNP_KeyLayout_ID(), new DecimalFormat("#"));
lCheckNo = new CLabel(Msg.translate(p_ctx, "CheckNo"));
mainPanel.add(lCheckNo, "growx");
mainPanel.add(fCheckNo, "wrap, growx");
fCheckNo.setFont(font);
fCheckNo.setHorizontalAlignment(JTextField.TRAILING);
fCheckAccountName = new PosTextField(Msg.translate(p_ctx, "A_Name"), p_posPanel, p_pos.getOSNP_KeyLayout_ID());
lCheckAccountName = new CLabel(Msg.translate(p_ctx, "A_Name"));
mainPanel.add(lCheckAccountName, "growx");
mainPanel.add(fCheckAccountName, "wrap, growx");
fCheckAccountName.setFont(font);
fCheckAccountName.setHorizontalAlignment(JTextField.TRAILING);
/**
* Load Credit Cards
*/
ValueNamePair[] ccs = p_order.getCreditCards((BigDecimal) fPayAmt.getValue());
// Set Selection
fCCardType = new CComboBox(ccs);
// red1 Id for testing
fCCardType.setName("cardType");
fCCardType.setRenderer(new ListCellRenderer() {
protected DefaultListCellRenderer defaultRenderer = new DefaultListCellRenderer();
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
JLabel renderer = (JLabel) defaultRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
renderer.setPreferredSize(new Dimension(50, 50));
renderer.setHorizontalAlignment(JLabel.CENTER);
return renderer;
}
});
lCCardType = new CLabel(Msg.translate(p_ctx, "CreditCardType"));
mainPanel.add(lCCardType, "growx");
mainPanel.add(fCCardType, "h 50, wrap, growx");
fCCardType.setFont(font);
fCCardNo = new PosTextField(Msg.translate(p_ctx, "CreditCardNumber"), p_posPanel, p_pos.getOSNP_KeyLayout_ID(), new DecimalFormat("#"));
lCCardNo = new CLabel(Msg.translate(p_ctx, "CreditCardNumber"));
fCCardNo.setName("cardNo");
mainPanel.add(lCCardNo, "growx");
mainPanel.add(fCCardNo, "wrap, growx");
fCCardNo.setFont(font);
fCCardNo.setHorizontalAlignment(JTextField.TRAILING);
fCCardName = new PosTextField(Msg.translate(p_ctx, "Name"), p_posPanel, p_pos.getOSK_KeyLayout_ID());
lCCardName = new CLabel(Msg.translate(p_ctx, "Name"));
mainPanel.add(lCCardName, "growx");
mainPanel.add(fCCardName, "wrap, growx");
fCCardName.setFont(font);
fCCardName.setHorizontalAlignment(JTextField.TRAILING);
fCCardMonth = new PosTextField(Msg.translate(p_ctx, "Expires"), p_posPanel, p_pos.getOSNP_KeyLayout_ID());
lCCardMonth = new CLabel(Msg.translate(p_ctx, "Expires"));
fCCardMonth.setName("expiry");
mainPanel.add(lCCardMonth, "growx");
mainPanel.add(fCCardMonth, "wrap, w 75!");
fCCardMonth.setFont(font);
fCCardMonth.setHorizontalAlignment(JTextField.TRAILING);
fCCardVC = new PosTextField(Msg.translate(p_ctx, "CVC"), p_posPanel, p_pos.getOSNP_KeyLayout_ID(), new DecimalFormat("#"));
lCCardVC = new CLabel(Msg.translate(p_ctx, "CVC"));
mainPanel.add(lCCardVC, "growx");
mainPanel.add(fCCardVC, "wrap, w 75!");
fCCardVC.setFont(font);
fCCardVC.setHorizontalAlignment(JTextField.TRAILING);
fPrintShipment.setText("Imprimir Remito");
fPrintShipment.setSelected(true);
mainPanel.add(fPrintShipment, "skip, wrap, growx");
AppsAction actCancel = new AppsAction("Cancel", KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), false);
actCancel.setDelegate(this);
f_bCancel = (CButton) actCancel.getButton();
f_bCancel.setFocusable(false);
mainPanel.add(f_bCancel, "h 50!, w 50!, skip, split 2, trailing");
AppsAction act = new AppsAction("Ok", KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), false);
act.setDelegate(this);
f_bProcess = (CButton) act.getButton();
f_bProcess.setFocusable(false);
mainPanel.add(f_bProcess, "h 50!, w 50!");
pack();
setTotals();
}
Aggregations