0

I got a serious problem on my code.

I got a swing JDBC code which I need to fill a table of names, addresses and an ID for the person, different than the table's ID. I created a swing input code for it, however, I wish it NOT to include the ID number's possibility - therefore, to make the swing have nothing else but the name and address being able to be set by the used, and not to show the ID at all.

Is there a possibility for it?

The creation of new partner, which has the name, address and the IdentityNumber strings, all private and their getters and setters public.

{

    protected final String FRAME_TITLE = "Vehicle Repository";
    private DatabaseHandler dbHandler;
    private JTabbedPane tabbedPane;
    private JTable partnerTable;
    private JpaControlledTableModel<Partner> partnerTableModel;

    @Override
    public void onCreate() {
        setDefaults(FRAME_TITLE);
        setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        dbHandler = new DatabaseHandler();
        dbHandler.open();
        tabbedPane = new JTabbedPane();

        partnerTableModel = new AsyncFullQueryingTableModel<>(dbHandler.getPartnerJpaController(), dbHandler.getEntityClassesToControllersMap());
        parterTable = new JTable(partnerTableModel);

        tabbedPane.addTab("Partners", new JScrollPane(parterTable));
        getContentPane().add(tabbedPane, BorderLayout.CENTER);
    }

    @Override
    public JMenuBar createJMenuBar() {
        JMenuBar menuBar = new JMenuBar();
        JMenu menu = new JMenu("Data");
        menuBar.add(menu);
        JMenuItem menuItem;
        menuItem = new JMenuItem(newPartnerAction);
        menu.add(menuItem);
        return menuBar;
    }
    private Action newPartnerAction = new AbstractAction("New parnter") {
        @Override
        public void actionPerformed(ActionEvent e) {
            Partner partner = new Partner();
            EntityEditorDialog<Partner> editorDialog = EntityEditorDialogFactory.createEditorDialog(partner, dbHandler.getPartnerJpaController());
            editorDialog.setVisible(true);
            if (partner.getId() != null) {
                partnerTableModel.refresh();
            }
        }
    };

    private String getString(String message) {
        return JOptionPane.showInputDialog(rootPane, message, "Data input", JOptionPane.QUESTION_MESSAGE);
    }

    private Partner getPartner(String message) {
        Object[] partners = dbHandler.getPartnerJpaController().findEntities().toArray();
        if (partners.length == 0) {
            return null;
        } else {
            return (Partner) JOptionPane.showInputDialog(rootPane, message, "Data input", JOptionPane.QUESTION_MESSAGE, null, partners, partners[0]);
        }
    }

    @Override
    public void dispose() {
        dbHandler.close();
        super.dispose();
    }
}

    };
Grijesh Chauhan
  • 57,103
  • 20
  • 141
  • 208
  • 4
    please whats the question, is about, please how can I wrote this code, without any consequence, for better help sooner post an [SSCCE](http://sscce.org/), short, runnable, compilable, with hardcoded value as local variables for JDBC .... – mKorbel May 18 '13 at 14:42
  • I want the user to be able ONLY to be able to give inside the name and the address of a person by input codes, and the other parts will be done. It seems to work now by other comment's help, but still not made the full work on it - still, a step forward. – user2397009 May 19 '13 at 22:32

1 Answers1

2

and not to show the ID at all

You can remove a column from display in the JTable:

table.removeColumn( table.getColumn(...) );
camickr
  • 321,443
  • 19
  • 166
  • 288