Question on what class to use

I like the way JList shows stuff and how it's like a visual array. The one problem is that i don't like how it's created and edited. Is there a class like JList that allows me to display a list of data but allows me to add and remove individual items?

If you use a ListModel, like a DefaultListModel with the JList, then you can add and remove items.JList myList = new JList(); //use whatever constructor or method to fill the list
DefaultListModel myListModel = (DefaultListModel)myList.getModel(); Then you can use the List Model's methods addElement(Object o) and removeElement(Object o)

Similar Messages

  • How do you know what classes to use ?

    Hello,
    This may sound daft - but how do you know what classes to use to do a particular task ? For example to do password-related stuff - how would I know which classes are all relevant to that ? Am I supposed to buy a book on the classes as the API documentation doesn't really tell you WHEN to use which classes.

    If you're using JSP, then your password field is likely going to be implemented in HTML. So that's nothing to do with Java. (And you can't use a JPassword field in a JSP page.) But when that field comes back to your server, you may be using Java to authenticate it. Even there, the question is not yet what Java method you are going to use, but what methodology. You could have a database to authenticate against, or an LDAP directory. Or you could have the web server use its built-in authentication, which means you don't have to do any Java coding at all. And there are other ways.
    So the question before yours is, how do you know what methodology to use? Again, that comes down to experience.

  • Need to know what classes im using

    Hi i have an application which has grown very large and im hoping theres some kind of tool out there for looking at the source code and determining which classes are used.
    Does any1 know about anything which does this? Or can any1 suggest a good way of finding this out?
    Thanks

    You can use an IDE with a debugger, so you can step through your code. Most IDE's has a debugger, like JBuilder to name one.
    You can also use a profiling tool to see how many objects are being created and what methods are called etc. On windows you can run with the -Xrunhprof option, but I think you need a program to make a report out of these data. There is also something called OptimizeIt you can use. http://www.vmgear.com/

  • What class to use for date manipulation

    To get some experience in using Java, I would like to write a small application. I want users to enter their names and birth dates, and then I want to present the number of days they have been walking around on this planet. Furthermore, I want to present the dates when the number of days will be a nice quantity ("On February 1st, 2007 your day age will be 10.000 days", or something like that).
    To calculate the number of days, I have to do some date manipulation. Now I am wondering what date-related classes I should use. Of course, there is Date, but in the API specification, I see 'deprecated' for a lot of methods. Does this mean that the use of Date is discouraged, and/or should be avoided?
    Then, there is a class Calendar, but that's an abstract class. Thus, I cannot create a Calendar object when a user has entered his birth date (in a Swing JTextField).
    The use of GregorianCalendar seems a bit far-fetched to me, but maybe I am wrong.
    In short, when a user has entered his birth date, I want to store it in some date-like object, and I want to be able to do some arithmetic based on that object.
    Can anyone give me some clues?
    Ewout

    > The use of GregorianCalendar seems a bit far-fetched
    to me, but maybe I am wrong.
    Yes, that's the way to go.

  • OOP question: self contained class or use of "external" typedefs...

    Hi all,
    I am trying my first steps into Labview OOP and am currently thinking on how to best proceed.
    I have an existing RT application running on a CRIO system that has as one of its components,
    a multi channel analyzer (MCA8000).
    I thought this would be a good candidate for my first LV class since the vi's I curently have for this MCA
    are all connected via a rather large cluster with sub-clusters to store status information and so on for
    this device. Exactly the kind of data which is better defined as private within a class!
    In the currently working code for the whole intrument (non-OOP) I use several queues to send commands
    to indivudal loops of the software and one general message and error logging queue.
    In the code I want to re-implement as OOP for the MCA I use data queues and the "general" logging
    queue of the main program. These queues are all typedefed in the main program.
    So instead of error in's and out's I have the typedefed logging queue as input and errors are logged there
    when they occur. Not sure if this is good practice but this is a good way to let the user know of errors that occur
    on the RT target since the queued log "entries" are all sent to the UI which runs on a laptop.
    The MCA specific queue typedefs I can include into the class project so that they are part of the MCA class.
    What I am not sure about is how to handle the "general" logging queue since it is also used elsewhere in the main
    program. And I am not "yet" planning of re-implementing the whole thing using oop, I wanted to start with a small
    overseeable project.
    In a fully OOP project I would probably define the logging queue in a parent class if I understand OOP correctly?
    Sorry, I am rather new to LV OOP so I might be asking something obvious...
    Olaf

    If you are really planning on implementing your OOP in pieces I would recommend attacking it from the most common and shared items first. So, start with your logs, error processing and messaging components. These are the types of things that will get used by your higher level classes. They also tend to be a bit more self contained and easier to start with.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • Question on what apps to use

    hiya it is my first time to buy a Nokia 5800 Xpress Music and i wanted to ask of any free apps for the following:
    1. Gmail or Yahoo
    2. Facebook and/or Twitter
    3. Integrated Chat service (like Meebo on Android)
    4. Wikipedia
    5. Dictionary
    6. World weather
    7. Converter (currency, weight, distance, etc.)

    If you use a ListModel, like a DefaultListModel with the JList, then you can add and remove items.JList myList = new JList(); //use whatever constructor or method to fill the list
    DefaultListModel myListModel = (DefaultListModel)myList.getModel(); Then you can use the List Model's methods addElement(Object o) and removeElement(Object o)

  • Hi i was a member of mobile me and i have i disk app on my mobile so the question is what do i use to replace i disk as it does not work on my phone as they have closed mobile me

    Hi i have a idisk app on my i phone and i cannot access it now since mobile me has close (shut down) in England
    so is there a new app for the iphone whick replaces the i disk app help

    http://www.peachpit.com/articles/article.aspx?p=1751378

  • What are the uses of Void wrapper class?

    Hi,
    Similar to other Wrappers, Void is a wrapper class for the primitive ' void ' . We all know that Void is a final class , we can't instantiate it.
    My Question is what are the uses of Void?
    thanks,

    kajbj wrote:
    I have at times used it in reflection and jmx.I have used them with SwingWorker if I didn't have anything interesting to return. There is also an example in the tutorial: [http://java.sun.com/docs/books/tutorial/uiswing/concurrency/simple.html]

  • What are you using as a Flash replacement for 64-bit machines?

    Hi,
    I was reading about the vulnerabilities in Adobe's Flash and decided to remove the offending package. I opened Chromium to make sure my Flash still worked, as I understood that Chromium implemented another method for rendering Flash stuff. I was wrong. For example, YouTube tells me that I need Flash 10 or higher. I tried to re-install the flashplugin package, but it is no longer in the repos.
    I can live without Flash content, but it's nice to have.
    So the question is, what are you using instead, that can be installed from the main repos?
    Many thanks,
    Chris.

    I have installed both lightspark 0.4.3 and gnash 0.8.8, since lightspark should be able to 'fall back to gnash for older videos' (see changelog of lightspark).
    I have tried some flash-websites in firefox and all of them seem to use gnash and there was 1 website that didn't load the content (www.deredactie.be - our national tvstation). So, I'm under the impression that lightspark is not used by firefox.
    Has anyone found out how to do this?
    Secondly, gnash should be able to use VA-API (hardware acceleration). Is it just a question to install libva and let gnash do the rest, or does one have to recompile gnash to build the support in?
    Zl.
    PS: to whoever thinks flashplugin is the 'real flash': gnash has beaten it in terms of providing hardware acceleration. hooray for opensource!

  • What classes should I use to send/receive bytes inmediately?

    What classes should I use to send/receive bytes inmediately? I mean, without using any buffers or whatever (I will implement this on my app), just the faster method.
    Is InputStream/OutputStream the lowest level choice?
    Thanks!

    Hi!
    Thank you very much for your help, I appreciate it a lot.
    While I test my server, I execute ping www.myclienthost.com -t (my client games are in other office, in the same building, but different ISP) and I don't see anything strange, so I guess network is working perfectly. However, if I use wireshark (sniffer) and I see that my system fails (server does not send acks so client disconnects) is because my acks messages are not sended for 6 o 7 seconds (it should send them every 2 or 3). It seems thread is blocked. and after 6 or 7 seconds one message with 2 or 3 acks together is sent. So, I see that the thread handler blocked for a few seconds and this is doing my server is failing. Why client handler thread on my server is blocked? One question: every 2 or 3 seconds I have a thread that uses sleep that iterates thru client handlers and takes OutputStream and send one ack message for every client handler. My question is, in client handler class I have a method called SendInfo(String whatever) which encrypts and sends through OutputStream, should I protectd this method from accesing from two threads??? as acks thread and client thread can access at the same time. Could this be the problem??
    EDIT: In my previous post I forgot to say what I found out with wireshark. Here I explain it. Sorry.
    By the way, how can I debug threads?? I would like to know if my client thread is blocked in that critical moment.
    Thanks a lot for your ideas and sorry for my English.
    Edited by: Ricardo_Ruiz_Lopez on Jan 22, 2009 7:38 AM

  • What Classes do you use for developing Database Applications

    Hi ! (sorry for my bad english)
    I develop now an application for production planning and I use an informix database-server. I have no problems with the database an the connection. I,m a database expert, but I,m a newcommer in java. What classes do you use to develop a database application ? (specially Table Handling) I tried it with JTable and AbstractTableModel. Are there better possibilities ?
    JdbTable OR
    JTable with DBTableModel OR
    JTable with DBTableModel and DataSet
    I know that this is a big question, but some little Informations can help me. (I develop with JBuilder Proffessional)
    Thank you for your help.
    Wolfgang

    No - the classes you have described (AbstractTableModel etc) are Swing classes - that is, they are Models in the MVC GUI architecture. Database-related stuff (SQL at any rate) is contained in the packages java.sql and javax.sql - The latter is part of the Enterprise addition. You would also need to purchase a database driver (or use the sun one, which is something like com.sun.odbc.jdbc.Driver or whatever). The driver supplies you with connections to the database (java.sql.Connection).
    Alternatively, you may be deploying code in a J2EE AppServer (eg. WebLogic, WebSphere etc) in which case you can use the JNDI to get a javax.sql.DataSource object (by setting one up in the AppServer and doing a lookup on it) and use this to get database Connections.
      Class c = Class.forName("com.sybase.jdbc2.jdbc.SybDriver");
      SybDriver sybDriver = (SybDriver) c.newInstance();
      java.sql.DriverManager.registerDriver((Driver) sybDriver);
      //then use Driver object to get hold of a Connection
      //or alternatively using DataSources
      InitialContext ctx = new InitialContext();
      DataSource ds = (DataSource) ctx.lookup("jdbc/MyDriver");
      Connection conn = null;
      try{
        Connection conn = ds.getConnection("login", "password");
        Statement stmt = conn.createStatement();
        ResultSet rs = stmt.executeQuery("select * from MY_TABLE");
        while (rs.next()) {
          //columns are enumerated 1...n
          String s = rs.getString(1);
          //or can get by Col Name
          String str = rs.getString("name_col");
      } finally {
        conn.close();
      }Anyway, I hope this helps - you'll probably need to get a book on it (Java Enterprise by O'Reilly is a good one)

  • Can anyone answer this question? What is used to format a string so that it falls into a certain Row/Column in excel? see text for indepth question.

    I'm attaching a file that may help. Just remember this is my FIRST attempt at using NI/FeildPoint so things that would be obvious to the normal users more than likely would slide right by me. So I'll try and explain what the text contains as to make my problem more clear. I'm using a FP-1000, FP-AI-100, and a FP-TB-10. i'm creating a application where I'm using the 8 channels from the FP-AI-100 to monitor a control system ,that we manufacture. The control system is in an environmental chamber. I use the FP-TB-10 to monitor the temperature while in the chamber. The control system is ran for 4 hours under varing enviromental conditions while I monitor vital system voltages with the FP-AI-100. Now the application that i'm building starts with the obvious FP CREATE.VI and so forth I have no problem communicating with the FP's, but the information that I'm monitioring needs to be placed into a file with Headers describing the information below it. Now I use a "WHILE LOOP.VI" to monitor the FP-AI-100 & FP-TB-10 for the 4 hour period. but before that I create and open a file where I use a "CONCATENATE STRINGS.VI" to enter the headers I need. I do this by CONSTANTS, CONTROLS, TABs, AND CARRIAGE RETURN being entered into the "CONCATENATE STRINGS.VI" in the order I want them to appear. I use ROW 1 to enter (OPERATOR:with a CONSTANT) an a (CONTROL so the operator may enter his name and be recorded into the file) using a TAB to seperate Columns and a CARRIAGE RETURNto drop down to ROW 2 for the next headers. I use header names and TABs to seperate the columns. This part works great. I end up with ROW 1 having the operator information then ROW 2 having the headers for all the channels I'm using to monitor the control system with in their own column. The trouble happens when I write to this file during the "WHILE LOOP". The information recorded for DATE:, TIME:, and Channel 0 of the FP-AI-100 end up right under their corresponding header on ROW 3, but the rest of the data ends up on ROW 4 in column 3 and goes down many rows with some of the data not being stored at all. It varies on how many rows are used starting at ROW 4 but hey always stay in column 3. I use the "FP READ.VI" outputing to a "ARRAY TO SPREADSHEET STRING.VI" outputing to a "CONCATENATE STRINGS.VI" for each channel within the "WHILE LOOP" then into the "WRITE.VI". I use the "CONCATENATE STRINGS.VI" to place my data OR atleast I thought you could do that some how I'm not quit doing something write either there is a sampling/timing issue or writing to file issue where things are being confused in the "WHILE LOOP" if someone know a better route to perform what I'm tring here I would be interested. Its not like I'm not giving it the old colledge try here but without proper training and the vagness of the manuals it's difficult to understand what every connection actually does.I'm tring though for everyone who happens to fill pity for me
    Thanks for your help
    John Morris
    Glendinning Marine Product, Inc.
    Attachments:
    ALLchannels ‏273 KB

    > I appreciate your effort to help me, but there is still a slight cloud
    > in front of my eyes here.(I must mention that I'm using Labview 5.1
    Oh, to bad. I'm using LV 6,02 and tried to save the application as LV5.1,
    but it didn't work.
    > Lets start with the easy one which is the SECOND main thing you
    > wanted to mention. In my application I used individual Create Tag.vi's
    > "so your saying that I can use just one Create Tag.vi and one Read.vi
    > and what ever I use to display the values will automatically to show
    > the individual channels" in other words if I use a "Indicator(DBL)"
    > comming out of the Read.vi what ever I use in the "PANEL" layout will
    > expand to show all 8 channel if I was using a FP-AI-100? Cool...
    Allmost right. The 8 channels come out as 1D-array, ch0...ch7.
    > #1--How do I change the delimiter (TAB) to a delimiter (comma) in a
    > Array to Spreadsheet String.vi?
    > ...cut
    I don't use this Spreadsheet VI, because files coming out there allways
    start this time consuming EXCEL wizzard. Because of this, I programmed my
    own CSV-conversion vi. Maybe you could just use a common texteditor, like
    wordpad and put the csv-examples from my last reply down to a text file
    and rename it to *.csv. Texteditors terminate lines with "\r\n" by
    default, so this is a very quick way for testing.
    > FP_Analog_Logging example to record all eight channels it uses a Array
    I didn't find the vi you metione above, but there is another good one:
    Look at examples\FieldPoint\DataLogging\FP Logger.vi.
    In a little case structure, at "false", there is a function called "Format
    into string".
    Pop up on the format string and adjust >>'\' Codes Display<<.
    Then you change the format string into: %.;%-f%s
    A Tab string is connected to the lower input of this function. Replace
    this one with a comma.
    That should do.
    >
    > #2--If using just one Create Tag.vi and one Read.vi and I have the
    > Item Name listed as ALL I take it that the information comming out of
    > the Read.vi is data for each channel in a String format starting with
    > channel 0 and ending with channel 7 for the FP-AI-100.
    Yes, just as explained above. If you put a indicator at the output to
    display the values, you can expand the display to show all 8 channels, but
    you can't name induvidual cells. In a array, all cells have identical
    named labels. If you want to name the individually, you have to attach the
    array to cluster function and put the indicator after this one. Enable
    labe display and name the output values individually.
    > #3--Now I use the following to "Format String" in the Array to
    > Spreadsheet string.vi (%.4f)but I don't see anyway of changing the
    > delimiter from (TAB) to (COMA)
    Explained above.
    > #4 you stated text strings need a "as prefix and sufix" and each
    > string is seperated by a coma, a period is used as decimal number
    > separator and lines have to be terminated by my question is
    > WHERE IS THIS ACCOMPLISHED? WHAT VI OR WHAT CONNECTOR PIN?
    Well, modifying strings are done with string functions.
    Above, as I explained how the sample FP Logger.vi can be modified to do
    the job for numbers. The pre- and suffixing with ", you only need for
    strings, which EXCEL should interpret a string and as nothing else as a
    string, even if there's a number inside. You usually need this only for
    headers. So its easyest, if you just write your string into a string
    constant or control and concatenate it to the previous csv-file contents.
    Oh, I just see by looking at the above mentioned example... Inside the
    case structure, but in the "true" case, there are error messages
    concatenated to the logfile. At this point it is importent, to use " for
    integrating the message into the CSV file, because a error message usually
    looks like this: >> ERROR 2345 in vi yxz <<
    Here you have text and number strings mixed in one line. EXCEL does not
    know, if it should interpret the number inside the error line as separate
    number, separating the line into three colums i.e. string before number,
    number and string after number. So tell EXCEL by putting a " before and
    after the line each.
    For this, expand the Format To String function by one input, move down all
    connections, to be able to insert a string constant with a " to the first
    argument connector. Change the contents of the string constant at the
    bottom argument from tab to ", (quotation mark AND comma)
    > #5 You gave me an example of what a 3 column header could look like:
    > "col0","col1","col2"\r\n Now is this something that you enter
    > somewhere cause I know that \r is carriage return and \n is newline so
    > I take it that the above is entered somewhere maybe in the Write.vi to
    > the connector called Header (F)? See this is what confuses me because
    > NI manuals have no examples of certain connectors types being used or
    > any reference as to how they manipluate data with there varing type
    > inputs. Or maybe I'm just missing them.
    The example I mentioned above help here to.
    Look at the Write File function. This function receves data from a
    function named concatenate strings. Expand this function to have one more
    spare input at the bottom. Create a string constant. Switch the constant
    display to "\" mode. Enter "col0","col1","col2"\r\n into the constant.
    Connect the constant to the spare input.
    Doing this, every dataline in the csv file is followed by
    "col0","col1","col2"\r\n .
    I wish you a nice weekend,
    Rainer Ehrt

  • TS3297 I have an iPhone and recently bought an iPod 4 touch what l am using the same apple ID for. The iPod won't let me download songs from iTunes it is asking me security questions which I don't think I have put answers to in the first place.

    I have an iPhone and recently bought an iPod 4 touch what l am using the same apple ID for. The iPod won't let me download songs from iTunes it is asking me security questions which I don't think I have put answers to in the first place, because of this it won't let me buy any songs on iTunes

    It's probably asking you to verify the security code found on the back of your credit card.
    Regards.

  • Why class builder allows to develop abstract final class ? What is the use of such class in ABAP?

    I am new to ABAP. I tried creating abstract class and found that class builder allows development of abstract final class. What is the use of such class in ABAP?

    Hi,
    Does not compile:
    This one do:
    Inheritance:
    Regards.

  • Can't reset password for apple ID I use for iCloud because email is no longer in use and cite refuses to accept answer to security question. What do I do?

    I can't reset the password for the apple id I use for iCloud because the associated email address is no longer in use and the site does not accept my answer to the security question. What should I do?

    Welcome to the Apple Community.
    If you don't receive a reset email or you don't have a rescue address, you should contact AppleCare who will initially try to assist you with a reset email or if unsuccessful will pass you to the security team to reset your account/security questions for you.
    If you are in a region that doesn't have international telephone support try contacting Apple through iTunes Store Support.

Maybe you are looking for

  • How to use function for 'date' - 30 mins?

    Hi, I need to subtract 30 mins from date-time and display value in report? Any function? Thanks! Edited by: user12427117 on Mar 11, 2011 10:20 AM

  • Large LDAP directories ( 10K users)

    Anyone used LDAP with very large directories? I'm experiencing a problem with my directory. When I connect the LDAP Realm to a small directory (by changing the root) the Realm works normally. However, when I connect the realm to a directory service w

  • ITunes hangs during sync "Transferring Purchases"

    I can no longer sync my iPhone. It starts out OK and then says "Transferring Purchases from Joe's iPhone. Copying HoldEm". It then shows abour 10% on the progress bar and sits there forever. I've tried everything I know but can't seem to get around t

  • Weblogic 10 - application deployment error: Exception is: "File too large"

    I posted this in Weblogic -> general but realise is should have really gone here as it's about admin server/deployment services setup / configuration. I am using weblogic application server 10 in a weblogic clustered enviornment. I am trying to deplo

  • Upgrade to flash on kindle fire

    I've tried to download this and have even picked every option yet it's still saying not installed and I can't watch any videos on YouTube help please