Can't get jlist to view in table

HI Everyone,
Im a newbie at java swing and I was attempting to put a jlist in a column however it is just showing me the position. Can anyone help on this, its fairly simple probably. I just been looking at this all day however, lol...
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
public class TableRowColumn extends JFrame
     private final static String LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
     JTable table;
     DefaultTableModel model;
     JPanel buttonPanel;
     JButton button;
Vector tmp=new Vector();
JList some=new JList();
     public TableRowColumn()
          // Create table
tmp=new Vector();
String[] sdata2={"stock1","stock2"};
//tmp.addElement(sdata2);
some=new JList(sdata2);
          Object[][] data = { {"1",some }, {"2", "C"}, {"3", "D"} };
          String[] columnNames = {"Number","Letter"};
          model = new DefaultTableModel(data, columnNames);
          table = new JTable(model);
          table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
          // Add table and a Button panel to the frame
          JScrollPane scrollPane = new JScrollPane( table );
          getContentPane().add( scrollPane );
          buttonPanel = new JPanel();
          getContentPane().add( buttonPanel, BorderLayout.SOUTH );
          button = new JButton( "Add Row" );
          buttonPanel.add( button );
          button.addActionListener( new ActionListener()
               public void actionPerformed(ActionEvent e)
                    model.addRow( createRow() );
                    int row = table.getRowCount() - 1;
                    table.changeSelection(row, 0, false, false);
                    table.requestFocusInWindow();
          button = new JButton( "Insert Row" );
          buttonPanel.add( button );
          button.addActionListener( new ActionListener()
               public void actionPerformed(ActionEvent e)
                    model.insertRow( 0, createRow() );
                    table.changeSelection(0, 0, false, false);
                    table.requestFocusInWindow();
          button = new JButton( "Empty Row" );
          buttonPanel.add( button );
          button.addActionListener( new ActionListener()
               public void actionPerformed(ActionEvent e)
                    model.setRowCount( model.getRowCount() + 1 );
                    int row = table.getRowCount() - 1;
                    table.changeSelection(row, 0, false, false);
                    table.requestFocusInWindow();
          button = new JButton( "Add Column" );
          buttonPanel.add( button );
          button.addActionListener( new ActionListener()
               public void actionPerformed(ActionEvent e)
                    String header = "Col" + (table.getColumnCount() + 1);
                    model.addColumn( header );
                    table.requestFocusInWindow();
          button = new JButton( "Add Column & Data" );
          buttonPanel.add( button );
          button.addActionListener( new ActionListener()
               public void actionPerformed(ActionEvent e)
                    String header = "Col" + (table.getColumnCount() + 1);
                    int rows = table.getRowCount();
                    String[] values = new String[rows];
                    for (int j = 0; j < rows; j++)
                         values[j] = Integer.toString(j);
                    model.addColumn( header, values );
                    table.requestFocusInWindow();
          button = new JButton( "Add Column - No Reordering" );
          buttonPanel.add( button );
          button.addActionListener( new ActionListener()
               public void actionPerformed(ActionEvent e)
                    // Use this method when you don't want existing columns
                    // to be rebuilt from the model.
                    // (ie. moved columns will not be reordered)
                    table.setAutoCreateColumnsFromModel( false );
                    String header = "Col" + (table.getColumnCount() + 1);
                    model.addColumn( header );
                    // AutoCreate is turned off so create table column here
                    TableColumn column = new TableColumn( table.getColumnCount() );
                    column.setHeaderValue( header );
                    table.addColumn( column );
                    // These won't work once setAutoCreate... has been set to false
                    buttonPanel.getComponent(3).setEnabled( false );
                    buttonPanel.getComponent(4).setEnabled( false );
                    table.requestFocusInWindow();
          button = new JButton( "Remove Last Column" );
          buttonPanel.add( button );
          button.addActionListener( new ActionListener()
               public void actionPerformed(ActionEvent e)
                    int columns = model.getColumnCount();
                    if (columns > 0)
                         if (!table.getAutoCreateColumnsFromModel())
                              int view =
                                   table.convertColumnIndexToView(columns - 1);
                              TableColumn column =
                                   table.getColumnModel().getColumn(view);
                              table.getColumnModel().removeColumn( column );
                         model.setColumnCount( columns - 1 );
                    table.requestFocusInWindow();
     private Object[] createRow()
          Object[] newRow = new Object[2];
          int row = table.getRowCount() + 1;
          newRow[0] = Integer.toString( row );
          newRow[1] = LETTERS.substring(row-1, row);
          return newRow;
     public static void main(String[] args)
          TableRowColumn frame = new TableRowColumn();
          frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
          frame.pack();
          frame.setLocationRelativeTo( null );
          frame.setVisible(true);
}

Yes, but you forgot to extend JList or JBoxList (whatever that is).
You would return this from the getTableCellRendererComponent method.
Of course, you would have to initialize the JList to whatever.
You also need to keep in mind that a cell renderer is just that: a renderer. It's like taking a screenshot of the component and drawing it into the table cell. It doesn't put an actual list component in the cell. So you aren't going to be able to just click on list items. You'd have to swap for a cell editor that is the same list to do that. Or do some fancy mouse event handling tricks.
It's a royal pain, but you might want to rethink doing it.

Similar Messages

  • How can I get the old view of iCal back on my MacBook Pro and iPhone?

    How can I get the old view of iCal back on my MacBook Pro and iPhone?  The Mavrick version is crisp and clean but a colored dot is not the same as a highlighted word. I rely on my iCal on my MacBook Pro and iPhone 5 to help me track which of the 8 sites I visit for my job during the week - the color coding is (was key) to organizing and tracking meetings.  I hate the upgrade! 

    If purchased through the Mac App Store then it can be installed on up to five authorized CPUs. Otherwise, it's controlled by the license that came with the software.
    To install on another computer copy the downloaded installer application to the other computer.

  • Help! can i get a tree view component used in jsp ,urgent!!

    hello all
    can i get a tree view component can be used in jsp ,it gets children data from database only when user expand one node, and it must be able to add nodes or removes node by user,so i can do some post handler in my database.
    regards!

    Where did you get this tree view component?

  • How can I get a list view after selecting "see all"?

    I just updated to iTunes 12.  I've looked on the net for this but couldn't find anything on it.
    Previously when I searched for something in the iTunes store I'd pick a certain category of media (podcasts, for example).  It would give me the first few results and then I could select "see all."  Then get a list view and sort it.
    Now when I click on "see all" I get an album cover view.  NOT a list view.  And I have no way to sort the results.  I usually sort by time.
    What's odd is when I'm still on the initial page you get after making a search I *can* sort the results.  But only the first 10.
    Basically, I need a way to sort all of my search results by time.  Either after selecting "see all" or having iTunes show many more than 10 results.
    This was possible (and the default, I think) in previous versions.  I've looked through every menu and I don't see a way to turn this functionality back on.
    Thanks.

    Hi,
    There is no such PowerShell command can achiev this. Maybe you can use a script to get the user name with folder redirection enabled. However, I am not familiar with writing script, and it would be better for you to ask in script forum below for professional
    assistance:
    http://social.technet.microsoft.com/Forums/en-US/home?forum=ITCG&filter=alltypes&sort=lastpostdesc
    Best Regards,
    Mandy
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected]

  • Where can i get   SALES  ORGANIZATION    FIELD and TABLE

    Can anybody tell me   where can i get   FIELD  and   TABLE  Name   OF  " sales organization    "

    Dear Sandeep,
    u will find VKORG is the Sales Organisation .
    u will find this Field in every related SD Module Table...
    Like ...VBAP,BKPF ..etc..
    Hope it helps...!!!
    Pls reward if Helpful...!!!

  • Can't get rid of prefixes in Table of Contents

    Doing a table of contens for a book with 12 chapters. Mostly it works fine but one thing I can't get right: most of the entries work fine but some appear with prefixes, as in "Ch_5:102.
    I can't get rid of them. I have gone to the made sure that no prefix is entered in the numbering options for that chapter. I have done "Update Numbering" several times.  What else can I try.
    I'm also confused about how to select the correct TOC styles for different headings in my chapters. In the chapters, I have styles "Heading One" "Heading Two" etc. and I want to associate them with styles TOC One, TOC Two, etc. but I find it a bit confusing.
    Thanks

    Cambot:
    Whether the responses on these forums solve your problems or not, realize that all participants here are volunteers, and with a few occasional exceptions, they are not Adobe employees.
    Everyone who uses email and mailing lists, sooner or later, comes to realize that it's possible to write or read messages in a way that may seem to be an insult. Just because it may seem so, doesn't make it so.
    It is possible to write insults on purpose. Sometimes they're sent in reply to a posting or reponse that's misinterpreted as a slight. It's always a good idea to respond by asking if it was intentional.
    The only discipline that's applied to participants who post intentional insults is that nobody pays attention to the particular posting, and forever after most sincere list participants simply ignore posts by that person.
    In other words, if you need help and want help, be helpful yourself. If the help that's offered isn't successful, it's not from lack of sincere efforts by those on the forum.
    HTH
    Regards,
    Peter Gold
    KnowHow ProServices

  • In Mail, my preview of incoming emails changed to one line only.  How can I get the bigger view?

    My view of emails has changed suddenly to only one line.  It used to be a bigger window, allowing me to read part of the body of the email, while viewing all new emails....how can I get that view back?  Is that a long header?  I try to click on long header but it is greyed out and unavailable even though I added the long header icon to my task bar.  Help??

    Hello Macdaddy and thanks for your prompt response.  Unfortunately for some reason, when I go to View, from Preferences, there is no PREVIEW, nor option for desired number of lines, option there at all?  Not sure why?  Any other ideas?  Thanks SO much for your attention to this issue of mine.

  • How can I get rid of Global Temp Table

    Hello,
    I've been writing PL/SQL stored proc for creating reports on VB.NET front end. Until now, I've been using session specific global temp table to store intermediate results and at the end I pass the result set to .NET via reference cursor. The reports are created by simply binding the ref cursor result sets to .NET grids. It's been working fine, but I am kind of bothered by the temp tables. I looked on other options, but couldn't really come up with one.
    Can somebody suggest me how I can get rid of those temp tables? Thanks,

    Tubby, that's exactly I was trying to do. I think that table type has to be defined in database, not within PL/SQL. How can I create that table of user defined record type? I tried that, but it doesn't allow me. I think I am missing something. For example,
    create type group_t is record
    (A varchar2,
    B number,
    C number)
    now inside sp, i have something like:
    type my_group is table of group_t index by binary_integer
    now I have sp cursor as
    cursor cur_test IS 'ABC' as A, 1 as B, 5 as C
    now i do something like this. My original queries are longer and much more complicated so please don't suggest you can directly open ref cursor for this query.
    FETCH cur_test BULK COLLECT INTO my_group;
    Then I do all the processing, calculations, totals, sub-totals, and insert into temp table and return via ref cursor.
    My problem is I can't directly fetch into the above table you mentioned. How should I go about in this situation?
    Maybe I should STOP thinking about this approach and just do whatever I've been doing or solve it through pure SQL. However, there are tons of problems with pure SQL approach.

  • How can I get a split view of Skype?

    I am running a Windows 8.1 laptop.  The Skype version it came with allowed me to have a split view so that Skype was always visible (I put it on the right side of my screen).  I just upgraded to the new version as Skype told me I had to do so.  Now I cannot find a way to get the split view again.  I want my normal browser to take roughly 80% of the screen leaving the remainder on the right of the screen for Skype.  How can I do this?

    I have the same issue, hope there is a response soon.

  • Where can i get Adobe SVG viewer

    Hi All,
    currently i am with SAP Netweaver EP7.0 WebApplication Server, I want to design the user interface by using visual composer.
    when I open the visual composer browser, i got an error like
    (Design board not shown, install the adobe SVG viewer).
    could anybody help me to rectify this, where can i get the Adobe SVG viewer and how can i install.

    you have to install on client side .
    Before you log on to and work with VC story board, you should check that your VC client machine meets the following software requirements.
    1. IE 6.0 SP1 or higher
    2. Microsoft XML Parser 4.0
    3.Adobe SVG viewer 3.0 or higher
    4. adobe flash pug-in
    Regards
    Sree
    NT:-- Please give points if it helps

  • Can't get a delimiter between Reapting Table Fields using the Double Eval formula.

    I have a problem in setting up the "Double Eval" formula, for a repeating table field.
    Background:
    I have a multiple-selection list box in an InforPath (2010) form. I want to concat all selected values in the list box and display them in a textbox with ";" as delimiter. I've gotten so far that with rules running when the list box is updated, the
    textbox content is updated listing the IDs of the selected items (I'm not sure yet if I want to display the IDs or make a lookup for the true text values, but that's another issue for later...).
    Problem:
    My problem is that I can't get the delimiter between the values. They are all listed in sequence with the ";" delimiter only at the end.
    I use the following formula ("Required" is the repeating field)
    eval(eval(Required; 'concat(., ";")'); "..")
    and get the following result:
    What I want to get into the comments text box is the string "684;239;91;".
    Any ideas what's wrong with my formula?
    (Using InforPath 2010 on a list published to SharePoint 2010.)

    Additional info that maybe is important to know:
    The multiple-selection list box is getting its values from a secondary data connection using a web service call:
    http://MySite/_vti_bin/ListData.svc/MyList?$filter=((CT%20eq%20'Product')%20and%20(CompGroup%20ne%20'OS'))&$orderby=Title
    The selections in my list box is yet stored in the field "Required" in a different SharePoint list, we can call it "BaseList", at the same site ("MySite").
    So to summerize:
    List 1: MySite/MyList
    Fields: CT, CompGroup, Title
    List 2: MySite/BaseList
    Fields: Required
    The different lists have more fields of course, but no need to list them all.

  • Not happy with Calendar View - Can we get a weekly view?

    There seems to be no in-between for the calendar view. You can look at the monthly view which shows no detail, or you can look at the daily view which gives you only one day. List view skips days where you have no entries. There must be a graphical way to see what you have going on for the week. Anyone have any ideas? Could this be a future plug-in app?

    Request it here:
    http://www.apple.com/feedback/iphone.html

  • Can OGG extract from a View to Table

    Dear guru,
    We have an view to get data from many table. And now we need to get synchronize data from that view to other table.
    So, can OGG extract data from a view ? I try use VIEW schema.Viewname in extract file but not success.
    Many thanks guy
    Ch

    chuongnh wrote:
    Dear guru,
    We have an view to get data from many table. And now we need to get synchronize data from that view to other table.
    So, can OGG extract data from a view ? I try use VIEW schema.Viewname in extract file but not success.
    Many thanks guy
    ChNo, a view is just a stored query. Goldengate Extract will capture the changes happening to data on tables.

  • How Can i get the data From A Table that use DefaultTableModel

    Hi and sorry for my bad english. The problem that i have is that i used this code to fill a table. Now i want when i select a row and click in a button , get the value of that row that i select so then i can update or delete that data in my dataBasesServer.
    private void consulta(){
              Connection c = ConectarSQL.conexionSQL();
              try {
                   Statement s = c.createStatement();
                   ResultSet ar = s.executeQuery("Select Apellido, Nombre FROM Personas");
                   DefaultTableModel modelo = new DefaultTableModel();
                   this.Tabla.setModel(modelo);
                   modelo.addColumn("Apellido");
                   modelo.addColumn("Nombre");
                   while (ar.next()) {
                      Object [] fila = new Object[2];
                      for (int i=0;i<2;i++)
                         fila[i] = ar.getObject(i+1);
                      modelo.addRow(fila);
              } catch (SQLException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
    }

    Dont worry kevinaworkman, the thing is that a read it and is really usefull, but i was looking other kind of solution. But i welcome your answer and interested to solve my problem.
    I find the answer.
    To retrive the data i have to use the following instruction:
    Tabla.getValueAt(Tabla.getSelectedColumn(),Tabla.getSelectedRow);

  • Can't get query to work.  table alias in subquery in FROM clause

    How can I rearrange this query to work?
    SELECT
                               TO_CHAR(dt.date_time, 'YYYY-MM-DD') start_date,
                                       (SELECT COUNT(*) FROM
                                            (SELECT DISTINCT a.non_asp, a.start_time, a.end_time
                                                  FROM appointments a
                      WHERE  a.start_time >= dt.date_time AND a.start_time < dt.date_time + 1
                                       ) num_overlap
                             FROM
                                  table(times_pkg.between_times(TO_DATE('2010-05-30'),
                                             TO_DATE('2010-07-03'), 60*24, 'Y')) dtbetween_times is a table function that returns times at given intervals.
    I am trying to get a count of distinct (non_asp, start_time, end_time) sets that fall on each day.
    However, it doesn't recognize dt.date_time in the FROM clause.

    Hi,
    A sub-query can be correlated only to its immediate parent. You're trying the correlate the SELECT DISTINCT sub-query to its grandparent.
    You can re-write the sub-query as a join, like this:
    SELECT  TO_CHAR(dt.date_time, 'YYYY-MM-DD') start_date,
         a.num_overlap
    FROM     table ( times_pkg.between_times ( TO_DATE('2010-05-30'),
                               TO_DATE('2010-07-03'),
                               60*24,
                               'Y'
               ) dt
    JOIN    (
           SELECT    start_time,
                    end_time,
                  COUNT (DISTINCT non_asp)     AS num_overlap
           FROM         appointments
         )  a         ON  a.start_time         >= dt.date_time
                  AND a.start_time         < dt.date_time + 1
    ;You could also eliminate the extra level between the SELECT DISTINCT sub-query and the main query by using SELECT (DISTINCT ...).

Maybe you are looking for

  • Open and close posting period authorization control TCODE: S_ALR_87003642

    HI All, Is there any chance to control the user to open and close another company code posting period variant in TCODE: S_ALR_87003642. In our system we are using the same client for different countries. So user can able to change the other country c

  • Export to Word RTF - Page Server error when over 160 pages exported

    We have XIR2 SP2 We have a Crystal report published into this Enterprise which, when all parameters are widened, runs to 190 pages. The resultant report includes tables We can export to PDF but the client requires it in Word RTF We can export to Word

  • Error when submitting podcast feed on iTunes

    When I went to submit a podcast in iTunes, I received an error that said, "We had difficulty reading this feed. Bad http result code: 500" I have run my url file through www.feedvalidator.org for verification which state it is good. My url I am tryin

  • Problem to validate XML document if the type of root element is abstract

    I have the following XML document: <?xml version="1.0" encoding="UTF-8"?> <ct013/> It corresponds to the following XSD Schema: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">      <xs:element name="ct013

  • Materialized view - fast refresh logs

    I understand that there will be a Change Data Capture(CDC) log maintained internally for materialized view fast refresh to happen. My question is, will this log get purged once the changes are applied to corresponding materialized view or will it per