Printing a Vector to a JTextArea

I'm having major problems with my project.
I can't get the information retrieved from a database to print to a JTable even though i've looked at so many different tutorials.
I ended up printing the information to a JTextArea for now but i'm having problems printing a vector to the TextArea.
     Vector columnNames = new Vector();
                      Vector data = new Vector();
                      Vector cache;
                      cache = new Vector();
                      int columns;
                      String[] headers;
                         try {
                              Class.forName("com.mysql.jdbc.Driver");
                              Connection con = DriverManager.getConnection (Url);
                              Statement stmt = con.createStatement();
                              ResultSet rs = stmt.executeQuery(query);
                              ResultSetMetaData md = rs.getMetaData();
                              columns = md.getColumnCount();
                              //read names of columns
                             for (int i = 1; i <= columns; i++)
                                 columnNames.addElement( md.getColumnName(i) );
                             System.err.println(columnNames);
                             String rowdatatotal = columnNames + "\n" + "\n";
                             while (rs.next())
                                  Vector row = new Vector(columns);
                                  for (int i = 1; i <= columns; i++)
                                       row.addElement( rs.getObject(i));
                                            sqloutputArea.setText (rowdatatotal + "\n");
                                  System.out.println(row);
                            }is there a way around this?
Thank you for your time

I have tried to use toString() by doing the following.
while (rs.next())
                                 row = new Vector(columns);
                                  for (int i = 1; i <= columns; i++)
                                       row.addElement( rs.getObject(i));
                                            sqloutputArea.setText (rowdatatotal + "\n");
                                  row.toString();
                                    sqloutputArea.setText (row);Is there an alternative to addElement but for strings?
I was wondering if i changed the vectors to Strings and substituted the addElement, it might work?

Similar Messages

  • Printing problem when printing a vector based program generated pdf file

    Hi,
    I bought a software which comes with a camera auto-focus calibration chart. The manufacturer mentioned that this chart is generated by a vector base program so customers can ajust the size of chart without any problem. The chart file is in pdf format.
    When I use my Photoshop CS5 (on Windows 7) to print it from my Epson 2200 inkject printer, it only print the vector part without filling up  the inside of the vectors enclosed area to black. Even the words in the footer are printed the vectors only (without fillup the word with black).
    I'd appreciate if anyone can help pointing out what's the cause.
    Thanks,
    Eric

    I have tried to print with pdf app as well. Same result.
    I found the solution yesterday while searching on line. Ended up it's the Epson 2200 driver bug. I was using Matte Black and the driver thought it is not compatible with Epson Premium Matte paper, so it did not print with that black ink. Change back to Photo Black ink solved it.
    So case resolved. Thanks
    Eric

  • Send Vector class to JSP and print this Vector using JSTL

    Hello All!
    I need your help to solve my question.
    I developed a Servlet + jsp application.
    I tested it in local with Apache Tomcat/6.0.20 and it works correctly.
    I write and use these classes:
    class for execute query, and including data page:
    package MySQL;
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    import java.util.*;
    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    * @author initmax
    public class MySQLQuery {
        private Connection CurrentConnect; //obj for connect to databae
        private Vector VectorPageObj = new Vector(); //save array object page, after execute query
    public MySQLQuery() {}
    //constructor accept current conection database
    public MySQLQuery(Connection CurrentConnectBase)
        CurrentConnect = CurrentConnectBase;
    //method accept name table and return all info on this table
    public void SelectAllField(String NameTable)
           try
             Statement st = CurrentConnect.createStatement();
             String query = ("select * from "+NameTable);
             ResultSet resultQuery = null;
             resultQuery = st.executeQuery(query);
    //step in cycle after execution query, and create Vector object
               while (resultQuery.next())
                  GenPageMySQL PageObj = new GenPageMySQL();
                  PageObj.setId(resultQuery.getInt("id"));
                  PageObj.setTheme(resultQuery.getString("theme"));
                  PageObj.setPage(resultQuery.getString("page"));
                  VectorPageObj.add(PageObj); //add obj in tail vector
           catch (SQLException e) {
             e.printStackTrace();
        *@set the CurrentConnect
        public void setConnection(Connection CurrentConnectBase) {
             CurrentConnect = CurrentConnectBase;
        *@get Vector object "Vector created after execute query"
         public Vector getVectorPageObj(Connection CurrentConnectBase) {
             return VectorPageObj;
    }start Servlet class:
    import java.util.*;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import MySQL.*;
    public class indexServlet extends HttpServlet {
        private  String getpage;
        //Connected MySQL
        private MySQLConnect MySQLConnectObj = new MySQLConnect();
        private MySQLQuery MySQLQueryObj = new MySQLQuery();
        public void init(){
              MySQLConnectObj.DownloadDriver();
              MySQLConnectObj.Connected();
              //Use current connection, for execution query
              MySQLQueryObj.setConnection(MySQLConnectObj.GetConnection());
        protected void doGet(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException, NullPointerException  {
      //      init();
            PrintWriter out = response.getWriter();
    //GET case useer
          getpage = request.getParameter("page");
          out.print("MySQLConnectObj.GetConnection() = "+MySQLConnectObj.GetConnection()); 
    //Check curent connect to database
          if(MySQLConnectObj.GetConnection() != null)
               MySQLQueryObj.SelectAllField("up_menu");//execution query
               MySQLConnectObj.DisConnected();
                request.setAttribute("up_menu_theme",MySQLQueryObj.getVectorPageObj(null));
                RequestDispatcher Dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/jsp/index.jsp");
                Dispatcher.forward(request, response);
          else if(MySQLConnectObj.GetConnection() == null){
                init() ;
            out.print("MySQLConnectObj.GetConnection() = "+MySQLConnectObj.GetConnection());
    //        MySQLConnectObj.DisConnected();
    }I forward Vector "MySQLQueryObj.getVectorPageObj(null)" to JSP, how I can print data vector using JSTL?

    your right, I learn Java however this very Interesting!
    I change code, change Vector on List
    class MySQLQyery:
    package MySQL;
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    import java.util.*;
    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    * @author initmax
    public class MySQLQuery {
        private Connection CurrentConnect; //obj for connect to databae
    public MySQLQuery() {}
    //constructor accept current conection database
    public MySQLQuery(Connection CurrentConnectBase) {
        CurrentConnect = CurrentConnectBase;
    //method accept name table and link on List, after work return all info on this table inside List
    public List<GenPageMySQL> selectAllField(String NameTable, List<GenPageMySQL> ListPageObj) {
           try {
             Statement st = CurrentConnect.createStatement();
             String query = ("select * from "+NameTable);
             ResultSet resultQuery = null;
             resultQuery = st.executeQuery(query);
    //step in cycle after execution query, and create Vector object
               while (resultQuery.next()) {
                  GenPageMySQL PageObj = new GenPageMySQL();
                  PageObj.setId(resultQuery.getInt("id"));
                  PageObj.setTheme(resultQuery.getString("theme"));
                  PageObj.setPage(resultQuery.getString("page"));
                  ListPageObj.add(PageObj); //add obj in tail vector
           catch (SQLException e) {
             e.printStackTrace();
           return ListPageObj;
        *@set the CurrentConnect
        public void setConnection(Connection CurrentConnectBase) {
             CurrentConnect = CurrentConnectBase;
      List<GenPageMySQL> ListPageObj;
                //get List<RowObject>
                ListPageObj = MySQLQueryObj.getListPageObj();
      out.print("Size Page objects = "+ListPageObj.size());
                request.setAttribute("upMenu",ListPageObj);
                RequestDispatcher Dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/jsp/index.jsp");
                Dispatcher.forward(request, response);string out.print("Size Page objects = "+ListPageObj.size()); == worked, I get count objects correct
    How I can output fields Object GenPageMySQL in JSTL?
    writing so:
             <c:out value="hello, Max" />
             <c:out value="${10+20/2}" />
             <c:forEach items="${upMenu}" var="Object" >     
                   <c:out value="${Object.getId}"> </c:out>
             </c:forEach>
        </body>
    </html>but get error:
    org.apache.jasper.JasperException: An exception occurred processing JSP page /WEB-INF/jsp/index.jsp at line 36
    33:          <c:forEach items="${upMenu}" var="Object" >
    34:         
    35:                 
    36:                <c:out value="${Object.getId}"> </c:out>
    37:
    38:    
    39:          </c:forEach>
    Stacktrace:
         org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
         indexServlet.doGet(indexServlet.java:49)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:717)How I can in output print fields my Object?
    Thank you for your help.

  • Print out vector

    Hi
    Does anyone know how I could print out the contents of a vector in a list in a message dialogue box.
    Thanks
    Jon

    Yes. Iterate through the contents of the Vector appending the return value of their toString() method to a StringBuffer & then set this as the text of the dialog.
    Oh, you wanted a code sample? No time.

  • Scope of a non-static method printing a vector of objects

    Hello everyone,
    I'm new to using the java.util.Vector package. I wanted to create a print out of all the objects of class "Student" that I created within a "students" vector. My problem is that scope is causing a compile error when calling the print method acting on the students vector. Anybody got any ideas? Further to this I'd like to keep my printVec() generic enough so that I can create a class "Teachers" and a "teachers" array and make the the printVec() method able to print both, ie;
    teachers.printVec()
    students.printVec()My code is below;
    import java.io.*;
    import java.lang.*;
    import java.util.*;
    class Example {
       public static void main(String[] args){
          Vector<Student> students = new Vector<Student>();
          students.addElement(new Student("Billy"));
          students.addElement(new Student("Ryan"));
          students.addElement(new Student("William"));
          students.addElement(new Student("Jason"));
          //the below print algorithm works...
          for(int i=0;i<students.size();i++)
             System.out.println(i+" "+students.elementAt(i).getName());
             //however i can't get this following one to work...
    //       students.printVec();
             //uncomment above line
       public void printVec(){
    //      for(int i=0;i<students.size();i++)//uncomment these lines
    //         System.out.println(i+" "+students.elementAt(i).getName());//uncomment these lines
            //uncomment above two lines
    class Student{
       //constructors
       public Student(String name){
          this.name = name;
          this.subjectNumber = -1;
          this.tutorialNumber = -1;
       //methods
       public String getName(){
          return name;
       //fields
       private String name;
       private int subjectNumber;
       private int tutorialNumber;
    }

    You should use an Iterator, not get(). And youshould
    prefer ArrayList over Vector.Why are you telling me this? I know this already... I
    was reusing the OP's way so that he/she/it could see
    it done his/her/its way.I have no way of knowing what you do or don't know. I only saw crap code, so I corrected it.
    >
    That won't work if more than one student has thesame
    name, and it's a very counterintuitive way to
    approach the problem.Um... yes, it will work if more than one student has
    the same name. It will not work if students in the
    Vector share memory. It searches for memory, not the
    name.Actually, we're both wrong.
    If Student overrides equals to be based on name, then it won't work as I described. If not, then it will work.
    It only looks at "memory" if Student does not override equals.
    I didn't think that there would be a problem with
    memory, but if there is, simply add a counter:????
    What are you talking about?
    public static void printVec(Vector<Student> students)
    int count = 0;
    for (Student s : students) {
    System.out.println((count++) + " " +
    + " " + s.getName());
    }That's the right way to do it, but that has nothing to do with "a problem with memory."

  • How to add Vector data to JTextArea ????

    Hi All,
    I have a JTExtArea where i want Vecor data to get display.
    Suppose i have Vector data as 1,2,3,4,5 then i want these number to be displayed in JTextArea as seperate rows.
    Thanks

    How about iterating over the collection, adding each value and a line break to the text area?
    myTextArea.setText("");
    for(Iterator iterator = myVector.iterator(); iterator.hasNext(); ) {
      Object value = iterator.next();
      String text = String.valueOf(value); // or format it somehow
      myTextArea.append(text);
      myTextArea.append("\r\n");
    }Hope this helps.

  • Really need help... How to print the 'content' of a JTextArea?

    Hello, i'm currently developping a HTML Editor in java but i've got a problem with printing job... Does anyone know a simple code to print the content of a textarea by clicking on a button?
    for instance:
    JTextarea textarea = new JTextArea();
    JButton print = new JButton ();
    file_menu.add(print) ;
    print.addActionListener(
    new ActionListener()
    public void actionPerformed(ActionEvent event)
    ////----> what could i put here to print the content of my textarea named 'textarea' ?
    I've searched on the web but i didn't find it...
    Thanks very much for your help...
    Sebastien Roupin

    thank you very much for your help... i'm checking this samples...
    Sebastien Roupin

  • How to print the all content of JTextArea to several pages

    Hi there, my application have a JTextArea and user can type text in. When the jbPrint button is pressed, the all content of JTextArea should be printed to papers. But now my application can only print out the first page even the content of JTextArea is 3-page length, does anyone can give me some clue or example? Thanks in advance.!! Really hurry!!

    Use freely downloadable smart jprint classes from http://www.activetree.com. This package also allows you to print contents of any kind of JTextComponent such as JTextField, JTextArea, JEditorPane, and JTextPane.
    Print the swing components with or without showing in the UI. Line breaking is done automatically for you and prints in multiple pages.
    JTable printing is specially interesting.

  • Exporting Flash vector art for print

    I would like to export art created in Flash as a vector
    format for print. Exporting as either AI or EPS from Flash seems to
    have many limitations: no support for masks, alpha transparency, or
    editable text with fonts embedded. Has anyone found a workflow to
    create print-ready vector art using Flash?
    I have tried many combinations of Flash, Freehand, and
    Illustrator with no success. (Freehand will open SWF files, but it
    rasterizes the vector art when exporting as either EPS or PDF).
    Working in Flash Pro 8, but from the Flash CS3 documentation
    it doesn't look like there are additional options for file export.
    Is it true that any vector art exported from Flash loses font info,
    masking, and transparency?

    Has anyone found a good solution for this? I need to export character art from Flash to use for print and consumer product items. Qualtity vectors are required.
    The "best" solution I've found so far is to "Print" as either a .PDF or .PS file, then open that file in Illustrator. It expands all the gradients, and creates very complex vectors, but it's better than the standard export to .AI function, which gives offending operator "bg" errors. Still, it is a sub-par result, and I end up having to recreate art anyway.
    (I'm using Flash CS4.)
    Dear Adobe, this should be a no-brainer ... Please introduce a true vector export feature from Flash to Illustrator that generates art we can actually use.

  • Vectors printing jagged when placed over raster images

    I am fixing a previously designed flyer for a reprint. On the last print, any vector object placed on top of the raster image was very noticeably jagged. This included both white text, which simply had jagged edges, to colored text, which had white jaggies as well. Drawn vector objects and clipping paths in jpgs were also jagged.
    I used InDesign CS3 to create it, but I outlined the type, embedded all the images and exported as a .pdf (my project manager insists on this; so maybe it's not even an ID issue).
    It looks fine when I print it on my hp LaserJet 2550n or the office's Canon iR 2800i - but that's never been a good way to tell how it's going to turn out at the end.
    I know just making it all in Photoshop is probably the safest option, but I would really like to keep the sharpness of the vectors, and I've got Character/Paragraph styles etc going that would be a pain to redo in Photoshop. Plus, copy+pasting it into Photoship creates pdf/vector object that looks just as horrid (on screen - it looks the same when I print it on the above-mentioned printers, but I'm still paranoid).
    Thanks for taking the time to read this and for any help you are able to offer!
    Lisa

    Peter, thank you for your reply. I really appreciate the help.
    Generally, I use the default settings for [Press Quality], since I don't have a complete understanding of all the settings. I have appended the .txt pdf setting summary at the bottom of this post.
    I'm aware that outlining type is supposed to be unnecessary but 1) my project manager insists on it because he doesn't want to deal with any kind of font problems (maybe if this is at the root of the problem it will push him to accept it), 2) I'm using Fontin & Fontin Sans by Jos Buivenga (a high quality free font) and the ligatures/alternate characters
    sometimes don't show correctly when printed (replaced by a ?) or viewed on another computer without the font.
    Yes, I embed the images into the ID document (Links - embed images). This is only because my project manager insists on this as well. It is unnecessary to do this when saving to a .pdf, correct?
    Here are the settings I generally use when exporting a pdf to send to the printer (who do not specify any kind of settings):
    Description
    Use these settings to create Adobe PDF documents best suited for high-quality prepress printing. Created PDF documents can be opened with Acrobat and Adobe Reader 5.0 and later.
    PDF Preset: [Press Quality]
    Compatibility: Acrobat 5 (PDF 1.4)
    Standards Compliance: None
    General
    Pages: All
    Spreads: Off
    Generate Thumbnails: Off
    Optimize PDF: On
    Create Acrobat Layers: N/A
    Export Layers: Visible and Printable Layers
    Include Bookmarks: Off
    Include Hyperlinks: Off
    Export Nonprinting Objects: Off
    Export Visible Guides and Baseline Grids: Off
    Create Tagged PDF: Off
    Include Interactive Elements: Off
    Multimedia: N/A
    Compression
    Color Images
    Bicubic Downsample at: 300 ppi
    for images above: 450 ppi
    Compression: Automatic
    Tile Size: N/A
    Quality: Maximum
    Grayscale Images
    Bicubic Downsample at: 300 ppi
    for images above: 450 ppi
    Compression: Automatic
    Tile Size: N/A
    Quality: Maximum
    Monochrome Images
    Bicubic Downsample at: 1200 ppi
    for images above: 1800 ppi
    Compression: CCITT Group 4
    Compress Text and Line Art: On
    Crop Image Data to Frames: On
    Marks and Bleeds
    Crop Marks: Off
    Bleed Marks: Off
    Registration Marks: Off
    Color Bars: Off
    Page Information: Off
    Page Mark Type: Default
    Weight: 0.25 pt
    Offset: 6 pt
    Use Document Bleed Settings: Off
    Bleed Top: 0 pt
    Bleed Bottom: 0 pt
    Bleed Left: 0 pt
    Bleed Right: 0 pt
    Include Slug Area: Off
    Output
    Color Conversion: Convert to Destination (Preserve Numbers)
    Destination: Document CMYK - U.S. Web Coated (SWOP) v2
    Profile Inclusion Policy: Don't Include Profiles
    Simulate Overprint: N/A
    Output Intent Profile Name: N/A
    Output Condition: N/A
    Output Condition Identifier: N/A
    Registry Name: N/A
    Advanced
    Subset Fonts Below: 100%
    Omit PDF: Off
    Omit EPS: Off
    Omit Bitmap Images: Off
    Transparency Flattener Preset: N/A
    Ignore Spread Overrides: N/A
    Security
    N/A
    Warnings

  • Print JTextPane as vectors, not as bitmaps?

    Hi,
    I'm working on a small Swing application that allows to arrange elements like pictures, vector graphics and texts on a page and prints them. I use JTextPanes to display and print text frames. Everything works fine - but when I print (on the printer, not on the screen) one ore more JTextPanes, the whole printing seems to be no vector printing any more but a bitmap printing.
    When I print without a JTextPane, I can zoom into the printed result (let's say a PDF, otherwise zooming is hard ;-)) as deep as I want and it is always sharp. But as soon as I print any JTextPane, the whole printing (even vector elements) are not sharp any more, but the pixels can be clearly seen when zooming in.
    My only question: Is this normal? If yes, why? Or did I do something wrong, i.e. is it possible to print the contents of a JTextPane as vector glyphs too?
    Thanks!

    Please answer just that question (y/n) and I am "happy" for the moment...
    Is it right that there is no way to print a JTextPane but to paint is "as a bitmap"?
    I have a workaround: I can convert the StyledDocument to a list of AttributedString instances. When I print the AttributedStrings, everything is right (they are real vector glyphs, no bitmaps).

  • Transparent vector printing

    Hi, I have issue with print transparent vector fill with prinJob. If I print transparent png, everything works,but when I have transparent fill in vector graphics, everything behind it is not printed, but grey area (color without transparency) is printed instead. I try to print it via PDF printer to PDF first and then print PDF itself, but I have same problem. I've tested it with different printers, no printer prints transparent vector fill correctly so it seems it's Flash problem. Do you have any advice or workaround? Thank you

    If you can isolate the problem,
    try to draw your vector fill content into a bmpdata object and add it manually to the printjob.
    Similar to the way its described here: http://www.pressingquestion.com/3535910/Air-Printjob---Print-Transparent-Png-And-Text-In-V ector

  • Printing JTextArea contents

    I'm a bit confused with the Printing API, how do I print, very simply, no dealing with margins yet, the contents of a JTextArea to the printer?

    I'm working on it, but still can't figure it out...here's what I've got so far:
            PrinterJob job = PrinterJob.getPrinterJob();
            //set job to know to print the text in the JTextArea, i s'pose
            if (job.printDialog())
                try {
                    job.print();
                } catch (PrinterException e) {
                }

  • JTabbedPane and JTextArea

    I have a problem, and I can't find what I need.
    I have an application that is suppose to be an address book. I've created 26 tabs (lettered A - Z) and in each tab, I've placed a JPanel (e.g. panelA, panelB, etc) and on each panel I've placed a JTextArea and a JList . I load my data from a file into a Vector.
    Here's my dilemma, I don't know how to get my data from my Vector to my JTextArea or my JList. If I instantiate a new JList and place it on the tab, it adds it as a new JList.
    I can get the tab via getSource(), but I don't know how to access the JTextArea or the JList in the tab.
    I can sort my Vector, print it out via System.out.println's, shoot, I can even pull out specific elements that correspond to a specific letter (the person who's last name starts with "M" for instance), but getting it into the JList or putting it in the JTextArea eludes me. Any help would be greatly appreciated.

    1) Create a custom panel (MyAddressPanel). Add the JList and JTextArea to the Panel
    2) Create a couple of accessor method (getAddressList, getAddressTextArea) to access any component you add to the panel
    3) Add each panel to the tabbed pane
    Now whenever you want to access the data from a specific tab you would do something like:
    int selected = tabbedPane.getSelectedIndex()
    MyAddressPanel panel = (MyAddressPanel)tabbedPane.getComponentAt(selected);
    JList list = panel.getAddressList();
    ...

  • How to sort a object vector by its integer item ?

    hi everybody,
    [there were few topics on this in the forum, but nothing could solve my problem yet. so, please instruct me]
    I have to sort a vector which contains objects, where each object represents, different data types of values,
    ex: {obj1, obj2, obj3, ....}
    obj1---->{String name, int ID, String[] departments}
    i have to sort this vector at three times, once by name, then by ID and then by departments.
    Leaving name and department , first i want to sort the ID of each object and then re-arrange the order of objects in the array according to new order.
    what i did was, copied the vector all objects' ID values to an integer array then i sorted it using selection sort. but now i want to re-arrange the vector, but i still can't. please guide.
    here is the sort i did, and the
    int[] ID = new int[mintomaxID.size()];
              for(int i=0;i<mintomaxID.size();i++)
                   ObjectStore_initialData obj_id = (ObjectStore_initialData)mintomaxID.elementAt(i);
                   ID[i] = obj_id.getID();
              System.out.println("Before sorting array");
              for(int i=0;i<ID.length;i++)
                   System.out.println(ID);     
              System.out.println();
              int i, j, m, mi;
    for (i = 0; i < ID.length - 1; i++) {
    /* find the minimum */
    mi = i;
    for (j = i+1; j < ID.length; j++) {
    if (ID[j] < ID[mi]) {
    mi = j;
    m = ID[mi];
    /* move elements to the right */
    for (j = mi; j > i; j--) {
    ID[j] = ID[j-1];
    ID[i] = m;
    System.out.println("After sorting array");
    for(int y=0;y<ID.length;y++)
                   System.out.println(ID[y]);     
    //*****here is where i need to re-arrange the entire vector by ID.
    I do understand this is some sort of database sort type of a question. but there's no database. it's simply i just want to sort the vector.
    Thank you.

    hi camickr,
    thank you for the detailed reply. but i still don't understand somethings. i tried to read the API and look for the collections.
    i have ObjectStore_initialData class (similar to person class), so do i still have to do a comparable class out of this class ? please simplify that.
    public class ObjectStore_initialData
         String NAME;
         int ID;
         String[] DPART;     
         public ObjectStore_initialData(String name, int id, String[] departments)
              NAME=name;
              ID=id;
              DPART = departments;
    public String getName()//----
              return NAME;
    public String getID()//----
              return ID;
    public String getDpart()//----
              return DPART;
    /*next class is the interface to collect the values from the user and put all of them at once in a vector*/
    //this class is to sort the vector by ID
    public class sorter
       public sorter()
       public static void sortbyID(Vector mintomaxID)
             int[] ID = new int[mintomaxID.size()];
              for(int i=0;i<mintomaxID.size();i++)
                   ObjectStore_initialData obj_id = (ObjectStore_initialData)mintomaxID.elementAt(i);
                   ID[i] = obj_id.getID();
              System.out.println("Before sorting array");
              for(int i=0;i<ID.length;i++)
                   System.out.println(ID);     
              System.out.println();
              int i, j, m, mi;
    for (i = 0; i >< ID.length - 1; i++) {
    /* find the minimum */
    mi = i;
    for (j = i+1; j < ID.length; j++) {
    if (ID[j] < ID[mi]) {
    mi = j;
    m = ID[mi];
    /* move elements to the right */
    for (j = mi; j > i; j--) {
    ID[j] = ID[j-1];
    ID[i] = m;
    System.out.println("After sorting array");
    for(int y=0;y<ID.length;y++)
                   System.out.println(ID[y]);     
    //*****here is where i need to re-arrange the entire vector by ID.
    /*new comparable class */
    public class ObjectStore_initialData implements Comparable
         String NAME;
         int ID;
         String[] DPART;     
         public ObjectStore_initialData(String name, int id, String[] departments)
              NAME=name;
              ID=id;
              DPART = departments;
    public String getName()//----
              return NAME;
    public String getID()//----
              return ID;
    public String getDpart()//----
              return DPART;
    static class IDComparator implements Comparator
              public int compare(Object o1, Object o2)
                   ObjectStore_initialData p1 = (ObjectStore_initialData )o1;
                   ObjectStore_initialData p2 = (ObjectStore_initialData )o2;
                   return p1.getID() - p2.getID();
    /*how can i put the vector here to sort? */
    public sorter()
    public static void sortbyID(Vector mintomaxID)
    int[] ID = new int[mintomaxID.size()];
              for(int i=0;i<mintomaxID.size();i++)
                   ObjectStore_initialData obj_id = (ObjectStore_initialData)mintomaxID.elementAt(i);
                   ID[i] = obj_id.getID();
              System.out.println("Before sorting array");
              for(int i=0;i<ID.length;i++)
                   System.out.println(ID[i]);     
              System.out.println();
              int i, j, m, mi;
    for (i = 0; i >< ID.length - 1; i++) {
    /* find the minimum */
    mi = i;
    for (j = i+1; j < ID.length; j++) {
    if (ID[j] < ID[mi]) {
    mi = j;
    m = ID[mi];
    /* move elements to the right */
    for (j = mi; j > i; j--) {
    ID[j] = ID[j-1];
    ID[i] = m;
    System.out.println("After sorting array");
    for(int y=0;y<ID.length;y++)
                   System.out.println(ID[y]);     
    /* using collections to sort*/
    Collections.sort(mintomaxID, new IDComparator());
    and to check the new order i wanted to print the vector to command line.
    still it doesn't do anything.
    the url you mentioned is good as i see. but how can i implement that in my class ? please instruct and simplify. i know i just repeated the code, i didn't understand to do a comparable class in collections for this class. Please explain where i'm head to and where's my misleading point here.
    Thank you.
    Message was edited by:
    ArchiEnger.711

Maybe you are looking for

  • Getting my Sharepoint data back

    Hi, I am still working on trying to get Sharepoint back running.    I had a SQL2005 crash when a disk got full and have since been able to move the data files and get SQL to recognize the files. The SQL databases are STS_config and STS_hca4_1 but I a

  • How to convert an Image to a byte array?

    I want to make a screenshot and then convert the image to a byte of arrays so I can send it through a BufferedOutputStream. try                robot = new Robot();                screenshot = robot.createScreenCapture(new Rectangle(500,500));        

  • FTPS: Writing empty files

    Hi Gurus, I have PROXY -> XI -> File scenario and we have to use FTPS to secure the connection. I have done the following steps - 1. Imported the public key certificate from 3rd party FTP server into the Trusted CA section of the Keystore in visual A

  • My quicktime won't export sound with my movies

    Hey, I have quicktime 7 pro and have tried to convert my home movies into the MPEG-4 format(the only thing that itunes will read.(i have tried the quicktime format and that failed) All i want to do is have my sound go with the movie after i export. I

  • Server Not Found - php in CS5.5 'Live Code' Issues

    Hi I'm new to this Forum, so hello to one and all. I have just started to learn php and was lead to believe that CS5.5 would be able to let me see what was happening when I place a new bit of php in the Live View. However, all I get is an error code