How can I add new row/column into existing jTable?

Hi add!
Can you help me how can I add new row/column into existing jTable?
Tnx in adv!

e.g
Create two buttons inside the Table ( "Add New Row" ) and ("Add new Column")
their handlers are:
add new row:
//i supose u already have
DefaultTabelModel tablemodel = new DefaultTableModel(rowdata, columnNames);
//and   
   JTabel jtable = new JTable(tablemodel);
// Handler (row)
jbtAddRow.addActionListener(new ActionListener(){
   public void actionPerformed(ActionEvent e) {
      if(jtable.getSelectedRow() >= 0 )
          tablemodel.insertRow(jtable.getSelectedRow(), new java.util.Vector());  
       else  
            tablemodel.addRow(new java.util.Vector());
    });to add new columns its the same but inside actionPerformed method:
ask for e.g "Whats the name for the new column"
then,
   tablemodel.addColumn(nameOfColumn, new java.util.Vector());   Joao
Message was edited by:
Java__Estudante

Similar Messages

  • How can i add or create Layers into existing PDF File

    How can i create or add new Layers into new or existing PDF file using DLE JAVA API (Datalogics API)

    sandyrock,
    The PDFL, as Adobe distributes it, only has a C/C++ interface.
    The JNI APIs are developed and supported by Datalogics, the company you licensed your copy of the PDFL from. Have you contacted them? Support for their API extensions to the PDFL should be included with your licensing fee and they have many tips and ready-made examples specific to their API extensions they could give you.

  • How can I add a row into a JTable with JButton

    Hi all. I have the following code:
    package gui;
    import db.*;
    import javax.swing.table.AbstractTableModel;
    import java.util.ArrayList;
    public class FoundersTable extends AbstractTableModel{
        private static final int COLUMNS = 8;
        private String columnNames[] = {"��� ����", "���", "�������", "�������", "���������", "��������",
                "����� �� ����������", "������ �� ����, �����"};
        private ArrayList data;
        public FoundersTable(){
            data = new ArrayList();
        public int getRowCount() {
            return data.size();
        public int getColumnCount() {
            return columnNames.length;
        public String getColumnName(int colIndex) {
            return columnNames[colIndex];
        public Object getValueAt(int rowIndex, int columnIndex) {
            return ((ArrayList)data.get(rowIndex)).get(columnIndex);
        public void setValueAt(Object value, int rowIndex, int columnIndex) {
            ((ArrayList)data.get(rowIndex)).set(columnIndex, value);
            fireTableCellUpdated(rowIndex, columnIndex);
        public void addRow(ArrayList neueZeile) {
            data.add(neueZeile);
            int index = data.size() - 1;
            fireTableRowsInserted(index, index);
        public void removeRow(int index) {
            data.remove(index);
            fireTableRowsDeleted(index, index);
        public void removeAllRows() {
            data.clear();
            fireTableRowsDeleted(0, 0);
        public boolean isCellEditable(int rowIndex, int columnIndex) {
            return true;
    }Now in my MainJFrame class I have one button for additing and one button for removing a selected row. How can I add/remove rows with this two buttons.
    Thanks

    No my question is how can I add and remove rows WITH buttons My point was the code is the same. You use the addRow(...) method. Why did you write an addRow(...) method if you aren't going to use it?
    I don't understand your problem. Do you not know how to write an ActionListener?

  • How to add new row and update existing rows at a time form the upload file

    hi
    How to add new row and update existing rows at a time form the upload file
    example:ztable(existing table)
    bcent                      smh            nsmh         valid date
    0001112465      7.4                       26.06.2007
    0001112466      7.5                       26.06.2007
    000111801                      7.6                       26.06.2007
    1982                      7.8                       26.06.2007
    Flat file structure
    bcent                       nsmh         valid date
    0001112465     7.8     26.06.2007  ( update into above table in nsmh)
    0001112466     7.9     26.06.2007  ( update into above table in nsmh) 
    000111801                     7.6      26.06.2007 ( update into above table in nsmh
    1985                      11              26.06.2007   new row it should insert in table
    thanks,
    Sivagopal R

    Hi,
    First upload the file into an internal table. If you are using a file that is on application server. Use open dataset and close dataset.
    Then :
    Loop at it.
    *insert or modify as per your requirement.
    Endloop.
    Regards,
    Srilatha.

  • How can I add new content in iDVD to a DVD-RW disc which has ample remaining free space? After preparing the new video for burning and clicking on Burn to iDVD, I get a window saying the disc's already recorded and that I can either Erase or Eject.

    How can I add new content in iDVD to a DVD-RW disc with a video previously successfully recorded on it? (The disc has ample remaining free space.)
    After preparing the new video for burning and clicking in the File menu on Burn to iDVD, I get a window saying the disc's already recorded and that I can either Erase or Eject. My assumption has been that iDVD would automatically find the free space and continue with the new recording from there. I'd be grateful if anyone can shine light on this.

    There are, but not with a DVD written as a movie disk. It must be closed when completed, or it doesn't work.
    Apple's built in Burn utility also automatically closes any data CD, DVD or Blu-ray disk you burn. Doesn't matter how much space is unused, you can't use it. You'd have to use a more advanced disk creation app, such as Toast Titanium. I then have the option of choosing to write the data as a session:
    I can keep doing this until the disk is full. If I've written five sessions to the disk, when I put it in the drive, five CD/DVD icons will appear on the desktop since the OS will treat each session as if they are separate physical disks. At any point you choose Write Disk when writing a group of data, that means you're closing the disk, and again can't add anything after that. So if I had written two sessions, and the third was Write Disk, it's over. I can't put anything else on that disk.

  • How can i add new tab in Business Partner

    hi every body,
    Present i am working on SAP CRM 3.0 version. i need to add new tab in BP.  Here EEWB not available. How can i add new tab?

    Hi  babu,
    you can add new tab in Buisness partner with the help of screen configaration functionality,in screen configaration u select first bp role (sold to party or retailer etc) and click on process screen sequence  and again click on overview and u will get fields right side of the screen, there u will see the field "new screen" click on that and add description for new tab and click on continue,save the document
    now u will again create a bp with modified bp role u will see changes means u will see new tab page on perticular bp role
    i hope this is helpful
    Rewards points if helpful
    Thanks&regards
    kishore kumar

  • How can i add new jcomponent to a frame?

    hi.
    how can we add new component to a frame? look at this code. Why when i click on button, nothing added to frame? event handled correctly and frame size changes but no button adds to frame.
    private void convertButtonMouseClicked(java.awt.event.MouseEvent evt) {
    // TODO add your handling code here:
    JButton newButton = new JButton("new");
    getContentPane().add(newButton , BorderLayout.CENTER);
    newButton.setVisible(true);
    setSize(500, 500);
    }

    Don't forget to use the Code Formatting Tags so the posted code retains its original formatting. That is done by selecting the code and then clicking on the "Code" button above the question input area.
    Well typically you wouldn't add a button to the Center of a BorderLayout. If you really want to do this you should be using a [Card Layout|http://java.sun.com/docs/books/tutorial/uiswing/TOC.html].
    In general the code for adding/removing components should be:
    panel.add(...)
    panel.revalidate();
    panel.repaint();

  • How can I add new songs to the top (not the bottom) of my playlist in iTunes?

    How can I add new songs to the top of my playlist in iTunes?
    I thought thats what it did before but now it automatically adds new songs to the bottom of the list.
    Not a huge issue but an annoyance.

    Go to your Music library
    Then, Click Playlist
    Then, Click the sort arrow until it points down.

  • I have one playlist on iphone4. how can i add new playlist without deleting old one. i do not have old playlist in itunes any more.

    I have one playlist on iphone4. how can i add new playlist without deleting old one. i do not have old playlist in itunes any more.When i try to sync iphone with itunes it says that this action will remove my old playlist and all songs.

    "it says that this action will remove my old playlist and all songs."
    Are you connecting to a different iTunes library than you normally connect to?  That will erase the songs and playlists since the iPhone can't be connected to multiple libraries even if it is in manual sync mode.
    If you no longer have access to the original library that your iPhone calls 'home', then the only way to save the playlist (and the songs on your iPhone) would be to use a 3rd party application to extract your iPhone contents to this new iTunes library you're trying to connect to.

  • How can I add new background on iweb?

    Dear all,
    somebody knows how can I add new backgroungs on iweb? and also how can I add my own themes?
    Cheers

    bobzhuman wrote:
    You can add new backgrounds in the "page"..."layout" section of the "inspector"...no limit to what you can add. Remember to use low resolution pics (72 dpi vs 300 dpi) and think of the size necessary for a "wallpaper" on your desktop. ex. http://www.desertmoon.net/Coryhamilton/Home.html done with a Jumsoft theme (baseball dark) as a core.
    The file used as a background on that site is located at http://www.desertmoon.net/Coryhamilton/Home_files/grunge.jpg
    It's dimensions are 1200px by 797px and 284k in file size. I guess there might be a reason to have the width set for 1200px even though file sizes could benefit from a smaller dimension repeating graphic, but running the file through Photoshop or even Elements would let the owner "Save For Web" as a .jpg - medium quality and get the file size down to about 108k so that the page would load quite a bit faster.

  • How can I add new songs and videos...?

    How can I add new songs and videos to my ipod without syncing as it wants to wipe out the ipod and replace all the existing media?

    On the ipod itself?  If so how?
    I've tried checking on box by the sync music to deselect "Entire music library", but get the  message about "Are sure.... All existing content on the iPod will be removed and replaced...".  However, I don't want to do that as there is music on my ipod I don't want to loose, got it from a previous computer that crashed and could not be recovered.

  • How can i add new files to my ipod from a different computer  without losing the added files on my ipod?

    how can i add new files to my ipod touch from a diferent computer without losing the added files already on my ipod?

    Email them? Use DropBox?  What type of files?

  • How can I Add new LookAndFel to IDE

    How can I Add new LookAndFel to IDE "JDeveloper 10g" ?
    (to the combo box in the Tool->Preferences->LookAndFeel ).

    Here is how you can add new L&Fs to the drop down list. (Instructions are for Linux , as I use Linux, but they will work for Windows too)
    Add the L&F jar to <path to JRE>/lib/ext (or <path to JDK>/jre/lib/ext). Then create swing.properties (if it does not already exist) in <path to JRE>/lib (or in jdk...) with following lines:
    swing.installedlafs = motif,windows,metal,mac,plastic
    swing.installedlaf.motif.name = CDE/Motif
    swing.installedlaf.motif.class = com.sun.java.swing.plaf.motif.MotifLookAndFeel
    swing.installedlaf.windows.name = Windows
    swing.installedlaf.windows.class = com.sun.java.swing.plaf.windows.WindowsLookAndFeel
    swing.installedlaf.metal.name = Metal
    swing.installedlaf.metal.class = javax.swing.plaf.metal.MetalLookAndFeel
    swing.installedlaf.mac.name = Mac
    swing.installedlaf.mac.class = com.sun.java.swing.plaf.mac.MacLookAndFeel
    swing.installedlaf.plastic.name = Plastic
    swing.installedlaf.plastic.class = com.jgoodies.plaf.plastic.PlasticLookAndFeel
    swing.defaultlaf=com.jgoodies.plaf.plastic.PlasticLookAndFeel
    Note that I retained default example L&Fs that normally come with the JDK/JRE (depending on the platfom) and added PlasticLookAndFeel as additional PLAF (Pluggable Look And Feel).
    Now it should be possible to choose Plastic L&F in not only JDeveloper but also other Swing apps that you want to use.
    Please let me know if this works and also if you have any questions.
    - Ganesh

  • How can i add new identity in file option of menu bar

    ''locking as a duplicate - https://support.mozilla.com/en-US/questions/869755''
    how can i add new identity option in file option of menu bar

    There are, but not with a DVD written as a movie disk. It must be closed when completed, or it doesn't work.
    Apple's built in Burn utility also automatically closes any data CD, DVD or Blu-ray disk you burn. Doesn't matter how much space is unused, you can't use it. You'd have to use a more advanced disk creation app, such as Toast Titanium. I then have the option of choosing to write the data as a session:
    I can keep doing this until the disk is full. If I've written five sessions to the disk, when I put it in the drive, five CD/DVD icons will appear on the desktop since the OS will treat each session as if they are separate physical disks. At any point you choose Write Disk when writing a group of data, that means you're closing the disk, and again can't add anything after that. So if I had written two sessions, and the third was Write Disk, it's over. I can't put anything else on that disk.

  • How can I add keywords for SEO into the code?

    How can I add keywords (for SEO) into the code of a Muse designed site?

    You might also be interested in the upcoming MuseJam on Thursday Muse Jam: Search Engine Optimization | Facebook
    Muse Jam: Search Engine Optimization
    Online May 22, 2013
    Join Principal Product Manager Dani Beaumont of the Adobe Muse team as she explores ways within the Muse application to build search engine optimized sites by way of metadata, keywords, H1 definitions, and sitemap generation. After the presentation we'll open the floor to any questions you might with the application.

Maybe you are looking for