JTable and JAR help

Hi,
I wonder if it's possible to make a JTable not editable for users, I thought there had to be a way, but I can't seem to find the proper method.
I also wonder how you can make a mouselistener on a JTable in such a way that when you double click on a row, something happends.
And I have some probs with jar archives, I can make them, but when i try to run them, this pops up:
"Failed to load Main-Class manifest attribute from MyProgram.jar"
appreciate all help...

You set this up in your table model.
When you create your table model, or just override AbstractTableModel. Make sure that isCellEditable() always returns false.

Similar Messages

  • Help with TableRowSorter , JTable and JList

    Hello,
    I�m developing an application in which I�m using a Jtable and Jlist to display data from a database. Jtable and Jlist share the same model.
    public class DBSharedModel extends DefaultListModel implements TableModelFor the Jtable I set a sorter and an filter
    DBSharedModel dataModel = new DBSharedModel();
    Jtable jTable = new JTable(dataModel) ;
    jTable.createDefaultColumnsFromModel();
    jTable.setRowSelectionAllowed(true);
    TableRowSorter<DBSharedModel> sorter = new TableRowSorter <DBSharedModel> (dataModel);
    jTable.setRowSorter(sorter);From what I read until now JavaSE 6 has NOT a sorter for JList (like one for JTable).
    So, I am using one from a this article http://java.sun.com/developer/technicalArticles/J2SE/Desktop/sorted_jlist/index.html
    When I sort the data from the table, I need to sort the data from the list, too.
    My ideea is to make the Jlist an Observer for the Jtable.
    My questions are:
    1.     How can I find if the sorter makes an ASCENDING or DESCENDING ordering?
    2.     How can I find what the column that is ordered?
    Or if you have any idea on how can I do the ordering on Jlist to be simultaneous to Jtable .
    Please help!
    Thank you

    Oh what the hell:
    Sun's basic Java tutorial
    Sun's New To Java Center. Includes an overview of what Java is, instructions for setting up Java, an intro to programming (that includes links to the above tutorial or to parts of it), quizzes, a list of resources, and info on certification and courses.
    http://javaalmanac.com. A couple dozen code examples that supplement The Java Developers Almanac.
    jGuru. A general Java resource site. Includes FAQs, forums, courses, more.
    JavaRanch. To quote the tagline on their homepage: "a friendly place for Java greenhorns." FAQs, forums (moderated, I believe), sample code, all kinds of goodies for newbies. From what I've heard, they live up to the "friendly" claim.
    Bruce Eckel's Thinking in Java (Available online.)
    Joshua Bloch's Effective Java
    Bert Bates and Kathy Sierra's Head First Java. This one has been getting a lot of very positive comments lately.

  • Error while converting jad and jar to alx and cod files

    hi all,
    i am getting an error while converting jad and jar files into cod and alx files for balckberry.. here is the error i am getting.. can anyone help me this regard...
    Parsing classfile: txtCanvas.class
    I/O Error: Import file not found: d:\Research In Motion\BlackBerry JDE4.6.0\lib\
    net_rim_api.jar
    thanks in advacne
    pallavi

    thank you very much for your responses. can i send my cod and alx files to check. if you are interested only.
    here is the command which i used to convert my jad and jar files
    D:\Research In Motion\BlackBerry JDE 4.6.0\bin>rapc import="d:\Research In Motio
    n\BlackBerry JDE 4.6.0\lib\net_rim_api.jar" codename=MoBilalMIDlet -midlet jad=M
    oBilalEnglish.jad MoBilalEnglish.jar

  • How to install and run my .jad and .jar on my Nokia6230?

    I'am newbie with J2ME.
    I transfer the .jad and .jar files of my first HelloWorld middlet to the phone.
    What is the next step?
    Is needed some JVM or similar in the phone?
    (When I try to open those files a 'file format not recognized' appears)
    thakns!

    Adarsh
       Before you start, it would be best to check for systems prerequisites (especially the backend Business Suite that you want to run against). Then you need to decide whether you want to run NWBC Desktop (i.e. Windows based) vs HTML (i.e. Browser based). The OSS Note # 900000 (NWBC FAQ) below should help to set you in the right direction.
    https://websmp130.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/sno/ui_entry/entry.htm?param=69765F6D6F64653D3030312669765F7361…
       License wise, NWBC licensing is the same as SAPGUI ... It's free as long as you have the standard SAP maintenance license.
    HTH

  • JTable and ResultSet TableModel with big resultset

    Hi, I have a question about JTable and a ResultSet TableModel.
    I have to develop a swing JTable application that gets the data from a ResultSetTableModel where the user can update the jtable data.
    The problem is the following:
    the JTable have to contain the whole data of the source database table. Currently I have defined a
    a TYPE_SCROLL_SENSITIVE & CONCUR_UPDATABLE statement.
    The problem is that when I execute the query the whole ResultSet is "downloaded" on the client side application (my jtable) and I could receive (with big resultsets) an "out of memory error"...
    I have investigate about the possibility of load (in the client side) only a small subset of the resultset but with no luck. In the maling lists I see that the only way to load the resultset incrementally is to define a forward only resultset with autocommit off, and using setFetchSize(...). But this solution doesn't solve my problem because if the user scrolls the entire table, the whole resultset will be downloaded...
    In my opinion, there is only one solution:
    - create a small JTable "cache structure" and update the structure with "remote calls" to the server ...
    in other words I have to define on the server side a "servlet environment" that queries the database, creates the resultset and gives to the jtable only the data subsets that it needs... (alternatively I could define an RMI client/server distribuited applications...)
    This is my solution, somebody can help me?
    Are there others solutions for my problem?
    Thanks in advance,
    Stefano

    The database table currently is about 80000 rows but the next year will be 200000 and so on ...
    I know that excel has this limit but my JTable have to display more data than a simple excel work sheet.
    I explain in more detail my solution:
    whith a distribuited TableModel the whole tablemodel data are on the server side and not on the client (jtable).
    The local JTable TableModel gets the values from a local (limited, 1000rows for example) structure, and when the user scroll up and down the jtable the TableModel updates this structure...
    For example: initially the local JTable structure contains the rows from 0 to 1000;
    the user scroll down, when the cell 800 (for example) have to be displayed the method:
    getValueAt(800,...)
    is called.
    This method will update the table structure. Now, for example, the table structure will contain data for example from row 500 to row 1500 (the data from 0 to 499 are deleted)
    In this way the local table model dimension will be indipendent from the real database table dimension ...
    I hope that my solution is more clear now...
    under these conditions the only solutions that can work have to implement a local tablemodel with limited dimension...
    Another solution without servlet and rmi that I have found is the following:
    update the local limited tablemodel structure quering the database server with select .... limit ... offset
    but, the select ... limit ... offset is very dangerous when the offset is high because the database server have to do a sequential scan of all previuous records ...
    with servlet (or RMI) solution instead, the entire resultset is on the server and I have only to request the data from the current resultset from row N to row N+1000 without no queries...
    Thanks

  • Moving a functional jsp and jar file to new directory breaks import?

    Simply put - how can I "move" or "copy" a functional JSP directory from the root of my site to a subdirectory
    of the same site and have it continue to work?
    here are the details:
    I have a site where the functional JSP content resides like so ...
    c:\site\itworkshere\thetestfile.jsp
    c:\site\itworkshere\WEB-INF\web.xml
    c:\site\itworkshere\lib\thejarfile.jar
    c:\site\itworkshere\classes\props.properties
    but when I copy the"itworkshere" directory to c:\site\newdirectory\itworkshere
    and try to load thetestfile.jsp page in my browser, I get ...
    thetestfile$jsp.java:6: Package com.corporatename.module.io not found in import.
    I know that the module.io classes are in thejarfile.jar, but for some reason, now that I've put the files
    in a new directory, the import is failing (simple import directive in thetestfile.jsp) And - yes - the .jar
    file is there in the new subdirectory.
    I am a newbie with jsp and just need to copy the files to new location and have them continue to work.
    Do I have to recompile the .jar with some sort of adjustments? I poked around and I don't see any assumptions about the directory structure in the build. The behavior leads me to believe that the build is assuming something
    about its location in the directory tree.
    Hope this question is clear and I appreciate any direction you can provide to steer me where to look/modify
    the necessary changes so I can move the .jsp's and .jar and not break them.

    Thanks for the suggestions and insights. I have made some progress.
    a context path of "/newdirectory/itworkshere" and a docBase of "./newdirectory/itworkshere" has resolved
    the .jsp include problem.
    However this seems a bit counter-intuitive to me considering that the default root context which is "" stands
    at the appBase which in my case is C:\Site. Since the default does not explicitly refer to the "itworkshere" directory,
    I'd expect that the newly added Context element would not have to either ---- BUT --- it does require that I include "itworkshere" in the context path and docBase (where I would expect ./newdirectory would have been sufficient since the default works that way) ... am I missing something?
    Now I havethe next odd behavior - the Servlet which resides in "itworkshere\WEB-INF\lib" is not loading when I put the appropriate URL in --> /newdirectory/itworkshere/DataCrunchingServlet
    I checked the web.xml file and it has the appropriate servlet-name and url-pattern (relative references)
    Furthermore I did a test where I simply rename the original working instance directory and again --- the URL is failing to find the servlet!!! (and yes I stopped/started Tomcat) It is as if the servlet can only be found in the originally installed scenario.
    I am extremely puzzled that the behaviors seem to indicate an assumption about the path structure, but the web.xml file is set up correctly.
    Help help!!! and Thank you.l

  • Jtable and database

    hi,
    i am using jdevlopper 10g and oracle 10g express.
    i create a database and a new connection to it.
    in the first frame, i created a new jtable and i want that it containts data from the database.
    is any one can help me.
    thanks

    Hi,
    you have two options:
    - Use ADF and ADF Swing, in which cae the database connect is through a business service (e.g. ADF Business Components or EJB)
    - Create a JDBC connection to the database and populate the JTable model with the data (which is cumbersome). You find tutorials on the web of how to do this.
    Frank

  • JTable and cell color

    Hello, hope you can help me here -
    I have a JTable, and based on the value of a certain column in a row, I want the background color of that entire row to change to a different color. How can I perform this operation?
    I have tried to override JTable's prepareRenderer, but it doesn't seem to be working.
    Any clues?
    Thanks!
    -Kirk

    Hi.
    First of all. Try searching the forum there have been plenty of posts on this subject.
    Now to answer your question of how to set the color. The trick lies in the cellrenderer.
    A JTabel contains several models internally. If I'm not mistaking the ColumnModel contains the appropriate rendere for every column. The simplest thing to do in my opinion is to use a decorator pattern on the TableCellRenderer interface. Something along the likes of this.
    import java.awt.Color;
    import java.awt.Component;
    import javax.swing.JTable;
    import javax.swing.table.TableCellRenderer;
    public class ColorTableCellRenderer implements TableCellRenderer {
    private TableCellRenderer render;
    public ColorTableCellRenderer( TableCellRenderer render ){
    this.render = render;
    * @see javax.swing.table.TableCellRenderer#getTableCellRendererComponent(javax.swing.JTable, java.lang.Object,
    * boolean, boolean, int, int)
    public Component getTableCellRendererComponent( JTable table , Object value , boolean isSelected , boolean hasFocus ,
    int row , int column ) {
    if( table != null ){ //Replace with specific condition
    Component cmp = this.render.getTableCellRendererComponent( table , value , isSelected , hasFocus , row , column );
    cmp.setBackground( Color.cyan );
    //Maybe need to call a validate or setOpaque. if experiencing problems.
    return cmp;
    }else{
    return this.render.getTableCellRendererComponent( table , value , isSelected , hasFocus , row , column );
    After that the easiest to do is set the defaultCellrenderer of your table in the following fashion.
    table.setDefaultRenderer(Object.class, new ColorTableCellRenderer( table.getDefaultRenderer(Object.class) ));
    Or this should also work.
    table.getColumnModel().getColumn(0).setCellRenderer(new ColorTableCellRenderer(chosenRenderer));
    Hope this helps & Good luck!

  • JAVA command line options -cp and -jar don't work together?

    Running JSDK 1.4.2 under Windows. I have a Java application that tries to dynamically load a class name that the user enters as follows:
    try {
    classResult = java.lang.Class.forName(strFilterName);
    catch (ExceptionInInitializerError e) {
    strErrorMessage = "ExceptionInInitializerError loading class: " + strFilterName;
    catch (LinkageError e) {
    strErrorMessage = "LinkageError loading class: " + strFilterName;
    catch (ClassNotFoundException e) {
    strErrorMessage = "ClassNotFoundException loading class: " + strFilterName;
    This works fine if the classes that make up my application are left as class files in the classpath, but fails to work if they have been collected and run from a JAR file. Note: I can even dynamically load the class when running from the JAR file, if the class I'm trying to load is within that JAR file too. The problem really occurrs when the dynamically loaded class is located someplace else in my classpath. I've tried using various combinations of the "-cp" and "-jar" Java command line options - but when loading and running from a JAR file - the "-cp" parameters seem to be ignored. Is this a bug? Has anyone ever seen this before?
    I run my program from the JAR file using this command:
    java -cp .;e:\entmgr\filters -jar EntMgr.jar
    Where "e:\entmgr\filters" is where the class I'm trying to dynamically load is. (This class has no package name, but loads perfectly as long as I'm not running the application from the JAR file). The class name specified by the user has to be fully specified with a package name (if it has one).
    I have tried forcing the "java.lang.Class.forName(strFilterName);" call to use the system class loader, the parent of the system class loaded, and even the null bootstrap class loader - all with no success.
    I am suspecting that the class loader that is loading and running my main program from the JAR file, is just not paying any attention to the "-cp" parameter when the "-jar" parameter is present. Indeed, I have never seen any change in the failure, no matter what I put in the "-cp" parameter when using the JAR file.
    When I run this without using the JAR file, here is the command I execute:
    java -cp .;davidp\snmp;filters davidp.snmp.EntMgr
    Where this is executed in a directory that has a "filters" and "davidp\snmp" directory. In this case, because the "filters" directory is in my class path - I can dynamically load my class from it using just its simple name (i.e. "TestTrapFilter").
    So, is there some bug that precludes the "-cp" parameter from working correctly when the "-jar" parameter is used? Is there some other way to initialize or set up the classloader I'm using, so it can find things outside of the JAR file I'm running from? I would hope that it is possible to get the same behavior from my program, no matter if it is run from a JAR file or not.
    Thanks for any assistence!
    Dave

    These posts are pretty old, but this page came up in a google search while I was having the same problem, so I thought I would throw my own (Later found) solution in.
    The -cp and -jar options did not work together for me, but I later learned that they didn't really have to (and you don't have to mess with jar manifest files).
    While on the command line, if you want to set a specific class path and also run a jar, all you need to do is add the jar to whatever extra class path you need to use in the -cp <arg>, and then specify which class you want run from inside the jar.
    IE:
    java -cp <YourSpecialClasspath>: <PathToJar> <ClassToRunInsideOfJar>
    in my case it was like:
    java -cp /home/user/WebRCP.jar:./StandaloneInstaller.jar InstallLoader
    Remember to put a ":" in between the two arguments for the class path (-cp).
    Hope this helps someone in the future,
    -Josh

  • JTables and Sql

    anyone know any good sites for on sql and displaying data from an sql database on a JTable. Appreciate any help. or if you know how to do it , gives us an idea.
    thanks

    i am sure once you get it out, you can handle the rest..
    put data into jTable..
    this helps you to get the data out from database..
    http://javaalmanac.com/egs/java.sql/pkg.html

  • Help, new to Linux and need help installing 8i

    I am new to Linux and some of this stuff..
    Yet,I have gotten the JDK116_v5 installed and working on my box.
    I have cut a cd for Oracle8i and need help..
    I have also recopiled my kernal as well...
    Does any one know where I can get help...
    null

    Al Pivonka (guest) wrote:
    : I am new to Linux and some of this stuff..
    : Yet,I have gotten the JDK116_v5 installed and working on
    : my box.
    : I have cut a cd for Oracle8i and need help..
    : I have also recopiled my kernal as well...
    : Does any one know where I can get help...
    Try http://www.akadia.com/html/dod-frame.html for Redhat.
    http://www.suse.de/~mha/oracle/ for SuSE
    Also peruse these
    http://www.akadia.com/html/dod-frame.html
    http://jordan.fortwayne.com/oracle/
    Colin.
    null

  • Software update and iLife help not working in Admin account

    For the last few weeks (maybe since iLife 11 was installed) software update and iLife help has quit working on the single administration account on my iMac. All works fine on the secondary accounts.
    If I try to use software update it says everything is up to date, even though I know there are updates available that can be seen if checking from a different account on the machine. In iLife, if I try to access the help files it tells me I need to download them. I click to download and after a few seconds it takes me back to the front help page and I then go through the entire process again but the help download never happens. On secondary accounts the help files work no problem.
    I've tried many of the tips for deleting helpfile plists, but nothing seems to work for me.
    Can any kind person list for me everything I should look to delete or move in the account to get these things working again?
    It would be much appreciated!

    Since the issue is specific to your original user account, you can proceed in two ways. One is to log into your new account, make a list of the preference files (plists) located in /username/Library/Preferences/, including any in the ByHost subfolder, log back into the original account, move everything on that other account's list from the original account's Preferences folder into a newly created folder on the Desktop, log out and back in, and see if the problem goes away. If so, you can copy the ones in the Desktop folder (one at time) back into /Preferences/, restart, and see if the problem returns. If so, you've identified the corrupt/conflicting one. Continue with all of them until isolating the bad ones. That'll save you the trouble of resetting preferences.
    The second way is much more detailed and I'll not burden you with the steps unless the above doesn't fix the issue.

  • JTable and clipboard...

    Hi all!
    I'm trying to copy data from JTable to system clipboard. Here's my code that is
    supposed to do that except it doesn't work. Nothing happens. The system is
    Windows, rigth click invokes menu with only one position - COPY, which is served
    by a appopriate ActionListener. I want to copy entire table (all data):
    private class NotEditableTable extends JTable
    NotEditableTable(Object[][] data, Object[] columnNames)
    super(data, columnNames);
    setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    setCellSelectionEnabled(true);
    getTableHeader().setReorderingAllowed(false);
    NotEditableTableEngine nete = new NotEditableTableEngine();
    this.addMouseListener(nete);
    public boolean isCellEditable(int row, int column)
    return false;
    private class NotEditableTableEngine extends MouseAdapter implements ActionListener
    public void mouseReleased(MouseEvent e)
    if (e.isPopupTrigger())
    JPopupMenu menu = new JPopupMenu();
    JMenuItem menuitem = new JMenuItem(Lang.TABLE_COPY, new ImageIcon("res/Copy16.gif"));
    menuitem.addActionListener(this);
    menu.add(menuitem);
    menu.show(NotEditableTable.this, e.getX(), e.getY());
    public void actionPerformed(ActionEvent e)
    TransferHandler th = new TransferHandler(null);
    NotEditableTable.this.setTransferHandler(th);
    Clipboard clip = NotEditableTable.this.getToolkit().getSystemClipboard();
    th.exportToClipboard(NotEditableTable.this, clip, TransferHandler.COPY);
    }

    I also tried the code above with a simple JTextField, both with text selected and not.Did my sample code use the TransferHandler??? The simple way to do it for a JTextField would be
    Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
    StringSelection testData = new StringSelection( textField.getText );
    //StringSelection testData = new StringSelection( textField.getSelectedText );
    c.setContents(testData, testData);
    As for the table I said that the Ctrl-C KeyStroke will invoke the default Action to copy selected data from the JTable to the Clipboard. This can be tested manually by simply using Ctrl-C. If you want to invoke it in your program then you need to get the corresponding Action from the JTable and invoke the ActionPerformed method of the Action. You can try using the
    getActionForKeyStroke(...) method of JComponent to get the Action.

  • A follow up question to Introducing Apple Recommends, Manage Subscriptions, and This Helped Me

    In Introducing Apple Recommends, Manage Subscriptions, and This Helped Me it was written
    Now anyone can click "This helped me" to say thanks to helpful members. When several people mark the same post, it will earn a gold star and appear at the top of the discussion, so it’s easier for others to find. The poster will also earn five reputation points for a job well done.
    Does anyone know (or is it written anywhere) just how many is 'serveral'? Is it decided on the fly? Or does it depend on the phase of the moon?
    Will the points be awarded to the poster only once, or if say 100 people mark it as helpful will more then 5 points be awarded?
    Sounds like a really good system but it seems that a bit more thought should have gone into it, no? Or at least the explanation could be clearer.
    Ciao.
    (Another question) Can the original post (this one) get marked as helpful also? Imagine  earning points for posting :-)

    Howdy GeoCo et al
    I sort of agree with this new "Helpie-ette" deal. I wonder why while at this portion of the UX they didn't address the ongoing issue of the "irrevocable nature " of the OP awards of the traditional Green Stamp and Gold Star - I have made the mistake (once) but I see the silliest things marked Solved frequently. THAT is bad for business in that it gives false visual info and false statistical results.
    We'll see... BTW, the [People] TAB itself is the only new thing (the CONTROL in the TAB bar) - the URL has always been alive and well if one knew to add " /people "

  • Google maps and google help not loading anymore! help!

    Google maps and google help aren't loading since I've updated firefox. Works in Chrome no problem. Tried everything listed here: https://support.mozilla.com/en-US/kb/Error%20loading%20web%20sites, re-installed flash, cleared cache, etc... what am I missing?

    Anyone have any ideas?

Maybe you are looking for

  • Get name of swf linked to an as file

    Sounds simple enough. I have a number of swfs (quiz01.swf, quiz02.swf.....) all linked to one quiz.as file. The quizes in turn are loaded by another swf, Main.swf. I need to get the name of the specific quiz that is loaded, so I can identify an exter

  • Navigation in Parent Child Hiearachy is a bug in OBIEE 11.1.1.6 ?

    Hi All, Please look into one of my earlier posts OBIEE 11g - Navigation in Parent Child Hiearchy not working One of my friends Ram told me that this is an Oracle Bug in 11.1.1.6. It's I just wanted to know if anybody has faced the same issue and repo

  • SlideShow using Indesign Scripting

    Hello... I want to convert the Indesign SlideShow file into HTML file using Indesign Javascript... In Indesign file One Enlarged image will be there and other small images will be there. When you click the small image it should display as Enlarged im

  • BIApplicationFrame UI Element

    Hi All, I have a scenario where I need to pass webdynpro context values to BI report. I use BIApplicaitonFrame UI element in my webdynpro application and I need to set the inital filters of the BEX report. I have set the properties of my BIApplicatio

  • FI posting baseline calculation is wrong.

    HI expart. in userexit_fill_xkomk1how to imlplennt for sap note -112385 for baseline calculation is wrong. What i will do for baseline calulation is coming as creation date. Thanks Dhirendra.