JScrollPane not showing in JList

listModel = new DefaultListModel();
        jList2 = new JList(listModel);
        scrollPane = new JScrollPane(jList2, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); The above still doesn't show the scrollPane. Any suggestions why?

works OK in this, using a null layout
import javax.swing.*;
import java.awt.*;
class Testing
  public void buildGUI()
    DefaultListModel lm = new DefaultListModel();
    final JList list = new JList(lm);
    JScrollPane sp = new JScrollPane(list,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                                         JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    for(int x = 0; x < 100; x++) lm.addElement(""+x);
    sp.setBounds(0,0,392,366);
    JFrame f = new JFrame();
    f.getContentPane().setLayout(null);
    f.getContentPane().add(sp);
    f.setSize(400,400);
    f.setLocationRelativeTo(null);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setVisible(true);
  public static void main(String[] args)
    SwingUtilities.invokeLater(new Runnable(){
      public void run(){
        new Testing().buildGUI();
}

Similar Messages

  • JScrollPane not updating when Jlist values are changed

    Hello,
    I have a utility where I have a JList with file names inside a JScrollpane. When a user changes directories, the file list changes to the fully qualified names of the files contained in the new directory. The idea is to have the file names show up in the viewport by scrolling the horizontal scroll bar all the way to the right.
    Here's a short break down of what my code. Sorry I can't provide a runnable snippet, I'm a lot crunched for time.
    Arrays.sort(fileArray);
    fileList.setListData(fileArray);
    hBar = FileScrollPane.getHorizontalScrollBar();
    hBar.setValue(hBar.getMaximum());
    The problem is that hbar.getMaximum() always seems to be a step behind. I always get the Maximum width from the last list of files. As I traverse down a directory tree this results in the knob always being not quit all the way to the right.
    I've tried running fileList.revalidate() after the setListData.
    I've tried calling FileScrollPane.setViewportView(fileList) after the setListData.
    I've tried setting the setViewPositon using getWidth from fileList.
    I've tried setting fileList.setPreferredSize(null) after the setListData, then setting the Viewport, then calling revalidate.
    Somehow the JScrollPane just isn't picking up that the jList has changed and updating it's scrollbars model accordingly until after I've run setValue.
    So my question summed up is:
    Is there someway to force JScrollPane to realize that the JList has changed and update it's components accordingly?

    I tried the revalidate and repaint and it didn't seem to work. I can't use threads for political reasons. so I wrote up the following code which demonstrates the problem. Notice that you have to click a button twice to get the correct values displayed in standard out. Any help would be greatly appreciated.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.beans.PropertyChangeEvent;
    import java.beans.PropertyChangeListener;
    public class TestJListScroll extends JFrame {
      JScrollPane jScrollPane1 = new JScrollPane();
      String[] listValues1 = {"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh",
                              "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh",
                              "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh",
                              "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh"};
      String[] listValues2 = {"TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT",
                              "TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT",
                              "TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT",
                              "TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT"};
      String[] listValues3 = {"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD",
                              "DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD",
                              "DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD",
                              "DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD",
                              "DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"};
      BorderLayout borderLayout1 = new BorderLayout();
      JPanel jPanel1 = new JPanel();
      JList list = new JList();
      JButton button1 = new JButton();
      JButton button2 = new JButton();
      JButton button3 = new JButton();
      public TestJListScroll() {
        try {
          jbInit();
        catch(Exception e) {
          e.printStackTrace();
      public static void main(String[] args) {
        TestJListScroll testJListScroll1 = new TestJListScroll();
        testJListScroll1.setSize(150,300);
        testJListScroll1.setVisible(true);
      private void jbInit() throws Exception {
        jScrollPane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
        jScrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        this.getContentPane().setLayout(borderLayout1);
        jPanel1.setMinimumSize(new Dimension(10, 75));
        jPanel1.setPreferredSize(new Dimension(10, 75));
        button1.setText("List 1");
        button1.addActionListener(new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            button1_actionPerformed(e);
        button2.setText("List 2");
        button2.addActionListener(new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            button2_actionPerformed(e);
        button3.setText("List 3");
        button3.addActionListener(new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            button3_actionPerformed(e);
        this.getContentPane().add(jScrollPane1, BorderLayout.CENTER);
        this.getContentPane().add(jPanel1, BorderLayout.SOUTH);
        jPanel1.add(button1, null);
        jPanel1.add(button2, null);
        jPanel1.add(button3, null);
        jScrollPane1.getViewport().add(list, null);
        list.addPropertyChangeListener("model", new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent e) {
            list_ModelChanged(e);
      void button1_actionPerformed(ActionEvent e) {
        System.out.println("button 1 pressed");
        list.setListData(listValues1);
      void button2_actionPerformed(ActionEvent e) {
        System.out.println("button 2 pressed");
        list.setListData(listValues2);
      void button3_actionPerformed(ActionEvent e) {
        System.out.println("button 3 pressed");
        list.setListData(listValues3);
      private void list_ModelChanged(PropertyChangeEvent e) {
        list.revalidate();
        list.repaint();
        BoundedRangeModel model = jScrollPane1.getHorizontalScrollBar().getModel();
        System.out.println("   file list width = " + list.getWidth());
        System.out.println("   Maximum = " + model.getMaximum());
        System.out.println("   extent = " + model.getExtent());
        model.setValue(model.getMaximum() - model.getExtent());
        System.out.println("   value = " + model.getValue());
    }Thanks,
    Jason

  • Using JScrollPane to show multiple JLists

    Hi, I want to show variable no. of JLists in my GUI. The no of JLists will be available at run time only. Can I put all these JLists in 1 ScrollPane so that whatever may be the no. of JLists (they may be 10 to 15) using scrollbar I can view all the JLists?
    Here is my requirement:
    | JL1 | JL2 |.....................................................| JL n |
    |____|___|....................................................... |____|
    Scrollbar should come here to scroll horizontally <--------------->
    Thanks in advancce,
    Adhiraj.

    Create a JPanel (mainPanel for instance) with a new GridLayout(1, 0). 0 indicates that there can be any number of columns. Add mainPanel to a JScrollPane and that should be enough.

  • JList is not showing up in my Frame

    This is a program I wrote for Having images in a List. A custom cellrenderer and a custom listmodel. Somehow the list itself does not show up in my frame.
    import java.awt.Component;
    import javax.swing.DefaultListModel;
    import javax.swing.Icon;
    import javax.swing.ImageIcon;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JList;
    import javax.swing.JScrollPane;
    import javax.swing.ListCellRenderer;
    public class ListWithImages extends JFrame {
         public ListWithImages() {
              //          We need a Custom model and a Custom Cell Renderer
              CustomImageListModel customImageListModel = new CustomImageListModel();
              CustomImageListCellRenderer customImageListCellRenderer = new CustomImageListCellRenderer();
              JList jlist = new JList(customImageListModel);
              jlist.setCellRenderer(customImageListCellRenderer);
              jlist.setVisibleRowCount(6);
              getContentPane().add(new JScrollPane(jlist));
              pack();
              setVisible(true);
         public static void main(String args[]) {
              new ListWithImages();
         class CustomImageListModel extends DefaultListModel {
              @Override
              public void addElement(Object arg0) {
                   // TODO Auto-generated method stub
         //          Add 10 elements with images
                   for (int i = 0; i < 10; i++) {
                        super.addElement(new Object[] { "Item " + i, new ImageIcon("smiley.jpg") });
         class CustomImageListCellRenderer extends JLabel implements ListCellRenderer {
              public CustomImageListCellRenderer() {
                   setOpaque(true);
              public Component getListCellRendererComponent(JList jlist, Object obj,
                        int index, boolean isSelected, boolean focus) {
                   CustomImageListModel model = (CustomImageListModel) jlist.getModel();
                   setText((String) ((Object[]) obj)[0]);
                   setIcon((Icon) ((Object[]) obj)[1]);
                   if (!isSelected) {
                        setBackground(jlist.getBackground());
                        setForeground(jlist.getForeground());
                   } else {
                        setBackground(jlist.getSelectionBackground());
                        setForeground(jlist.getSelectionForeground());
                   return this;
    }

    I try yhis code and the list is displayed. Try using a layout to get a better design
    public ListWithImages() {
                    this.setLaout(new FlowLayout());
              //          We need a Custom model and a Custom Cell Renderer
              CustomImageListModel customImageListModel = new CustomImageListModel();
              CustomImageListCellRenderer customImageListCellRenderer = new CustomImageListCellRenderer();
              JList jlist = new JList(customImageListModel);
              jlist.setCellRenderer(customImageListCellRenderer);
              jlist.setVisibleRowCount(6);
              getContentPane().add(new JScrollPane(jlist));
              pack();
              setVisible(true);
         }http://java.sun.com/docs/books/tutorial/uiswing/layout/visual.html
    HTH

  • Separator is not showing up in the JList that is set in the TextField

    Hi,
    This problem is really weird and I am tired trying to find the problem and so thought i ll ask u guys... i cant see any problem in the code below.. but when i run it the separator that i want if some condition is true it just dsnt come... i did debug it and it does actually go in the if condition but the separator is not showing up... i dont kno y...
    I am pasting the code of the JList renderer SearchListCellRenderer that implements ListCellRenderer.......it has only one method....
    public Component getListCellRendererComponent(JList list, Object value,
                   int     index, boolean isSelected, boolean cellHasFocus) {
              JLabel label = null;
              if (value != null){
                   label = new JLabel();/*(JLabel) defaultRenderer.getListCellRendererComponent(list, value, index,
                   isSelected, cellHasFocus);*/
                   if(!anatomySeparator && anatomyMap.containsKey(value.toString().toLowerCase())){
                        label.setVerticalTextPosition(SwingConstants.BOTTOM);
                        label.setPreferredSize(new Dimension(300, 80));
                        label.setText("<html><body>" + "<p style='color:white;'><b>--------------Anatomy--------------</b></p>" + "<p style='color:white;'><b>" + value.toString() + "</b></p></body></html>");
                        anatomySeparator = true;
                        logger.debug("in anatomy");
                   }else if(!diseaseSeparator && diseaseMap.containsKey(value.toString().toLowerCase())){
                        label.setVerticalTextPosition(SwingConstants.BOTTOM);
                        label.setPreferredSize(new Dimension(300, 80));
                        label.setText("<html><body>" + "<p style='color:white;'><b>---------------Diseases----------------</b></p>" + "<p style='color:white;'><b>" + value.toString() + "</b></p></body></html>");
                        diseaseSeparator = true;
                        logger.debug("in disease");
                   }else if(!propSeparator && observationMap.containsKey(value.toString().toLowerCase())){
                        label.setVerticalTextPosition(SwingConstants.BOTTOM);
                        label.setPreferredSize(new Dimension(300, 80));
                        label.setText("<html><body>" + "<p style='color:white;'><b>-----------Observations----------------</b></p>" + "<p style='color:white;'><b>" + value.toString() + "</b></p></body></html>");
                        propSeparator = true;
                        logger.debug("in observation");
                   }else{
                        label.setPreferredSize(new Dimension(300, 30));
                        label.setText("<html><body><p style='color:white;'><b>" + value.toString() + "</b></p></body></html>");
              return label;
    If i see the output the list in the JList is bold also in the condition i have the label size larger so in some values the label is actually large than others... that means it does go in the if condition... but the separator that i have there it just dsnt show up... i dnt kno wat is wrong... can anyone pls help me with this????
    This is how i set the autocopleter text field with the Jlist and its renderer... if that is of some help.....
    JList list = new JList();
    JPopupMenu popup = new JPopupMenu();
    JTextComponent textComp;
    private static final String AUTOCOMPLETER = "AUTOCOMPLETER"; //NOI18N
    public SearchListCellRenderer renderer;
    public AutoCompleter(JTextComponent comp){
    textComp = comp;
    textComp.putClientProperty(AUTOCOMPLETER, this);
    JScrollPane scroll = new JScrollPane(list);
    scroll.setBorder(null);
    list.setFocusable( false );
    list.setBackground(Color.DARK_GRAY);
    list.setForeground(Color.WHITE);
    renderer = new SearchListCellRenderer();
    list.setCellRenderer(renderer);
    scroll.getVerticalScrollBar().setFocusable( false );
    scroll.getHorizontalScrollBar().setFocusable( false );
    popup.setBorder(BorderFactory.createLineBorder(Color.black));
    popup.add(scroll);
    if(textComp instanceof JTextField){
    textComp.registerKeyboardAction(showAction, KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), JComponent.WHEN_FOCUSED);
    textComp.getDocument().addDocumentListener(documentListener);
    }else
    textComp.registerKeyboardAction(showAction, KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, KeyEvent.CTRL_MASK), JComponent.WHEN_FOCUSED);
    textComp.registerKeyboardAction(upAction, KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), JComponent.WHEN_FOCUSED);
    textComp.registerKeyboardAction(hidePopupAction, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_FOCUSED);
    popup.addPopupMenuListener(new PopupMenuListener(){
    public void popupMenuWillBecomeVisible(PopupMenuEvent e){
    public void popupMenuWillBecomeInvisible(PopupMenuEvent e){
    textComp.unregisterKeyboardAction(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0));
    public void popupMenuCanceled(PopupMenuEvent e){
    list.setRequestFocusEnabled(false);
    }

    If you need further help then you need to create a [Short, Self Contained, Compilable and Executable, Example Program (SSCCE)|http://homepage1.nifty.com/algafield/sscce.html], that demonstrates the incorrect behaviour.
    Don't forget to use the Code Formatting Tags so the posted code retains its original formatting. That is done by selecting the code and then clicking on the "Code" button above the question input area.

  • JList not showing elements

    Hi To all,
    I am trying to get elements in a JList.All the things are going right but in the application it is not showing any data.
    my code is like ...
    JList jlist=new JList();
    while(---code---)
    //some code
    Vector datalist = new Vector();
    String fname=f.getName();
    for(int i=0;(i<datalist.size());i++)
    datalist.add(fname);
    jlist.setListData(datalist);
    System.out.println(datalist);
    it is showing all names in dos prompt through System.out.println()..
    but not through jlist.
    Any help please
    Thanks in advance

    I'm having a problem with JList (it's not showing the
    elements added to the List).
    i've checked the forum, but couldn't found the answer
    to my problem. Any suggestion on the forum search
    keyword?
    here's my code
    public class TestClass extends JFrame{
    public static void main(String args[]){
    JFrame fra = new MyClass();
    fra.show();
    public class MyClass{
    private JList list;
    public MyClass(){
    setSize(400,300);  
    list = new JList();
    JSplitPane split = new
    ew JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
    new JScrollPane(tree),
    new JScrollPane(fileList));
    ContentPane c = getContentPane(c);
    c.add(split);
    } // end of constructor
    public populateListAtRunTime(){
    DefaultListModel listModel = new
    ew DefaultListModel();
    listModel.addElement("Testing 1");
    listModel.addElement("Testing 2");
    list = new JList(listModel);/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    With this line you are not changing the
    list you have already added to the SplitPane
    (I think it is already added before this gets
    called, you never show the relationship of this
    method to the constructor...), instead, you are
    creating a new JList which you never add to
    anywhere. Is there a way to instead add elements
    to the JList's data model instead of creating a new
    one? Something like this:
    DefaultTableModel listModel = list.getListModel(); //Or something like it...
    listModel.addElement(//...);
    list.revalidate();
    } // end of myClass (inner class)
    The tree showed up in the split pane
    And i think the list also showed up on the splitpane
    also (except that the element value is not
    there)...any clue on why this is happening?
    sorry again..i know this topic must have been posted
    numerous time, but i'm bad with search term
    keyword..and did not find any result that come close
    to my match
    I tried JList + visible, JList + show, and a few
    other

  • JScrollPane bars do not show

    Hi,
    I add the Panel that contains a large image to a scroll pane. However, the image is large, and the scroll bars do not show.
        JScrollPane ScrollPaneScroller = new JScrollPane();
        this.getContentPane().add(ScrollPaneScroller, BorderLayout.CENTER);
        ScrollPaneScroller.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
        ScrollPaneScroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        ScrollPaneScroller.getViewport().add(PanelwithImage, null);
        PanelwithImage.setCenter(this.getWidth(), this.getHeight());Also, how to display the center of the image?

    Aw h&#101;ll...
    import java.awt.Dimension;
    import java.awt.Image;
    import java.io.IOException;
    import java.net.URL;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    public class BigDukeImage {
      public static final String IMAGE_PATH = "http://"
          + "duke.kenai.com/nyanya/NyaNya.jpg";
      private static final Dimension SCROLLPANE_SIZE = new Dimension(900, 700);
      private static void createAndShowUI() {
        Image image = null;
        try {
          URL url = new URL(IMAGE_PATH);
          image = ImageIO.read(url);
          JLabel label = new JLabel(new ImageIcon(image));
          JScrollPane scrollpane = new JScrollPane(label);
          scrollpane.setPreferredSize(SCROLLPANE_SIZE);
          JFrame frame = new JFrame("Big Duke Image");
          frame.getContentPane().add(scrollpane);
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.pack();
          frame.setLocationRelativeTo(null);
          frame.setVisible(true);
          JScrollBar vertSBar = scrollpane.getVerticalScrollBar();
          JScrollBar horzSBar = scrollpane.getHorizontalScrollBar();
          vertSBar.setValue(
              (vertSBar.getMaximum() - vertSBar.getVisibleAmount()) / 2);
          horzSBar.setValue(
              (horzSBar.getMaximum() - horzSBar.getVisibleAmount()) / 2);
        } catch (IOException e) {
          e.printStackTrace();
      public static void main(String[] args) {
        java.awt.EventQueue.invokeLater(new Runnable() {
          public void run() {
            createAndShowUI();
    }

  • JList not showing images

    Have raised a thread giving details of the problem in Java2D forum
    JList not showing images
    Have anybody experienced this issue? I face this issue only when i use swingworker and only for small images (few kBs). It works fine for large images (More than 1MB files). I use Win 7.
    Regards,
    Sreram

    One, do you say because i set the model each time, sometimes the list is not getting repainted? I didn't say that. It's just good concurrency practice to only manipulate models on the EDT, particularly when SwingWorker easily allows the break up of loading the images in a background thread and updating the model on the EDT through the publish/process methods.
    Will the splitting up of worker as process chunks be of any use? Again it's just a good habit to get into for concurrency reasons.
    As for your repainting issue, try changing this line
    item.setImage(getImagefromFile(f)); to
    item.setImage(new ImageIcon(getImageFromFile(f)).getImage()); The ImageIcon class uses MediaTracker to synchronously load images (you can use your own if you want). If you're getting your images via the Toolkit.createImage# methods, then the images need to be loaded. Usually what happens is the toolkit image will get loaded when first drawn. The component that's doing the drawing gets repainted as more of the image comes in. But in the case of a JList, that component is the cell renderer pane and it doesn't care about repaint() calls. So changing the above line will insure the images are already loaded and ready to draw when first shown. tjacobs01 post reminded me of this.

  • JTable Problem (table does not show rows and columns)

    Hi All,
    What the table is suppose to do.
    - Load information from a database
    - put all the values in the first column
    - in the second column put combobox (cell editor with numbers 1-12)
    - the 3rd column put another combobox for something else
    - the 4th column uses checkbox as an edit
    The number of rows of the table should be equal to the number of
    record from
    the database. If not given it default to 20 (poor but ok for this)
    The number of columns is 4.
    But the table does not show any rows or
    column when I put it inside a
    JScrollPane (Otherwise it works).
    Please help,
    thanks in advance.
    public class SubjectTable extends JTable {
    * Comment for <code>serialVersionUID</code>
    private static final long serialVersionUID = 1L;
    /** combo for the list of classes */
    protected JComboBox classCombo;
    /** combo for the list of subjects */
    protected JComboBox subjectsCombo;
    /** combo for the list of grade */
    protected JComboBox gradeCombo;
    boolean canResize = false;
    boolean canReorder = false;
    boolean canSelectRow = false;
    boolean canSelectCell = true;
    boolean canSelectColumn = true;
    // the row height of the table
    int rowHeight = 22;
    // the height of the table
    int height = 200;
    // the width of the table
    int width = 300;
    // the size of the table
    Dimension size;
    * Parameterless constructor. Class the one of the other constructors
    to
    * create a table with the a new <code>SubjectTableModel</code>.
    public SubjectTable() {
    this(new SubjectTableModel());
    * Copy constructor to create the table with the given
    * <code>SubjectTableModel</code>
    * @param tableModel -
    * the <code>SubjectTableModel</code> with which to
    initialise
    * the table.
    SubjectTable(SubjectTableModel tableModel) {
    setModel(tableModel);
    setupTable();
    * Function to setup the table's functionality
    private void setupTable() {
    clear();
    // set the row hieght
    this.setRowHeight(this.rowHeight);
    // set the font size to 12
    //TODO this.setFont(Settings.getDefaultFont());
    // disble reordering of columns
    this.getTableHeader().setReorderingAllowed(this.canReorder);
    // disble resing of columns
    this.getTableHeader().setResizingAllowed(this.canResize);
    // enable the horizontal scrollbar
    this.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    // disable row selection
    setRowSelectionAllowed(this.canSelectRow);
    // disable column selection
    setColumnSelectionAllowed(this.canSelectColumn);
    // enable cell selection
    setCellSelectionEnabled(this.canSelectCell);
    setPreferredScrollableViewportSize(getSize());
    TableColumn columns = null;
    int cols = getColumnCount();
    for (int col = 0; col < cols; col++) {
    columns = getColumnModel().getColumn(col);
    switch (col) {
    case 0:// subject name column
    columns.setPreferredWidth(130);
    break;
    case 1:// grade column
    columns.setPreferredWidth(60);
    break;
    case 2:// class room column
    columns.setPreferredWidth(120);
    break;
    case 3:// select column
    columns.setPreferredWidth(65);
    break;
    } // end switch
    }// end for
    // set up the cell editors
    doGradeColumn();
    doClassColumn();
    //doSubjectColumn();
    * Function to clear the table selection. This selection is different
    to
    * <code>javax.swing.JTable#clearSelection()</code>. It clears the
    user
    * input
    public void clear() {
    for (int row = 0; row < getRowCount(); row++) {
    for (int col = 0; col < getColumnCount(); col++) {
    if (getColumnName(getColumnCount() - 1).equals("Select")) {
    setValueAt(new Boolean(false), row, getColumnCount() - 1);
    }// if
    }// for col
    }// for row
    * Function to set the cell renderer for the subjects column. It uses
    a
    * combobox as a cell editor in the teacher's subjects table.
    public void doSubjectColumn() {
    TableColumn nameColumn = getColumnModel().getColumn(0);
    nameColumn.setCellEditor(new DefaultCellEditor(getSubjectsCombo()));
    // set up the celll renderer
    DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
    renderer.setToolTipText("Click for drop down list");
    nameColumn.setCellRenderer(renderer);
    // Set up tool tip for the sport column header.
    TableCellRenderer headerRenderer = nameColumn.getHeaderRenderer();
    if (headerRenderer instanceof DefaultTableCellRenderer) {
    ((DefaultTableCellRenderer) headerRenderer)
    .setToolTipText("Click the Name to see a list of choices");
    }// end doSubjectsColumn----------------------------------------------
    /** Function to set up the grade combo box. */
    public void doGradeColumn() {
    TableColumn gradeColumn = getColumnModel().getColumn(1);
    gradeColumn.setCellEditor(new DefaultCellEditor(getGradeCombo()));
    DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
    renderer.setToolTipText("Click for drop down list");
    gradeColumn.setCellRenderer(renderer);
    // Set up tool tip for the sport column header.
    TableCellRenderer headerRenderer = gradeColumn.getHeaderRenderer();
    if (headerRenderer instanceof DefaultTableCellRenderer) {
    ((DefaultTableCellRenderer) headerRenderer)
    .setToolTipText("Click the Grade to see a list of choices");
    }// end doGradeColumn-------------------------------------------------
    * Function to setup the Class room Column of the subjects
    public void doClassColumn() {
    // set the column for the classroom
    TableColumn classColumn = getColumnModel().getColumn(2);
    classColumn.setCellEditor(new DefaultCellEditor(getClassCombo()));
    DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
    renderer.setToolTipText("Click for drop down list");
    classColumn.setCellRenderer(renderer);
    // Set up tool tip for the sport column header.
    TableCellRenderer headerRenderer = classColumn.getHeaderRenderer();
    if (headerRenderer instanceof DefaultTableCellRenderer) {
    ((DefaultTableCellRenderer) headerRenderer)
    .setToolTipText("Click the Class to see a list of choices");
    }// end doClassColumn--------------------------------------------------
    * Function to get the size of the table
    * @return Returns the size.
    public Dimension getSize() {
    if (this.size == null) {
    this.size = new Dimension(this.height, this.width);
    return this.size;
    * Function to set the size of the table
    * @param dim
    * The size to set.
    public void setSize(Dimension dim) {
    if (dim != null) {
    this.size = dim;
    return;
    * Function to create/setup the class room comboBox. If the comboBox
    is
    * <code>null</code> a nwew one is created else the functon returns
    the
    * function that was returned initially.
    * @return Returns the classCombo.
    private JComboBox getClassCombo() {
    if (this.classCombo == null) {
    this.classCombo = new JComboBox();
    // fill up the class name combo
    ArrayList classRooms = new ArrayList();
    try {
    //TODO classRooms = Settings.getDatabase().getClassRooms();
    for (int i = 0; i < 10; i++) {
    String string = new String("Class");
    string += i;
    if (!classRooms.isEmpty()) {
    classRooms.trimToSize();
    for (int i = 0; i < classRooms.size(); i++) {
    this.classCombo.addItem(classRooms.get(i));
    } catch (Exception e) {
    e.printStackTrace();
    return this.classCombo;
    * Function to create/setup the subjects comboBox. If the comboBox is
    * <code>null</code> a nwew one is created else the functon returns
    the
    * function that was returned initially.
    * @return Returns the subjectsCombo.
    private JComboBox getSubjectsCombo() {
    if (this.subjectsCombo == null) {
    this.subjectsCombo = new JComboBox();
    try {
    ArrayList subjects = loadSubjectsFromDatabase();
    if (!subjects.isEmpty()) {
    Iterator iterator = subjects.iterator();
    while (iterator.hasNext()) {
    // create a new subject instance
    //TODO Subject subct = new Subject();
    // typecast to subject
    //TODO subct = (Subject) iterator.next();
    String name = (String) iterator.next();
    // add this subject to the comboBox
    //TODO this.subjectsCombo.addItem(subct.getName());
    subjectsCombo.addItem(name);
    }// end while
    }// end if
    else {
    JOptionPane.showMessageDialog(SubjectTable.this,
    "Subjects List Could Not Be Filled");
    System.out.println("Subjects List Could Not Be Filled");
    } catch (Exception e) {
    e.printStackTrace();
    return this.subjectsCombo;
    * Function to load subjects from the <code>Database</code>
    * @return Returns the subjects.
    private ArrayList loadSubjectsFromDatabase() {
    // list of all the subject that the school does
    ArrayList subjects = new ArrayList();
    try {
    //TODO to be removed later on
    for (int i = 0; i < 10; i++) {
    String string = new String("Subject");
    string += i;
    subjects.add(i, string);
    // set the school subjects
    //TODO subjects = Settings.getDatabase().loadAllSubjects();
    } catch (Exception e1) {
    e1.printStackTrace();
    return subjects;
    * Function to create/setup the grade comboBox. If the comboBox is
    * <code>null</code> a nwew one is created else the functon returns
    the
    * function that was returned initially.
    * @return Returns the gradeCombo.
    private JComboBox getGradeCombo() {
    if (this.gradeCombo == null) {
    this.gradeCombo = new JComboBox();
    // fill with grade 1 to 12
    for (int i = 12; i > 0; i--) {
    this.gradeCombo.addItem(new Integer(i).toString());
    return this.gradeCombo;
    public static void main(String[] args) {
    try {
    UIManager.setLookAndFeel(new Plastic3DLookAndFeel());
    System.out.println("Look and Feel has been set");
    } catch (UnsupportedLookAndFeelException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    SubjectTableModel model = new SubjectTableModel();
    int cols = model.getColumnCount();
    int rows = model.getRowCount();
    Object[][] subjects = new Object[rows][cols];
    for (int row = 0; row < rows; row++) {
    subjects[row][0] = new String("Subjectv ") + row;
    }//for
    model.setSubjectsList(subjects);
    SubjectTable ttest = new SubjectTable(model);
    JFrame frame = new JFrame("::Table Example");
    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setViewportView(ttest);
    frame.getContentPane().add(scrollPane);
    frame.pack();
    frame.setVisible(true);
    **************************************END
    TABLE******************************
    ----------------------------THE TABLE
    MODEL----------------------------------
    * Created on 2005/03/21
    * SubjectTableModel
    package com.school.academic.ui;
    import javax.swing.table.AbstractTableModel;
    * Class extending the <code>AbstractTableModel</code> for use in
    creating the
    * <code>Subject</code>s table. In addition to the implemented methods
    of
    * <code>AbstractTableModel</code> The class creates a model that has
    initial
    * values - the values have their own <code>getter</code> and
    * <code>setter</code> methods - but can still be used for values that
    a user
    * chooses.
    * <p>
    * @author Khusta
    public class SubjectTableModel extends AbstractTableModel {
    * Comment for <code>serialVersionUID</code>
    private static final long serialVersionUID = 3257850978324461113L;
    /** Column names for the subjects table */
    String[] columnNames = { "Subject", "Grade", "Class Room",
    "Select" };
    /** Array of objects for the subjects table */
    Object[][] subjectsList;
    private int totalRows = 20;
    protected int notEditable = 0;
    * Parameterless constructor.
    public SubjectTableModel() {
    // TODO initialise the list
    // add column to the default table model
    this.subjectsList = new
    Object[getTotalRows()][getColumnNames().length];
    * Copy constructor with the <code>subjectList</code> to set
    * @param subjects
    public SubjectTableModel(Object[][] subjects) {
    this(0, null, subjects, 0);
    * Copy constructor with the initial number of row for the model
    * @param rows -
    * the initial rows of the model
    * @param cols -
    * the initial columns of the model
    * @param subjects -
    * the initial subjects for the model
    * @param edit - the minimum number of columns that must be
    uneditable
    public SubjectTableModel(int rows, String[] cols, Object[][]
    subjects, int edit) {
    // set the initial rows
    setTotalRows(rows);
    // set the column names
    setColumnNames(cols);
    // set the subjectlist
    setSubjectsList(subjects);
    //set not editable index
    setNotEditable(edit);
    * Function to get the total number of columns in the table
    * @return int -- the columns in the table
    public int getColumnCount() {
    if (this.subjectsList == null) {
    return 0;
    return getColumnNames().length;
    * Function to get the total number of rows in the table
    * @return int -- the rows in the table
    public int getRowCount() {
    if (this.subjectsList == null) {
    return 0;
    return this.subjectsList.length;
    * Function to get the name of a column in the table.
    * @param col --
    * the column to be named
    * @return String -- the column in the table
    public String getColumnName(int col) {
    if (getColumnNames()[col] != null) {
    return getColumnNames()[col];
    return new String("...");
    * Function to get the value of the given row.
    * @param row --
    * the row of the object.
    * @param col --
    * the col of the object.
    * @return Object -- the value at row, col.
    public Object getValueAt(int row, int col) {
    return getSubjectsList()[row][col];
    * Function to return the data type of the given column.
    * @param c --
    * the column whose type must be determined.
    * @return Class -- the type of the object in this col.
    public Class getColumnClass(int c) {
    if (getValueAt(0, c) != null) {
    return getValueAt(0, c).getClass();
    return new String().getClass();
    * Function to put a value into a table cell.
    * @param value --
    * the object that will be put.
    * @param row --
    * the row that the object will be put.
    * @param col --
    * the col that the object will be put.
    public void setValueAt(Object value, int row, int col) {
    * TODO: Have a boolean value to determine whether to clear or
    to set.
    * if true clear else set.
    if (value != null) {
    if (getSubjectsList()[0][col] instanceof Integer
    && !(value instanceof Integer)) {
    try {
    getSubjectsList()[row][col] = new
    Integer(value.toString());
    fireTableCellUpdated(row, col);
    } catch (NumberFormatException e) {
    * JOptionPane .showMessageDialog( this., "The \""
    +
    * getColumnName(col) + "\" column accepts only
    values
    * between 1 - 12");
    return;
    System.out.println("Value = " + value.toString());
    System.out.println("Column = " + col + " Row = " + row);
    // column = Grade or column = Select
    switch (col) {
    case 2:
    try {
    // TODO
    if (Boolean.getBoolean(value.toString()) == false
    && getValueAt(row, 0) != null
    && getValueAt(row, 1) != null
    && getValueAt(row, 2) != null) {
    // subjectsList[row][col + 1] = new
    Boolean(true);
    System.out.println("2. false - Updated...");
    * this.subjectListModel.add(row,
    * this.subjectsList[row][0] + new String(" -
    ") +
    * this.subjectsList[row][2]);
    } catch (ArrayIndexOutOfBoundsException exception) {
    exception.printStackTrace();
    break;
    case 3:
    if (Boolean.getBoolean(value.toString()) == false
    && getValueAt(row, 0) != null
    && getValueAt(row, 1) != null
    && getValueAt(row, 2) != null) {
    System.out.println("3. If - Added...");
    getSubjectsList()[row][3] = new Boolean(true);
    this.subjectListModel.addElement(this.subjectsList[row][0] +
    * new String(" - ") + this.subjectsList[row][2]);
    // subjectListModel.remove(row);
    fireTableCellUpdated(row, col);
    fireTableDataChanged();
    // this.doDeleteSubject();
    } else if (Boolean.getBoolean(value.toString()) ==
    true
    && getValueAt(row, 0) != null
    && getValueAt(row, 1) != null
    && getValueAt(row, 2) != null) {
    setValueAt("", row, col - 1);
    setValueAt("", row, col - 2);
    setValueAt("", row, col - 3);
    System.out.println("3. Else - Cleared...");
    // this.subjectListModel.remove(row);
    break;
    default:
    break;
    }// end switch
    getSubjectsList()[row][col] = value;
    fireTableCellUpdated(row, col);
    fireTableDataChanged();
    }// end if
    }// end
    * Function to enable edition for all the columns in the table
    * @param row --
    * the row that must be enabled.
    * @param col --
    * the col that must be enabled.
    * @return boolean -- indicate whether this cell is editble or
    not.
    public boolean isCellEditable(int row, int col) {
    if (row >= 0
    && (col >= 0 && col <= getNotEditable())) {
    return false;
    return true;
    * Function to get the column names for the model
    * @return Returns the columnNames.
    public String[] getColumnNames() {
    return this.columnNames;
    * Function to set the column names for the model
    * @param cols
    * The columnNames to set.
    public void setColumnNames(String[] cols) {
    // if the column names are null the default columns are used
    if (cols != null) {
    this.columnNames = cols;
    * Function to get the rows of subjects for the model
    * @return Returns the subjectsList.
    public Object[][] getSubjectsList() {
    if (this.subjectsList == null) {
    this.subjectsList = new
    Object[getTotalRows()][getColumnNames().length];
    return this.subjectsList;
    * Function to set the subjects list for the model
    * @param subjects
    * The subjectsList to set.
    public void setSubjectsList(Object[][] subjects) {
    // if the subject list is null create a new one
    // using default values
    if (subjects == null) {
    this.subjectsList = new
    Object[getTotalRows()][getColumnNames().length];
    return;
    this.subjectsList = subjects;
    * Function to get the total number of rows for the model. <b>NB:
    </b> This
    * is different to <code>
    getRowCount()</code>.<code>totalRows</code>
    * is the initial amount of rows that the model must have before
    data can be
    * added.
    * @return Returns the totalRows.
    * @see #setTotalRows(int)
    public int getTotalRows() {
    return this.totalRows;
    * Function to set the total rows for the model.
    * @param rows
    * The totalRows to set.
    * @see #getTotalRows()
    public void setTotalRows(int rows) {
    // if the rows are less than 0 the defaultRows are used
    // set getTotalRows
    if (rows > 0) {
    this.totalRows = rows;
    * Function to get the number of columns that is not editble
    * @return Returns the notEditable.
    public int getNotEditable() {
    return this.notEditable;
    * Function to set the number of columns that is not editable
    * @param notEdit The notEditable to set.
    public void setNotEditable(int notEdit) {
    if (notEdit < 0) {
    notEdit = 0;
    this.notEditable = notEdit;
    ----------------------------END TABLE MODEL----------------------------------

    I hope you don't expect us to read hundreds of lines of unformatted code? Use the "formatting tags" when you post.
    Why are you creating your own TableModel? It looks to me like the DefaultTableModel will store you data. Learn how to use JTable with its DefaultTableModel first. Then if you determine that DefaultTableModel doesn't provide the required functionality you can write your own model.

  • Image does not show up!

    Hello. Im studying java swing and working on some experiment and badly need some help. Im using Graphics2D and not JLable or Icon for some reason. The problem is the image does not show up. What could be the reason and work around? Another, do you know any tutorial on the said matter? Thanks in advance.
    import java.awt.*;
    import javax.swing.*;
    public class ShowImageGraphics
         //Graphics2D g2;
         public static void main(String[] args)
              new ShowImageGraphics();
         public ShowImageGraphics()
              JFrame frame = new JFrame("Sample Graphics");
              frame.setSize(200, 300);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.getContentPane();
              frame.show();
         public void paint(Graphics g)
               Graphics2D g2 = (Graphics2D)g.create();
              Image img = Toolkit.getDefaultToolkit().getImage("/images/rocketship.gif");
              g2 = (Graphics2D)g;
              g2.drawImage(img,14,5,33,40, null);
    }

    import java.awt.*;
    import java.awt.image.*;
    import java.net.*;
    import javax.swing.*;
    public class ImageExample {
        public static void main(String[] args) throws MalformedURLException {
            URL url = new URL("http://today.java.net/jag/bio/JagHeadshot.jpg");
            JLabel label = new JLabel(new ImageIcon(url));
            JFrame f = new JFrame("ImageExample");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(new JScrollPane(label));
            f.pack();
            f.setExtendedState(JFrame.MAXIMIZED_BOTH);
            f.setVisible(true);
    }

  • ScrollBars not showing up properly

    I am displaying a JTree in a JScrollPane with default settings ie. both horizontal and vertical scroll bars will show up when the contents can not fit in to the scroll pane.In this case when i expand the tree nodes the scroll bars are not showing up properly.It looks like the foreground is not painted properly.The background color is white here.We are using custom look and feel, not the standard one. Any idea why it is so?
    Thanx in advance
    Ashok

    This is the MetalTheme i am using.
    public class SSBCMetalTheme extends javax.swing.plaf.metal.MetalTheme
    //     private final ColorUIResource primary1 = new ColorUIResource(102,102,153);
         private final ColorUIResource primary1 = new ColorUIResource(0,0,0);
    //     private final ColorUIResource primary2 = new ColorUIResource(153,153,204);
         private final ColorUIResource primary2 = new ColorUIResource(153,153,153);
    //     private final ColorUIResource primary3 = new ColorUIResource(204,204,255);
         private final ColorUIResource primary3 = new ColorUIResource(204,204,204);
    private final ColorUIResource windowBackground = new ColorUIResource(Color.white);
    private final ColorUIResource textHighlight = new ColorUIResource(Color.blue);
         private final ColorUIResource secondary1 = new ColorUIResource(102,102,102);
         private final ColorUIResource secondary2 = new ColorUIResource(153,153,153);
         private final ColorUIResource secondary3 = new ColorUIResource(204,204,204);
    //     private FontUIResource controlFont = new FontUIResource("Dialog",Font.BOLD,12);
         private FontUIResource controlFont = new FontUIResource("Dialog",Font.BOLD,11);
    //     private FontUIResource systemFont = new FontUIResource("Dialog",Font.PLAIN,12);
         private FontUIResource systemFont = new FontUIResource("Dialog",Font.PLAIN,11);
    //     private FontUIResource userFont = new FontUIResource("Dialog",Font.PLAIN,12);
         private FontUIResource userFont = new FontUIResource("Dialog",Font.PLAIN,11);
         private FontUIResource smallFont = new FontUIResource("Dialog",Font.PLAIN,10);
         public String getName() { return "SSBC"; }
         protected ColorUIResource getPrimary1() { return primary1; }
         protected ColorUIResource getPrimary2() { return primary2; }
         protected ColorUIResource getPrimary3() { return primary3; }
         protected ColorUIResource getSecondary1() { return secondary1; }
         protected ColorUIResource getSecondary2() { return secondary2; }
         protected ColorUIResource getSecondary3() { return secondary3; }
         //public ColorUIResource getWindowBackground() { return (primary3); };
         public ColorUIResource getWindowBackground() { return windowBackground; };
         public ColorUIResource getDesktopColor() { return (primary3); };
         public ColorUIResource getTextHighlightColor(){ return primary3;}
    //public ColorUIResource getControlDisabled(){ return primary3;}
    //public ColorUIResource getControlHighlight(){ return windowBackground;}
         public FontUIResource getControlTextFont() { return controlFont;}
         public FontUIResource getSystemTextFont() { return systemFont;}
         public FontUIResource getUserTextFont() { return userFont;}
         public FontUIResource getMenuTextFont() { return controlFont;}
         public FontUIResource getWindowTitleFont() { return controlFont;}
         public FontUIResource getSubTextFont() { return smallFont;}
    I can't use windows look and feel as i am using the above look and feel.Any idea what is the problem?
    Thanx
    Ashok

  • Why this tree can not show on the Applet?

    hi, all, I try to create a java Applet show a tree, this following code has no error, but the tree can not show on the Applet, can any one tell me why? thanks!
    <code>
    import java.awt.*;
    import java.applet.Applet;
    import java.awt.event.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    import java.awt.dnd.*;
    public class AppletApp extends Applet {
         Date myDate;
         protected JTree m_tree = null;
         protected DefaultTreeModel m_model = null;
         protected JTextField m_display;
         public void init() {
         public void paint(Graphics g) {
              DefaultMutableTreeNode root = new DefaultMutableTreeNode("root");          
              DefaultMutableTreeNode node1 = new DefaultMutableTreeNode("node1");          
              root.add(node1);                    
              node1.add(new DefaultMutableTreeNode("sub1_1"));                         
              node1.add(new DefaultMutableTreeNode("sub1_2"));                                        
         public static void main(String arg[]) {
              JFrame myFrame = new JFrame();          
              Container contentPane = myFrame.getContentPane();
              contentPane.setLayout(new GridLayout(1,2));          
              AppletApp app = new AppletApp();          
              contentPane.add(new JScrollPane(app), BorderLayout.CENTER);     
              myFrame.addWindowListener (new WindowAdapter() {
                   public void windowClosing(WindowEvent e) {
                        System.exit(0);
              app.init();
              app.start();
              myFrame.setSize (400,400);                              
              myFrame.setVisible(true);          
    </code>

    Not quite sure what you are trying to do, but if you move the code from the paint() method into the init() method (then delete your paint() method), then add one new line to the init() method (after the code you just inserted) that reads:
    getContentPane().add(new JTree(root));
    - You should at least see a tree!

  • Not show horizontal srollbar when decrease table size

    import java.awt.Dimension;
    import java.awt.GridLayout;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    public class SimpleTableDemo extends JPanel {
         final Object[][] data = {
                   { "Mary", "Campione", "ooooooooooooooooooooooooooo", "5" },
                   { "Alison", "Huml", "Rowing", "3" },
                   { "Kathy", "Walrath", "Chasing toddlers", "2" },
                   { "Mark", "Andrews", "Speed reading", "20" },
                   { "Angela", "Lih", "Teaching high school", "4" } };
         final Object[] columnNames = { "First Name", "Last Name", "Sport",
                   "Est. Years Experience" };
         public SimpleTableDemo() {
              JTable table = new JTable(data, columnNames);
              // Create the scroll pane and add the table to it.
              JScrollPane scrollPane = new JScrollPane(table);
              scrollPane.setPreferredSize(new Dimension(400, 100));
              // Add the scroll pane to this panel.
              setLayout(new GridLayout(1, 0));
              add(scrollPane);
         public static void main(String[] args) {
              JFrame frame = new JFrame("SimpleTableDemo");
              frame.addWindowListener(new WindowAdapter() {
                   public void windowClosing(WindowEvent e) {
                        System.exit(0);
              frame.getContentPane().add("Center", new SimpleTableDemo());
              // frame.setSize(400, 125);
              frame.pack();
              frame.setVisible(true);
    }When I decrease table size the vertical scrollbar show, but horizontal srollbar NOT show. Why?

    When I decrease table size the vertical scrollbar show, but horizontal srollbar NOT show. Why? Because the table automatically resizes the width of each column.
    If you don't want this behaviour then set the setAutoResizeMode(...) method to off.

  • ITunes does not show up on apple tv 1st gen.

    i have a 1st gen apple tv with the 160 gig HD. recently, it will not show the itunes site. Under teh movies tab there are my movies and trailers and that's it. Does anyone know how to get the itunes store back on apple tv?

    Known issue currently, you'll need to wait for the fix.

  • My downloaded text sounds do not show up under the sounds tab in settings after installing 8.1.1. can someone help me please?

    i downloaded a couple text tones and since installing 8.1.1, they will not show up under the sounds tab. in fact, they do not show up in my recent purchases on itunes, but when i go to buy them again, it says that i have already bought this tone. I just want to use the tones i paid for as the tones on my phone. not asking much.... thanks for the help. i hope someone can help me get the tones working. thank you.

    This was happening to me too but only for some of my songs. I have a mac so I dunno about PCs, but for most of my ringtones I had to create an ACC version in itunes to make them short enough then turn that into a m4r and those all worked fine. But if the song was already short enough and I didn't create an ACC version and just turned the original into a m4r, then it wouldn't appear in my itunes.
    so if you're on a mac:
    1. go to get info, options, pick when you want the song to start and end.
         Has to be pretty short to work, 30 second or less is good
         if it's already short enough that's fine
    2. right click and click 'create ACC version'
         a copy with the length you put in will appear, drag that into a folder or whatever and just type in m4r where m4a would be
         still make an ACC version even if it's the right length
    Hopefully this helps someone else.

Maybe you are looking for