List of usage examples for javax.swing JButton setIcon
@BeanProperty(visualUpdate = true, description = "The button's default icon") public void setIcon(Icon defaultIcon)
From source file:jgnash.ui.report.compiled.RunningAccountBalanceChart.java
private JPanel createPanel() { LocalDate end = DateUtils.getLastDayOfTheMonth(endDateField.getLocalDate()); LocalDate start = end.minusYears(1); startDateField.setDate(start);/*from w w w . jav a 2s . c o m*/ 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")); JFreeChart chart = createVerticalXYBarChart(combo.getSelectedAccount()); 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 -> { updateSubAccountBox(); Account a = combo.getSelectedAccount(); if (a == null) { return; } chartPanel.setChart(createVerticalXYBarChart(a)); panel.validate(); }; hideLockedAccountCheckBox.addActionListener(e -> { combo.setHideLocked(hideLockedAccountCheckBox.isSelected()); updateSubAccountBox(); Account a = combo.getSelectedAccount(); if (a == null) { return; } chartPanel.setChart(createVerticalXYBarChart(a)); panel.validate(); }); hidePlaceholderAccountCheckBox.addActionListener(e -> { combo.setHidePlaceholder(hidePlaceholderAccountCheckBox.isSelected()); updateSubAccountBox(); Account a = combo.getSelectedAccount(); if (a == null) { return; } chartPanel.setChart(createVerticalXYBarChart(a)); panel.validate(); }); updateSubAccountBox(); combo.addActionListener(listener); refreshButton.addActionListener(listener); return panel; }
From source file:com.intel.stl.ui.common.view.ComponentFactory.java
public static JButton getIntelActionButton(String text, Icon icon) { JButton btn = new JButton(text); btn.setUI(new IntelButtonUI(UIConstants.INTEL_MEDIUM_BLUE, UIConstants.INTEL_MEDIUM_DARK_BLUE)); btn.setBackground(UIConstants.INTEL_BLUE); btn.setForeground(UIConstants.INTEL_WHITE); btn.setIcon(icon); return btn;/*w ww . j a v a2 s .c o m*/ }
From source file:be.nbb.demetra.dfm.DfmExecViewTopComponent.java
@Override public JComponent getToolbarRepresentation() { JToolBar toolBar = NbComponents.newInnerToolbar(); toolBar.addSeparator();//from w ww .j av a 2 s . com toolBar.add(Box.createRigidArea(new Dimension(5, 0))); JToggleButton startStop = (JToggleButton) toolBar .add(new JToggleButton(StartStopCommand.INSTANCE.toAction(this))); startStop.setIcon(DemetraUiIcon.COMPILE_16); startStop.setDisabledIcon(createDisabledIcon(startStop.getIcon())); startStop.setToolTipText("Start/Stop"); JButton edit = toolBar.add(EditSpecCommand.INSTANCE.toAction(this)); edit.setIcon(DemetraUiIcon.PREFERENCES); edit.setDisabledIcon(createDisabledIcon(edit.getIcon())); edit.setToolTipText("Specification"); JButton clear = toolBar.add(ClearCommand.INSTANCE.toAction(this)); clear.setIcon(DemetraUiIcon.EDIT_CLEAR_16); clear.setDisabledIcon(createDisabledIcon(clear.getIcon())); clear.setToolTipText("Clear"); SwingColorSchemeSupport colorSchemeSupport = SwingColorSchemeSupport .from(DemetraUI.getInstance().getColorScheme()); sparkline = (ChartPanel) toolBar .add(Charts.avoidScaling(new ChartPanel(Charts.createSparkLineChart(null)))); sparkline.setPreferredSize(new Dimension(150, 16)); sparkline.setMaximumSize(new Dimension(150, 16)); sparkline.getChart().getXYPlot().setDataset(dataset); sparkline.getChart().getXYPlot().getRenderer() .setBasePaint(colorSchemeSupport.getLineColor(ColorScheme.KnownColor.GREEN)); sparkline.setBackground(colorSchemeSupport.getPlotColor()); sparkline.setBorder(BorderFactory.createLineBorder(colorSchemeSupport.getGridColor())); sparkline.setToolTipText("loglikelihood"); return toolBar; }
From source file:es.emergya.ui.base.plugins.PluggableJTabbedPane.java
private void addFloatingButtons() { JButton salir = new JButton(); salir.addActionListener(new ExitHandler()); Icon icon = LogicConstants.getIcon("header_button_exit"); salir.setIcon(icon); if (icon != null) if (min_height < icon.getIconHeight()) min_height = icon.getIconHeight(); // Aadimos el botn de Salir salir.setBounds(this.getWidth() - icon.getIconWidth() - 2, 2, icon.getIconWidth(), icon.getIconHeight()); salir.setBorderPainted(false);/*from ww w . j a va 2 s.c o m*/ PluggableJTabbedPane.this.salir = salir.getBounds(); // Logo de la empresa JLabel logo = new JLabel(); icon = LogicConstants.getIcon("header_logo_cliente"); if (min_height < icon.getIconHeight()) min_height = icon.getIconHeight(); logo.setIcon(icon); logo.setBounds(salir.getBounds().x - icon.getIconWidth() - 2, 2, icon.getIconWidth(), icon.getIconHeight()); JLabel companyLogo = new JLabel(); icon = LogicConstants.getIcon("header_logo"); if (icon != null) if (min_height < icon.getIconHeight()) min_height = icon.getIconHeight(); companyLogo.setIcon(icon); companyLogo.setBounds(logo.getBounds().x - icon.getIconWidth(), 2, icon.getIconWidth(), icon.getIconHeight()); botones_flotantes = new ArrayList<JComponent>(); addFloatingButton(companyLogo); addFloatingButton(logo); addFloatingButton(salir); repaint(); }
From source file:jgnash.ui.report.compiled.MonthlyAccountBalanceChart.java
private JPanel createPanel() { LocalDate end = DateUtils.getLastDayOfTheMonth(endDateField.getLocalDate()); LocalDate start = end.minusYears(1); startDateField.setDate(start);//from w w w . ja v a 2 s .c o m 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; }
From source file:com.intel.stl.ui.common.view.ComponentFactory.java
public static JButton getIntelActionButton(ImageIcon icon, final Color enableColor, final Color disableColor, AbstractAction action) {/*from w w w .j a va2 s . c om*/ JButton btn = new JButton(action) { private static final long serialVersionUID = 1L; @Override public void setEnabled(boolean b) { super.setEnabled(b); setForeground(b ? enableColor : disableColor); } }; btn.setIcon(icon); btn.setUI(new IntelButtonUI(UIConstants.INTEL_MEDIUM_BLUE, UIConstants.INTEL_MEDIUM_DARK_BLUE)); return btn; }
From source file:net.nosleep.superanalyzer.panels.HomePanel.java
public JPanel createRightButtonBarPanel(final PieRotator rotator) { URL url = this.getClass().getResource("/media/" + "ButtonPlay.png"); final ImageIcon playIcon = new ImageIcon(Toolkit.getDefaultToolkit().getImage(url)); url = this.getClass().getResource("/media/" + "ButtonPause.png"); final ImageIcon pauseIcon = new ImageIcon(Toolkit.getDefaultToolkit().getImage(url)); final JButton button = new JButton(playIcon); button.setBorder(null);// w ww.j a v a 2 s .c o m button.setBorderPainted(false); button.setText(null); button.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { if (rotator.isRunning() == false) { rotator.start(); button.setIcon(pauseIcon); } else { rotator.stop(); button.setIcon(playIcon); } } }); JToolBar toolBar = new JToolBar(); toolBar.setFloatable(false); toolBar.setBackground(Color.white); toolBar.add(button); JPanel barPanel = new JPanel(new BorderLayout()); barPanel.setBackground(Color.white); barPanel.add(toolBar, BorderLayout.SOUTH); return barPanel; }
From source file:jgnash.ui.report.compiled.MonthlyAccountBalanceChartCompare.java
private JPanel createPanel() { LocalDate end = DateUtils.getLastDayOfTheMonth(endDateField.getLocalDate()); LocalDate start = end.minusYears(1); startDateField.setDate(start);/* w w w .j a v a2 s . co m*/ 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; }
From source file:me.philnate.textmanager.windows.MainWindow.java
/** * Initialize the contents of the frame. *///from www. j a v a 2 s.c o m private void initialize() { changeListener = new ChangeListener(); frame = new JFrame(); frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { Starter.shutdown(); } }); frame.setBounds(100, 100, 1197, 500); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().setLayout(new MigLayout("", "[grow]", "[][grow][::16px]")); customers = new CustomerComboBox(); customers.addItemListener(changeListener); frame.getContentPane().add(customers, "flowx,cell 0 0,growx"); jScrollPane = new JScrollPane(); billLines = new BillingItemTable(frame, true); jScrollPane.setViewportView(billLines); frame.getContentPane().add(jScrollPane, "cell 0 1,grow"); // for each file added through drag&drop create a new lineItem new FileDrop(jScrollPane, new FileDrop.Listener() { @Override public void filesDropped(File[] files) { for (File file : files) { addNewBillingItem(Document.loadAndSave(file)); } } }); monthChooser = new JMonthChooser(); monthChooser.addPropertyChangeListener(changeListener); frame.getContentPane().add(monthChooser, "cell 0 0"); yearChooser = new JYearChooser(); yearChooser.addPropertyChangeListener(changeListener); frame.getContentPane().add(yearChooser, "cell 0 0"); JButton btnAddLine = new JButton(); btnAddLine.setIcon(ImageRegistry.getImage("load.gif")); btnAddLine.setToolTipText(getCaption("mw.tooltip.add")); btnAddLine.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { addNewBillingItem(); } }); frame.getContentPane().add(btnAddLine, "cell 0 0"); JButton btnMassAdd = new JButton(); btnMassAdd.setIcon(ImageRegistry.getImage("load_all.gif")); btnMassAdd.setToolTipText(getCaption("mw.tooltip.massAdd")); btnMassAdd.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { JFileChooser file = new DocXFileChooser(); switch (file.showOpenDialog(frame)) { case JFileChooser.APPROVE_OPTION: File[] files = file.getSelectedFiles(); if (null != files) { for (File fl : files) { addNewBillingItem(Document.loadAndSave(fl)); } } break; default: return; } } }); frame.getContentPane().add(btnMassAdd, "cell 0 0"); billNo = new JTextField(); // enable/disable build button based upon text in billNo billNo.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent arg0) { setButtonStates(); } @Override public void insertUpdate(DocumentEvent arg0) { setButtonStates(); } @Override public void changedUpdate(DocumentEvent arg0) { setButtonStates(); } private void setButtonStates() { boolean notBlank = StringUtils.isNotBlank(billNo.getText()); build.setEnabled(notBlank); view.setEnabled(pdf.find(billNo.getText() + ".pdf").size() == 1); } }); frame.getContentPane().add(billNo, "cell 0 0"); billNo.setColumns(10); build = new JButton(); build.setEnabled(false);// disable build Button until there's some // billNo entered build.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (runningThread == null) { try { // check that billNo isn't empty or already used within // another Bill if (billNo.getText().trim().equals("")) { JOptionPane.showMessageDialog(frame, getCaption("mw.dialog.error.billNoBlank.msg"), getCaption("mw.dialog.error.billNoBlank.title"), JOptionPane.ERROR_MESSAGE); return; } try { bill.setBillNo(billNo.getText()).save(); } catch (DuplicateKey e) { // unset the internal value as this is already used bill.setBillNo(""); JOptionPane.showMessageDialog(frame, format(getCaption("mw.error.billNoUsed.msg"), billNo.getText()), getCaption("mw.dialog.error.billNoBlank.title"), JOptionPane.ERROR_MESSAGE); return; } PDFCreator pdf = new PDFCreator(bill); pdf.addListener(new ThreadCompleteListener() { @Override public void threadCompleted(NotifyingThread notifyingThread) { build.setToolTipText(getCaption("mw.tooltip.build")); build.setIcon(ImageRegistry.getImage("build.png")); runningThread = null; view.setEnabled(DB.pdf.find(billNo.getText() + ".pdf").size() == 1); } }); runningThread = new Thread(pdf); runningThread.start(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } build.setToolTipText(getCaption("mw.tooltip.build.cancel")); build.setIcon(ImageRegistry.getImage("cancel.gif")); } else { runningThread.interrupt(); runningThread = null; build.setToolTipText(getCaption("mw.tooltip.build")); build.setIcon(ImageRegistry.getImage("build.png")); } } }); build.setToolTipText(getCaption("mw.tooltip.build")); build.setIcon(ImageRegistry.getImage("build.png")); frame.getContentPane().add(build, "cell 0 0"); view = new JButton(); view.setToolTipText(getCaption("mw.tooltip.view")); view.setIcon(ImageRegistry.getImage("view.gif")); view.setEnabled(false); view.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { File file = new File(System.getProperty("user.dir"), format("template/%s.tmp.pdf", billNo.getText())); try { pdf.findOne(billNo.getText() + ".pdf").writeTo(file); new ProcessBuilder(Setting.find("pdfViewer").getValue(), file.getAbsolutePath()).start() .waitFor(); file.delete(); } catch (IOException | InterruptedException e1) { // TODO Auto-generated catch block LOG.warn("Error while building PDF", e1); } } }); frame.getContentPane().add(view, "cell 0 0"); statusBar = new JPanel(); statusBar.setBorder(new BevelBorder(BevelBorder.LOWERED)); statusBar.setLayout(new BoxLayout(statusBar, BoxLayout.X_AXIS)); GitRepositoryState state = DB.state; JLabel statusLabel = new JLabel(String.format("textManager Version v%s build %s", state.getCommitIdDescribe(), state.getBuildTime())); statusLabel.setHorizontalAlignment(SwingConstants.LEFT); statusBar.add(statusLabel); frame.add(statusBar, "cell 0 2,growx"); JMenuBar menuBar = new JMenuBar(); frame.setJMenuBar(menuBar); JMenu menu = new JMenu(getCaption("mw.menu.edit")); JMenuItem itemCust = new JMenuItem(getCaption("mw.menu.edit.customer")); itemCust.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { new CustomerWindow(customers); } }); menu.add(itemCust); JMenuItem itemSetting = new JMenuItem(getCaption("mw.menu.edit.settings")); itemSetting.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { new SettingWindow(); } }); menu.add(itemSetting); JMenuItem itemImport = new JMenuItem(getCaption("mw.menu.edit.import")); itemImport.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { new ImportWindow(new ImportListener() { @Override public void entriesImported(List<BillingItem> items) { for (BillingItem item : items) { item.setCustomerId(customers.getSelectedCustomer().getId()) .setMonth(monthChooser.getMonth()).setYear(yearChooser.getYear()); item.save(); billLines.addRow(item); } } }, frame); } }); menu.add(itemImport); menuBar.add(menu); customers.loadCustomer(); fillTableModel(); }