This week's giveaway is in the Testing forum.
We're giving away four copies of TDD for a Shopping Website LiveProject and have Steven Solomon on-line!
See this thread for details.
Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
  • Piet Souris
  • Himai Minh

change location of jtable

Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi friends,
i have ctreated a jtable.
i want to change the loacation of jtable at (120,120)
how to change the location?
please help..
the code is as below.

import java.awt.Point;
import java.util.ArrayList;
import java.util.List;
import javax.swing.DefaultCellEditor;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellEditor;

* To change this template, choose Tools | Templates
* and open the template in the editor.

* @author ROHIT
public class test

public static void main(String args[])
final List<TableCellEditor> editors = new ArrayList<TableCellEditor>(3);
String[] items1 = { "Red", "Blue", "Green" };
JComboBox comboBox1 = new JComboBox( items1 );
DefaultCellEditor dce1 = new DefaultCellEditor( comboBox1 );
Object[][] data =
{"Color", "Red"},
{"Shape", "Square"},
{"Fruit", "Banana"},
{"Plain", "Text"}
String[] columnNames = {"Type","Value"};
DefaultTableModel model = new DefaultTableModel(data, columnNames);
JTable table = new JTable(model)
// Determine editor to be used by row
public TableCellEditor getCellEditor(int row, int column)
int modelColumn = convertColumnIndexToModel( column );

if (modelColumn == 1 && row < 3)
return editors.get(row);
// return (TableCellEditor)editors.get(row);
return super.getCellEditor(row, column);
JScrollPane scrollPane = new JScrollPane( table );

JFrame ts=new JFrame("Billing System");
ts.add( scrollPane );


Posts: 3323
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please UseCodeTags.

What do you mean by change the location. Do you mean the location of the frame on the screen or the JTable inside the frame.
incandescent light gives off an efficient form of heat. You must be THIS smart to ride this ride. Tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
    Bookmark Topic Watch Topic
  • New Topic