use of com.jgoodies.forms.builder.DefaultFormBuilder in project jgnash by ccavanaugh.
the class BudgetOverviewPanel method layoutMainPanel.
private void layoutMainPanel() {
ResourceBundle rb = ResourceUtils.getBundle();
initComponents();
FormLayout layout = new FormLayout("2dlu, right:d, $lcgap, max(40dlu;d), $lcgap, d", "min");
DefaultFormBuilder builder = new DefaultFormBuilder(layout, this);
setLayout(layout);
setBorder(Borders.EMPTY);
builder.add(new JLabel(rb.getString("Label.Year")), CC.xy(2, 1));
builder.add(yearSpinner, CC.xy(4, 1));
builder.add(sparkLinePanel, CC.xy(6, 1));
}
use of com.jgoodies.forms.builder.DefaultFormBuilder in project jgnash by ccavanaugh.
the class TransactionNumberDialog method layoutDialog.
private void layoutDialog() {
final FormLayout layout = new FormLayout("p:g", "f:p:g(1.0)");
final DefaultFormBuilder builder = new DefaultFormBuilder(layout);
builder.border(Borders.DIALOG);
builder.append(layoutPanel());
builder.nextLine();
builder.appendUnrelatedComponentsGapRow();
builder.nextLine();
builder.append(StaticUIMethods.buildOKCancelBar(okButton, cancelButton));
getContentPane().add(builder.getPanel(), BorderLayout.CENTER);
pack();
setMinimumSize(getSize());
}
use of com.jgoodies.forms.builder.DefaultFormBuilder in project jgnash by ccavanaugh.
the class AbstractTransactionPanel method buildHorizontalSubPanel.
/**
* A method to help create one row sub panels. This helps to work around
* a layout limitation of components spanning multiple columns.
* If a String is passed as a component, it will be localized and
* converted to a JLabel.
*
* @param columnSpec The column spec for the layout
* @param components The components for the sub-panel
* @return The resulting JPanel
*/
protected JPanel buildHorizontalSubPanel(final String columnSpec, final Object... components) {
FormLayout layout = new FormLayout(columnSpec, "f:d:g");
DefaultFormBuilder builder = new DefaultFormBuilder(layout);
for (Object component1 : components) {
if (component1 instanceof String) {
// add a label
builder.append(new JLabel(rb.getString((String) component1)));
} else {
// add a component
builder.append((Component) component1);
}
}
return builder.getPanel();
}
use of com.jgoodies.forms.builder.DefaultFormBuilder in project jgnash by ccavanaugh.
the class MonthlyAccountBalanceChart method createPanel.
private JPanel createPanel() {
LocalDate end = DateUtils.getLastDayOfTheMonth(endDateField.getLocalDate());
LocalDate start = end.minusYears(1);
startDateField.setDate(start);
JButton refreshButton = new JButton(rb.getString("Button.Refresh"));
refreshButton.setIcon(IconUtils.getIcon("/jgnash/resource/view-refresh.png"));
subAccountCheckBox = new JCheckBox(rb.getString("Button.IncludeSubAccounts"));
subAccountCheckBox.setSelected(true);
hideLockedAccountCheckBox = new JCheckBox(rb.getString("Button.HideLockedAccount"));
hidePlaceholderAccountCheckBox = new JCheckBox(rb.getString("Button.HidePlaceholderAccount"));
Account a = combo.getSelectedAccount();
JFreeChart chart = createVerticalXYBarChart(a);
final ChartPanel chartPanel = new ChartPanel(chart);
FormLayout layout = new FormLayout("p, 4dlu, p:g", "");
DefaultFormBuilder builder = new DefaultFormBuilder(layout);
FormLayout dLayout = new FormLayout("p, 4dlu, p, 8dlu, p, 4dlu, p, 8dlu, p", "");
DefaultFormBuilder dBuilder = new DefaultFormBuilder(dLayout);
dBuilder.append(rb.getString("Label.StartDate"), startDateField);
dBuilder.append(rb.getString("Label.EndDate"), endDateField);
dBuilder.append(refreshButton);
FormLayout cbLayout = new FormLayout("p, 4dlu, p, 4dlu, p, 4dlu", "");
DefaultFormBuilder cbBuilder = new DefaultFormBuilder(cbLayout);
cbBuilder.append(subAccountCheckBox);
cbBuilder.append(hideLockedAccountCheckBox);
cbBuilder.append(hidePlaceholderAccountCheckBox);
builder.append(rb.getString("Label.Account"), combo);
builder.nextLine();
builder.append(" ");
builder.append(cbBuilder.getPanel());
builder.nextLine();
builder.appendRelatedComponentsGapRow();
builder.nextLine();
builder.append(dBuilder.getPanel(), 3);
builder.nextLine();
builder.appendUnrelatedComponentsGapRow();
builder.nextLine();
builder.appendRow(RowSpec.decode("fill:p:g"));
builder.append(chartPanel, 3);
final JPanel panel = builder.getPanel();
ActionListener listener = e -> {
try {
Account account = combo.getSelectedAccount();
if (account == null) {
return;
}
updateSubAccountBox();
chartPanel.setChart(createVerticalXYBarChart(account));
panel.validate();
} catch (final Exception ex) {
Logger.getLogger(MonthlyAccountBalanceChart.class.getName()).log(Level.SEVERE, ex.getLocalizedMessage(), ex);
}
};
combo.addActionListener(listener);
hideLockedAccountCheckBox.addActionListener(e -> {
combo.setHideLocked(hideLockedAccountCheckBox.isSelected());
try {
Account account = combo.getSelectedAccount();
if (account == null) {
return;
}
updateSubAccountBox();
chartPanel.setChart(createVerticalXYBarChart(account));
panel.validate();
} catch (final Exception ex) {
Logger.getLogger(MonthlyAccountBalanceChart.class.getName()).log(Level.SEVERE, ex.getLocalizedMessage(), ex);
}
});
hidePlaceholderAccountCheckBox.addActionListener(e -> {
combo.setHidePlaceholder(hidePlaceholderAccountCheckBox.isSelected());
try {
Account account = combo.getSelectedAccount();
if (account == null) {
return;
}
updateSubAccountBox();
chartPanel.setChart(createVerticalXYBarChart(account));
panel.validate();
} catch (final Exception ex) {
Logger.getLogger(MonthlyAccountBalanceChart.class.getName()).log(Level.SEVERE, ex.getLocalizedMessage(), ex);
}
});
refreshButton.addActionListener(listener);
updateSubAccountBox();
return panel;
}
use of com.jgoodies.forms.builder.DefaultFormBuilder in project jgnash by ccavanaugh.
the class MonthlyAccountBalanceChartCompare method createPanel.
private JPanel createPanel() {
LocalDate end = DateUtils.getLastDayOfTheMonth(endDateField.getLocalDate());
LocalDate start = end.minusYears(1);
startDateField.setDate(start);
JButton refreshButton = new JButton(rb.getString("Button.Refresh"));
refreshButton.setIcon(IconUtils.getIcon("/jgnash/resource/view-refresh.png"));
subAccountCheckBox = new JCheckBox(rb.getString("Button.IncludeSubAccounts"));
subAccountCheckBox.setSelected(true);
hideLockedAccountCheckBox = new JCheckBox(rb.getString("Button.HideLockedAccount"));
hidePlaceholderAccountCheckBox = new JCheckBox(rb.getString("Button.HidePlaceholderAccount"));
jcb_compare = new JCheckBox(rb.getString("Button.Compare"));
jcb_compare.setSelected(true);
Account a = combo1.getSelectedAccount();
Account a2 = combo2.getSelectedAccount();
JFreeChart chart = createVerticalXYBarChart(a, a2);
final ChartPanel chartPanel = new ChartPanel(chart);
FormLayout layout = new FormLayout("p, 4dlu, p:g", "");
DefaultFormBuilder builder = new DefaultFormBuilder(layout);
FormLayout dLayout = new FormLayout("p, 4dlu, p, 8dlu, p, 4dlu, p, 8dlu, p", "");
DefaultFormBuilder dBuilder = new DefaultFormBuilder(dLayout);
dBuilder.append(rb.getString("Label.StartDate"), startDateField);
dBuilder.append(rb.getString("Label.EndDate"), endDateField);
dBuilder.append(refreshButton);
FormLayout cbLayout = new FormLayout("p, 4dlu, p, 4dlu, p, 4dlu", "");
DefaultFormBuilder cbBuilder = new DefaultFormBuilder(cbLayout);
cbBuilder.append(subAccountCheckBox);
cbBuilder.append(hideLockedAccountCheckBox);
cbBuilder.append(hidePlaceholderAccountCheckBox);
builder.append(rb.getString("Label.Account"), combo1);
builder.nextLine();
builder.append(rb.getString("Label.Compare"), combo2);
builder.nextLine();
builder.append(jcb_compare);
builder.append(cbBuilder.getPanel());
builder.nextLine();
builder.appendRelatedComponentsGapRow();
builder.nextLine();
builder.append(dBuilder.getPanel(), 3);
builder.nextLine();
builder.appendUnrelatedComponentsGapRow();
builder.nextLine();
builder.appendRow(RowSpec.decode("fill:p:g"));
builder.append(chartPanel, 3);
final JPanel panel = builder.getPanel();
ActionListener listener = e -> {
try {
if (e.getSource() == jcb_compare) {
combo2.setEnabled(jcb_compare.isSelected());
}
Account account = combo1.getSelectedAccount();
if (account == null) {
return;
}
Account account2 = combo2.getSelectedAccount();
if (jcb_compare.isSelected() && account2 == null) {
return;
}
updateSubAccountBox();
chartPanel.setChart(createVerticalXYBarChart(account, account2));
panel.validate();
} catch (final Exception ex) {
Logger.getLogger(MonthlyAccountBalanceChartCompare.class.getName()).log(Level.SEVERE, ex.getLocalizedMessage(), ex);
}
};
combo1.addActionListener(listener);
combo2.addActionListener(listener);
jcb_compare.addActionListener(listener);
subAccountCheckBox.addActionListener(listener);
hideLockedAccountCheckBox.addActionListener(e -> {
combo1.setHideLocked(hideLockedAccountCheckBox.isSelected());
combo2.setHideLocked(hideLockedAccountCheckBox.isSelected());
try {
Account account = combo1.getSelectedAccount();
if (account == null) {
return;
}
Account account2 = combo2.getSelectedAccount();
if (jcb_compare.isSelected() && account2 == null) {
return;
}
updateSubAccountBox();
chartPanel.setChart(createVerticalXYBarChart(account, account2));
panel.validate();
} catch (final Exception ex) {
Logger.getLogger(MonthlyAccountBalanceChartCompare.class.getName()).log(Level.SEVERE, ex.getLocalizedMessage(), ex);
}
});
hidePlaceholderAccountCheckBox.addActionListener(e -> {
combo1.setHidePlaceholder(hidePlaceholderAccountCheckBox.isSelected());
combo2.setHidePlaceholder(hidePlaceholderAccountCheckBox.isSelected());
try {
Account account = combo1.getSelectedAccount();
if (account == null) {
return;
}
Account account2 = combo2.getSelectedAccount();
if (jcb_compare.isSelected() && account2 == null) {
return;
}
updateSubAccountBox();
chartPanel.setChart(createVerticalXYBarChart(account, account2));
panel.validate();
} catch (final Exception ex) {
Logger.getLogger(MonthlyAccountBalanceChartCompare.class.getName()).log(Level.SEVERE, ex.getLocalizedMessage(), ex);
}
});
refreshButton.addActionListener(listener);
updateSubAccountBox();
return panel;
}
Aggregations