Problem displaying table (JTABLE), can u help me?

Hi 2 all.
I'm beginer in java (I have expirience of some yoears developing in pro-C, but not java).
I try to create some JDialog using Intellig Idea7. There I create JTable component, try to initialize it with values in the array (that was inialized before)
(ex:
JTable table1 = new JTable(data_string_array, row_names_array);
The problem is when I try to make & run application, there is nothing displayed.
On "debug prints" ( print(table1.getValueAt(0,0)); ) where I try to print values of the table - everything is right. it print right values, but then aren't displayed on the dialog window.
What could be a problem?
here is example of the code:
import javax.swing.*;
import java.awt.event.*;
* Created by IntelliJ IDEA.
* User: db2admin
* Date: Jul 10, 2008
* Time: 11:53:43 AM
* To change this template use File | Settings | File Templates.
public class frame1 extends JFrame{
private JPanel contentPane;
private JButton buttonOK;
private JButton buttonCancel;
private JTable table1;
private JScrollPane scrollpane;
public frame1 ()
contentPane = new JPanel();
setContentPane(contentPane);
getRootPane().setDefaultButton(buttonOK);
// Create table data:
Object[][] data_matrix = {
{"one", "two"},
{"five", "six"},
{"nine", "ten"},
Object[] row_names = {"1row1", "2row2"};
// create new table instance
table1 = new JTable(data_matrix, row_names);
scrollpane = new JScrollPane(table1);
System.out.println("this print");
buttonOK.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
onOK();
buttonCancel.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
onCancel();
// call onCancel() when cross is clicked
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
addWindowListener(new WindowAdapter()
public void windowClosing(WindowEvent e)
onCancel();
// call onCancel() on ESCAPE
contentPane.registerKeyboardAction(new ActionListener()
public void actionPerformed(ActionEvent e)
onCancel();
}, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
private void onOK()
// add your code here
//dispose();
private void onCancel()
// add your code here if necessary
dispose();
public static void main(String[] args)
frame1 dialog = new frame1();
dialog.pack();
dialog.setVisible(true);
System.out.println("This is other print");
//JTableDemo demo = new JTableDemo();
//System.exit(0);
P.S. Other question: what principal difference in creating simple forms as JFrame or JDialog?

Hi!
Well, I don't know what IntellyJ makes, but
1) I can't see where the buttons are created, so addActionListener throws NPE.
2) I can't see where the scrollPane is added to the contentPane
Andras_

Similar Messages

  • Banner image will not display in Dreamweaver; can you help?

    Banner image will not display in Dreamweaver; can you help?

    If the banner image is not displaying, it is either not in an acceptable web file format (optimized for web as jpg, gif or png). Or it is corrupted.  Or the path to the image file on server is broken. 
    It's impossible to say more without a link to your problem page.
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists 
    http://alt-web.com/

  • HP 8500 printer will not print fast on firefox, but does on Safari. HP support says it is a problem with firefox. Can you help me out?

    Question
    HP 8500 printer will not print fast on firefox, but does on Safari. HP support says it is a problem with firefox. Can you help me out? edit

    Thank you for posting your list of installed Extensions. One of them might be intercepting the menu command. Since you have the Add-on Compatibility Reporter, it's possible that an older add-on that doesn't actually work well with Firefox 5 could be to blame. Could you try disabling the "HP Smart Web Printing" extension and see whether that makes any difference?
    Also, you can simulate a print button on a web site by pasting this to the location bar and pressing Enter. You also can save it as a bookmark for easier access (when scripts are saved as bookmarks, we call them bookmarklets). Hopefully you won't need it for long.
    <br>javascript:void(window.print());

  • I just updated to 10.8.4 and my mail program is showing a series of boxes with AAAAs inside them instead of the email addresses. Also when on Safari web pages are displaying the same AAAAAs instead of type. Firefox displays fine. Can someone help me?

    I just updated to 10.8.4 and my mail program is showing a series of boxes with AAAAs inside them instead of the email addresses. Also when on Safari web pages are displaying the same AAAAAs instead of type. Firefox displays fine. Can someone help me?

    Restart your Mac and immediately hold down the Shift key when you hear the startup chime to boot into Safe Mode. Keep holding the Shift key until you see a progress bar towards the bottom of the screen. You can let go of the Shift key at that point.
    OS X asks you to log in (you will get this screen on a Safe Mode boot even if your Mac is set to automatically log in). Let the Mac finish booting to the desktop and then restart normally. This will clear Font Book's database and the cache files of the user account you logged into in Safe Mode.
    Next, close all running applications. From an administrator account, open the Terminal app and enter the following command. You can also copy/paste it from here into the Terminal window:
    sudo atsutil databases -remove
    Terminal will then ask for your admin password. As you type, it will not show anything, so be sure to enter it correctly.
    This removes all font cache files. Both for the system and the current user font cache files. After running the command, close Terminal and immediately restart your Mac.

  • I am using Ringtone maker from Blackout labs, I made a ringtone and it did go into my tones and it won't upload to my phone. I have done this several times and never had any problems til now. Can anyone help me on this?

    I made a ringtone and it did go into my tones and it won't upload to my phone. I have done this several times and never had any problems til now. Can anyone help me on this?

    Try assigning Queen as the Album Artist on the compilations in iTunes on your computer.

  • TS3899 iPad mail account says problem with 'ssl settings' - can you help me?

    iPad mail account says problem with 'ssl settings' - can you help me?

    The 4Gs hardware, only 256 MB of RAM, prohibits updating beyond 6.1.6.
    Starting when iOS 7 was released, Apple now allows downloading the last compatible version of some apps (iOS 4.2.1 and later only)
    App Store: Downloading Older Versions of Apps on iOS - Apple Club
    App Store: Install the latest compatible version of an app
    You first have to download the non-compatible version on your computer. Then when you try to purchase the version on your iPod you will be offered a compatible version if one exists.

  • My search bar for my library no longer works. Also, the menu bar is no longer visible. Noticed this problem last Saturday. Can anyone help me with this?

    My search bar for my iTunes library no longer works. Also, the menu bar is no longer visible. Noticed this problem last Saturday. This might be an issue with my desktop, and not iTunes itself Can anyone help me with this?

    Press Ctrl-B to toggle the menu bar on and off.
    When you say that the "search bar for my iTunes library no longer works" can you be more specific?  The operation of the search function has changed in iTunes 12, essentially having two very distinct modes:
    when Search Entire Library is checked, entering a search string will generate a dropdown of all matching items within your whole library, from which multiple operations are available via context menus
    when Search Entire Library is unchecked, entering a search string creates a filtered view of whatever your current focus is (e.g., if you're looking at a playlist the filter applies only to items in that playlist) with none of the dropdown options as in the first case

  • I can't fathom the reasoning behind ID CS5 tables. Can you help?

    I can make ID CS5 tables work, but I don't understand how they work. I should mention that I'm a heavy FrameMaker user, so I'm sure I've got some faulty preconceptions.
    In FrameMaker, I'm accustomed to using table styles to automate table formatting. All table formatting info -- e.g., text styles for table titles, headings, and body; rules; cell padding; etc -- is built into the table style and applied with a single click. The text styling information is drawn from preexisting paragraph styles that are associated with the table style. All very straightforward. But in InDesign, things seem a lot more complicated.
    InDesign has Table Styles and Cell Styles. I'm unclear on the relationship between the two. You can specify ruling and shading styles in both. I don't understand this. 
    I've gotten more predictable results with Cell Styles, so I've built most of my formatting info into them. But Cell Styles aren't stand-alone entities. Even though you have to create them, then add them to the Table Style, they have to be associated with a preexisting paragraph style. This seems like a duplication of effort -- two separate styles (cell and paragraph) applying the same text formatting info. The Cell Style does include ruling and shading info, but that shouldn't be necessary since that information theoretically can be entered in the Table Style.
    Also, using Cell Styles limits you to one paragraph style per cell. In some cases I need two -- data or text, followed by some bullet points. When this happens I've had to strip out the Cell Style and apply a paragraph style directly. Seems funky.
    I don't want to get too deep into the weeds with specific puzzles I've encountered; suffice to say I don't understand how Table Styles and Cell Styles interact and how best to use them to create and format tables efficiently. Do any of you understand the thinking behind ID tables? Can you point to a source that explains it? There's got to be a system there, a set of coherent operating principles, but I haven't been able to discern them.
    Sincere thanks,
        --Donna Reynolds

    semiwool wrote:
    I'm not clear how you're able to automate the next-format behavior in FrameMaker. Are you saying that populating a FrameMaker table by importing text from a source, using the convert-to-table option does this because the incoming content has paragraph styles that match existing FrameMaker formats, and that you can't get this in InDesign? InDesign's import options are quite rich. If you need details, search Google for "InDesign text import options" without quotes.
    My apologies. I must have done a poor job of explaining the problem, which is: If you apply a Cell Style to a cell, that cell will only permit one paragraph style. If you need to use two styles in the cell, you have to change the Cell Style to None, then do your formatting with a regular paragraph style.
    These tables were imported as RTF, which has worked reasonably well. Actually, yesterday I was thinking about the discussion we had re: Frame > ID conversions. The first draft of the tutorial I worked up is done. If interested, I'd be happy to send a copy.
    Many thanks for your assistance,
       -dr
    Try this:
    * Create a small table, say four rows by four columns.
    * Create a paragraph style named noStyle, based on No Style.
    * Create a paragraph style with text color cyan, for the second paragraph in the cel; call it cyan. Leave Next Style as Same Style.
    * Create a paragraph style with text color magenta, for the first paragraph in the cell; call it magenta. Set Next style to cyan.
    * Create a cell style whose paragraph style is magenta.
    * In a table cell, create two paragraphs that use the style noStyle.
    * Copy the two paragraphs to another cell.
    * In the first cell, apply the magenta style to the first paragraph.
    * Select both paragraphs in the cell, or select the cell.
    * In the paragraph styles panel, Right-Click the magenta style name.
    * In the context menu that appears, click Apply "magenta" then Next Style. The first paragraph remains magenta, and the second paragraph changes to cyan.
    * Select  the second cell.
    * Apply the cell style magentaCell. Both paragraphs are tagged with the magenta paragraph style.
    * Select the cell and in the Paragraph Styles panel, Right-Click the paragraph style magenta, and select Apply "magenta," then Next Style. Like the two paragraphs selected in the cell that has no cell style applied, the first paragraph remains magenta, and the second paragraph changes to cyan.
    * Copy two paragraphs tagged with noStyle and paste to all the cells in the table.
    * Select the whole table.
    * Apply the magenta paragraph style to all cells.
    * * In the paragraph styles panel, Right-Click the magenta style name.
    * In the context menu that appears, click Apply "magenta" then Next Style. The first paragraph remains magenta, and the second paragraph changes to cyan. All the cells have the first paragraph tagged magenta and the second tagged cyan.
    * Undo these last steps until all cells have reverted to containing two noStyle paragraphs.
    * Select the whole table and apply the magenta cell style.
    * In the paragraph styles panel, Right-Click the magenta style name.
    * In the context menu that appears, click Apply "magenta" then Next Style. The first paragraph remains magenta, and the second paragraph changes to cyan.
    So, with or without cell styles, the Apply Next Style feature efficiently formats multiple-style table cells.
    [EDIT] Yes, I'd like to see your tutorial. Click on my name in the sidebar to send a private message, if you don't have my email address already. Thanks for the offer.[/EDIT]
    HTH
    Regards,
    Peter
    Peter Gold
    KnowHow ProServices
    Message was edited by: peter at knowhowpro

  • Start up problem, white screen. Can you help?

    Hello, this problem starts with a freeze up normally waking from sleep mode. Hard restart get fan noise,start up noise, white/gray screen with/out the apple or wheel and that is as far as it gets. Once in a while (like 2 in 4 days) it will boot completely. I have run disk utility 3 times, with it finding and fixing errors twice and none once. I have reset pram, I have tried booting booting from disc (holding c down while starting up) with no change. I have reset the sm by leaving the thing unplugged over night. I am in a small town with out a apple store and only one service center with a huge backlog! can anyone help? Oh and I have reinstalled osx and restored from timemachine 3 times and this still happens:-(

    Thanks, I failed to write down the errors, but i do recall them coming up while checking the catalog hierarchy...not much help I know. Thanks for the system test tip, but fond no problem. would the power supply cause the top of the computer to heat up? I just noticed it seems to be hot. I have put a fan blowing on it, to help for now. Keep in mind that I could have just never noticed this before! Here is my last question, I have always purchased apple care, a search shows nothing registered for this computer. I moved about 6 months ago and have no clue where the box with my apple care would be. I can not find my purchase receipt. I recall the apple store emailing it to me, but alas, I cannot find it. Do they keep records of these things? Thank you again for all of your help!

  • Is everybody having problems with Canoscan drivers-can anyone help, please?

    After starting with Leopard, my LIDE25 refuses to work, and the window from the toolbox tells me a driver cannot be found, even after redownloading the driver, which, according to the Canon website, is perfectly compatible with the LIDE25 driver. Someone is not being honest, or Apple has made a huge mistake in the bug department. My smart mailboxes don't work either.Can anyone help? I see there are others with Canon scanner driver problems on this forum - what can we do? I'm so tired of fragile scanners breaking down and needing replacement - they are like VCRs in this respect, somehow a crap technology - but this time it's surely not the scanner to blame.

    I have a Conoscan 8400F scanner, and after downloading the latest driver it actually works BETTER than it ever has... used to take almost 3 minutes to scan a 8.5 X 11 page, now less than a minute.
    Jeff

  • Lightroom problem!!! Can someone help please???

    Hi All,
      Just bought a new computer 2 wks ago & installed Lightroom 3.0.  I've used it only 3 times & when I went to open it to edit today  I get the message "Opening Catalog:Img 2136_cr2.Ircat"  then a window pops up saying that a problem caused the program to stop working.  windows will close the program & notify you if a solution is availble."  Can anyone help me with this.  I'm new to LR .  This is very discouraging ...maybe should just use PScs5 instead. 
    Any information would be greatly appreciated.
    Thanks kimkl

    First, I've not had any similar problems, which I know doesn't help you. But I think this isn't a chronic LR problem. Given that file name, I think you must have, at some point, exported a catalog (File / Export as Catalog on a PC). How that got set as your default catalog I'm not sure.
    Anyway, try this:
    Use your computer's search function to find the file in question. Delete it. Delete any other files in the same folder, EXCEPT for any image files, of course.
    Now restart LR.  It will come up with a message that says it can't find the catalog, and give you a choice of creating a new one, or selecting an existing one. If you really have only opened LR 3 times, and haven't done much editing, I'd suggest creating a new one. Otherwise, find the correct catalog file and choose it.
    Where is the "correct" catalog? It should be in a folder named Lightroom, normally located in the folder where your images are.
    Have you backed up your catalog when exiting LR?  If so, you could follow the advice above, but choose one of the backup .lrcat files.
    If worse comes to worse, find and delete ALL files that end in .lrcat and other files that are with them, then restart LR, and select the option to create a new catalog. Be sure to select the option, if it's presented, to always use that catalog when starting LR.
    This tutorial isn't exactly about this problem, but it will show you where the catalog files are located and how the dialogs I reference are set up:
    http://thelightroomlab.com/2009/05/how-to-get-your-lightroom-catalog-onto-an-external-hard -drive/
    Let us know if this helps.

  • My display doesnt work, can anyone help?

    Hi, i have an ipod nano..it worked fine until recently but now the display doesnt work. I can still play music on it but the screen stays either black or white. can anyone help please!

    If none of these steps address the issue, your iPod may need to be repaired.
    Consider setting up a mail-in repair for your iPod http://depot.info.apple.com/ipod/
    Or visit your local Apple Retail Store http://www.apple.com/retail/
    In case your iPod is no longer covered by the warranty and you want to find a second repairing company, you can try iPodResQ at your own risk
    http://www.ipodresq.com/index.php

  • I'm having problems installing my printer, can anyone help ?

    Hello there, i've installed a Canon MP 560 onto my Macbook, by mistake i installed it onto my wives user page ( I am relatively new to all this ). I need to install it on my user page, as i need for work. Can anyone help me move it ? Thank you.

    Leanneh,
    You may try a chat, the first one is for CC/CC2014, the others are for older versions:
    Creative Cloud support (all Creative Cloud customer service issues, chat open between 5AM and 7PM PST/PDT on workdays)
    http://helpx.adobe.com/x-productkb/global/service-ccm.html
    Serial number and activation support (non-CC, chat open between 5AM and 7PM PST/PDT on workdays)
    http://helpx.adobe.com/x-productkb/global/service1.html
    Get help with orders, refunds, and exchanges (non-CC, chat open between 5AM and 7PM PST/PDT on workdays)
    http://helpx.adobe.com/x-productkb/global/service-b.html
    Adobe ID and registration support (non-CC, chat open between 5AM and 7PM PST/PDT on workdays)
    http://helpx.adobe.com/x-productkb/global/service-c1.html
    And Adobe phone Support, is only for CC/CC2014:
    http://helpx.adobe.com/adobe-connect/adobe-connect-phone-numbers.html

  • Problems connecting to Exchange - can anyone help?...

    I'm trying to connect a Nokia N900 to our Exchange 2007 server.
    I've copied and installed our self signed certificate to the phone.
    After entering the details of our exchange server it attempts to connect but I keep getting the following error:
    "Either exchange server requires a secure connection or your account it disabled"
    All of our other devices (iphones, blackberries) work fine with the exact same settings.
    This seems like a common issue - one that Nokia are unable to help with.
    Can anyone help me?

    Good luck. Odds are very strong that something is cooked and the phone will have to be replaced. Drying it out with rice may work, but that's almost always a temporary solution. The corrosion has already begun and sooner or later, it will fail completely. Hopefully, it will wait until after you're eligible for an upgrade again.

  • Problem with Table.getSelectedColumn() method plz help its so urgent

    Hi,
    I need to display a input msg box while the given icode( coloumn name) is not there in database and the the input value should goto the product( 3rd column in my table) column in table. my code is bellow.
    private void TablePropertyChange(java.beans.PropertyChangeEvent evt) {
    // ss
    i=0;
    int s=1;
    String icde=new String();
    String Prdct=new String();
    String result=new String();
    // String CODE=new String();
    String ICDE=new String();
    String prd=new String();
    int Colselected=Table.getSelectedColumn();
    //column.getPreferredWidth();
    try
    TableColumn ICode = Table.getColumnModel().getColumn(1);
    TableColumn product = Table.getColumnModel().getColumn(2);
    TableColumn unit = Table.getColumnModel().getColumn(3);
    TableColumn rate = Table.getColumnModel().getColumn(4);
    TableColumn Amount = Table.getColumnModel().getColumn(5);
    for(;i<s;++i)
    //For loop starts
    ICode.setPreferredWidth(76);
    product.setPreferredWidth(157);
    unit.setPreferredWidth(75);
    rate.setPreferredWidth(85);
    Amount.setPreferredWidth(95);
    Table.setValueAt(i+1,i,0);
    float gr=0,//Gross amt
    qt=0,//Qty
    rt=0,//Rate;
    dcp=0,//Disc%
    dcam=0,//Disc Amt
    edrt=0,//EDrate
    edrt1=0,
    edam=0,//EDGross
    taxrt=0,//TaxRate
    taxam=0,//TaxAmt
    netam=0;//netamt
    try
    Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
    Connection con1 = DriverManager.getConnection(url1,"suresh", "special");
    Statement stmt1 = con1.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
                        ResultSet.CONCUR_READ_ONLY);
    Prdct=Table.getValueAt(i,1).toString();
    Statement stmti= con1.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
                        ResultSet.CONCUR_READ_ONLY);
    ResultSet rsi = stmti.executeQuery("select * from prd where ICODE='"+Prdct+"'");
    java.util.Vector <String> prdct = new java.util.Vector <String>();
    if(rsi.next())
    String prodct=rsi.getString("ITEM");
    prdct.add(prodct);
    Table.setValueAt(prdct,i,1);
    Double RT=rsi.getDouble("saleprice");
    String RTS=RT.toString();
    Table.setValueAt(RTS,i,4);
    // int ColValue=Colselected==1;
    else if(Colselected==1)
    result = (String)JOptionPane.showInputDialog(this,
    "Enter the new Item", "S-appsys's INFO",JOptionPane.INFORMATION_MESSAGE);
    System.out.println("asdrf "+i);
    Table.setValueAt(result,i,2);
    // Colselected=0;
    // Table.setV
    // System.out.println("asdrf "+i);
    }// Table.setValueAt(result,i,2);
    }catch ( java.lang.ClassNotFoundException cl)
    System.out.println("Error"+cl);
    catch(java.sql.SQLException sq)
    System.out.println("Error"+sq);
    qt=Float.parseFloat(Table.getValueAt(i, 3).toString());
    rt=Float.parseFloat(Table.getValueAt(i, 4).toString());
    gr=qt*rt;
    Table.setValueAt(gr,i,5);
    s=Table.getRowCount();
    }catch(java.lang.NullPointerException e){}
    my problem is i can get the msg box while i am giving value in 1st time. but if i am giving the value in second row it will show the msgbox 4 times and it will change previous rows product column value twise and then it will change current row value. i need solution for this
    plzzz help me
    Thanks in advance
    Suresh.

    Your description of the problem makes no sense to me.
    The code you posted in not formatted or executable so I'm not going to waste time trying to understand it.
    If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
    And don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags so the code retains its original formatting.

Maybe you are looking for