Hi I am trying to plot linegraph using primefaces. But I am getting the graph for 1st quadrant but I have data for 4th quadrant as well.
My code is:
Bean class:
private LineChartModel lineModel1;
#PostConstruct
public void init() {
createLineModels();
}
public LineChartModel getLineModel1() {
return lineModel1;
}
private void createLineModels() {
lineModel1 = initLinearModel();
lineModel1.setTitle("Linear Chart");
lineModel1.setLegendPosition("e");
Axis yAxis = lineModel1.getAxis(AxisType.Y);
yAxis.setMin(-10);
yAxis.setMax(10);
}
private LineChartModel initLinearModel() {
LineChartModel model = new LineChartModel();
LineChartSeries series1 = new LineChartSeries();
series1.setLabel("Series 1");
series1.set(1, -2);
series1.set(0, 1);
series1.set(1, 3);
model.addSeries(series1);
return model;
}
The output Graph looks like this:
Generated Graph
Related
Update:
WorldConfiguration and World are still the same,
WorldConfiguration setup = new WorldConfigurationBuilder()
.with(new HelloSystemArtemis())
.with(new RenderSystem(batch, environment))
.with(new BulletSystem(this))
.with(new PlayerSystem(perspectiveCamera, batch, gameUi, this))
.with(new AthmosphereSystem(modelComponent,
bulletComponent))
.with(new MovementSystem(this))
.with(new StatusSystem(this))
.with(new EnemySystem(this))
.build();
World world = new World(setup);
world.setDelta(delta);
int entityId = world.create();
world.edit(entityId).create(HelloComponentArtemis.class).message = "\n\rHello Oxyddians!\n\r";
Decided to post full code for clarity reason, in fact can't explain from where the problem is coming, even if I got errors that point me to
#All({ModelComponentArtemis.class, ModelComponentArtemis.class})
public class AthmosphereSystem extends BaseSystem {
private static OxyddiA game;
private static Assets assets = new Assets();
private ComponentMapper<ModelComponentArtemis> mc;
private ComponentMapper<BulletComponentArtemis> bc;
public AthmosphereSystem(ComponentMapper<ModelComponentArtemis> mc,
ComponentMapper<BulletComponentArtemis> bc) {
this.mc = mc;
this.bc = bc;
}
#Override
protected void processSystem() {
int entity = world.create();
ModelComponentArtemis mc = new ModelComponentArtemis(assets.Athmosphere,0,0,0);
mc.create(entity); //Not working
BulletComponentArtemis bc = new BulletComponentArtemis();
btCollisionShape shape = Bullet.obtainStaticNodeShape(assets.Athmosphere.nodes);
bc.bodyInfo = new btRigidBody.btRigidBodyConstructionInfo(0, null, shape, Vector3.Zero);
bc.body = new btRigidBody(bc.bodyInfo);
bc.body.userData = entity;
bc.motionState = new MotionState(mc.instance.transform);
((btRigidBody) bc.body).setMotionState(bc.motionState);
bc.create(entity); //Not working
return entity; //Not working as well
}
}
ModelComponent used in this approach
public class ModelComponentArtemis extends Component {
public Model model;
public ModelInstance instance;
public ModelComponentArtemis(Model model, float x, float y, float z)
{
this.model = model;
this.instance = new ModelInstance(model, new Matrix4().setToTranslation(x, y, z));
}
public void reset() {
}
}
BulletComponent used in this approach
public class BulletComponentArtemis extends Component {
public MotionState motionState;
public btRigidBody.btRigidBodyConstructionInfo bodyInfo;
public btCollisionObject body;
public Model model;
public void init() {
ModelComponentArtemis modelComponent = new ModelComponentArtemis(model,0,0,0);
BulletComponentArtemis bulletComponent = new BulletComponentArtemis();
btCollisionShape shape = Bullet.obtainStaticNodeShape(model.nodes);
bulletComponent.bodyInfo = new btRigidBody.btRigidBodyConstructionInfo(0, null, shape, Vector3.Zero);
bulletComponent.body = new btRigidBody(bulletComponent.bodyInfo);
Object bCuD = null;
bulletComponent.body.userData = bCuD;
bulletComponent.motionState = new MotionState(modelComponent.instance.transform);
((btRigidBody) bulletComponent.body).setMotionState(bulletComponent.motionState);
}
public void reset() {
}
}
And of course the BulletSystem used in this project
#All(ModelComponentArtemis.class)
public class BulletSystem extends EntitySystem
{
public Entity e;
public final btCollisionConfiguration collisionConfiguration;
public final btCollisionDispatcher dispatcher;
public final btBroadphaseInterface broadphase;
public final btConstraintSolver solver;
public final btDiscreteDynamicsWorld collisionWorld;
public GameWorld gameWorld;
public PreGameWorld preGameWorld;
private final btGhostPairCallback ghostPairCallback;
public final int maxSubSteps = 5;
public final float fixedTimeStep = 0.2f / 60f;
private EntityContactListener myContactListener;
public BulletSystem(GameWorld gameWorld)
{
super(Aspect.all(ModelComponentArtemis.class));
this.gameWorld = gameWorld;
myContactListener = new EntityContactListener();
myContactListener.enable();
collisionConfiguration = new btDefaultCollisionConfiguration();
dispatcher = new btCollisionDispatcher(collisionConfiguration);
broadphase = new btAxisSweep3(new Vector3(-1000, -1000, -1000), new Vector3(1000, 1000, 1000));
solver = new btSequentialImpulseConstraintSolver();
collisionWorld = new btDiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfiguration);
ghostPairCallback = new btGhostPairCallback();
broadphase.getOverlappingPairCache().setInternalGhostPairCallback(ghostPairCallback);
this.collisionWorld.setGravity(new Vector3(0f, -0.5f, 0f));
}
public BulletSystem(PreGameWorld preGameWorld)
{
this.preGameWorld = preGameWorld;
myContactListener = new EntityContactListener();
myContactListener.enable();
collisionConfiguration = new btDefaultCollisionConfiguration();
dispatcher = new btCollisionDispatcher(collisionConfiguration);
broadphase = new btAxisSweep3(new Vector3(-1000, -1000, -1000), new Vector3(1000, 1000, 1000));
solver = new btSequentialImpulseConstraintSolver();
collisionWorld = new btDiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfiguration);
ghostPairCallback = new btGhostPairCallback();
broadphase.getOverlappingPairCache().setInternalGhostPairCallback(ghostPairCallback);
this.collisionWorld.setGravity(new Vector3(0f, -0.5f, 0f));
}
public void update(float deltaTime)
{
collisionWorld.stepSimulation(deltaTime, maxSubSteps, fixedTimeStep);
}
protected void processSystem(int entityId) {
this.world.getEntity(entityId).getComponent(BulletComponentArtemis.class);
}
#Override
protected void processSystem() {
}
public void dispose()
{
collisionWorld.dispose();
if (solver != null) solver.dispose();
if (broadphase != null) broadphase.dispose();
if (dispatcher != null) dispatcher.dispose();
if (collisionConfiguration != null)
collisionConfiguration.dispose();
ghostPairCallback.dispose();
}
}
With all that in mind, I know I just can't find any solution,
Maybe it will be clearer like that for anyone wishing to help
Thanks anyawy.
Couple of things to note:
you don't need to inject entity instances
working with Entity and EntityEdit is slower than working with int and ComponentMapper/Archetype/EntityTransmuter, but fine for the beginning.
What you probably want to do is creating an AtmosphereSystem (extending BaseSystem) and create the entity within the initialize method or offer a public method (non-static).
If you need to call those entity factory methods, just inject the AtmosphereSystem (or anything extending BaseSystem) by adding a field "AtmosphereSystem atmosphereSytem;" inside any other BaseSystem.
See this gist for a similar use case (factory methods for creating entities).
I am building an android GPS app with Codename one. I use com.codename1.googlemaps.MapContainer to create a Google map;
In my app is use tabs to create different "pages".
Code:
cnt = new MapContainer();
t.addTab("Tab3", cnt);
And for my current location I use:
try {
Coord position = new Coord(lat,lng);
cnt.clearMapLayers();
cnt.setCameraPosition(position);
cnt.addMarker(EncodedImage.create("/maps-pin.png"), position, "Hi marker", "Optional long description", new ActionListener() {
public void actionPerformed(ActionEvent evt) {
// stuff todo...
}
});
} catch(IOException err) {
// since the image is iin the jar this is unlikely
err.printStackTrace();
}
I like to add a wms layer to the Google Maps. Is this possible? I can't find in codenameone a command addLayer. If yes, do you have a code snippet how to do this?
If it is not possiple, can I use openlayers in my codename one app? Can you give me a code snippet to do this?
Edit
I started to create an native file to "catch"the addtileoverlay from google maps api. The layer I want to use is a xyz layer, so I think I can use a urltileprovider from the googlemap api
I made the native code for the tileoverlay but the tileoverlay doesn't appear. Is it because i didn't get a link with the mapcontainer.
I am little bit stuck. I tried to build from scratch with the googmaps example but the mapcompnent is not anymore used.
package com.Bellproductions.TalkingGps;
import com.google.android.gms.maps.model.UrlTileProvider;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.model.TileOverlayOptions;
import com.google.android.gms.maps.model.TileProvider;
import com.google.android.gms.maps.model.TileOverlay;
import com.codename1.impl.android.AndroidNativeUtil;
import java.util.Locale;
import java.net.MalformedURLException;
public class SeamarksImpl {
private GoogleMap mapInstance;
private TileOverlay m;
TileProvider provider;
public boolean isSupported() {
return true;
}
public long addTilelayer (){
final String URL_FORMAT = "http://t1.openseamap.org/seamark/{z}/{x}/{y}.png";
AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() {
public void run() {
provider = new UrlTileProvider(256, 256) {
#Override
public synchronized URL getTileUrl(int x, int y, int zoom) {
try {
y = (1 << zoom) - y - 1;
return new URL(String.format(Locale.US, URL_FORMAT, zoom, x, y ));
} catch (MalformedURLException e) {
throw new RuntimeException();
}
}
TileOverlayOptions tileopt = new TileOverlayOptions().tileProvider(provider);
public void addlayer() {
m = mapInstance.addTileOverlay(tileopt);
}
};
}
});
long p = 1;
return p;}
}
My seamarks.java file has this code to bind with the native interface
import com.codename1.system.NativeInterface;
/**
*
* #author Hongerige Wolf
*/
public interface Seamarks extends NativeInterface {
public void addTilelayer ();
}
In the mainactivity java file i have the statements
public Seamarks seamark;
public void init(Object context) {
seamark = (Seamarks)NativeLookup.create(Seamarks.class);
}
public void start() {
seamark.addTilelayer();
}
Update
I created a new googlemaps.CN1lib. But the xyz layer is not showing on the googlemaps. I used native code tot use the Tileoverlay feature and tried to add tileoverlay in the same way as Markers.
In the InternalNativeMapsImpl file i changed
private void installListeners() {
/*
if (mapInstance == null) {
view = null;
System.out.println("Failed to get map instance, it seems google play services are not installed");
return;
}*/
view.getMapAsync(new OnMapReadyCallback() {
#Override
public void onMapReady(GoogleMap googleMap) {
mapInstance = googleMap;
TileProvider tileProvider;
tileProvider = new UrlTileProvider(256, 256) {
String tileLayer= "http://t1.openseamap.org/seamark/";
#Override
public synchronized URL getTileUrl(int x, int y, int zoom) {
// The moon tile coordinate system is reversed. This is not normal.
int reversedY = (1 << zoom) - y - 1;
//String s = String.format(Locale.US, tileLayer , zoom, x, y);
String s = tileLayer + "/" + zoom + "/" + x + "/" + reversedY + ".png";
URL url = null;
try {
url = new URL(s);
} catch (MalformedURLException e) {
throw new AssertionError(e);
}
return url;
}
};
mMoonTiles = mapInstance.addTileOverlay(new TileOverlayOptions().tileProvider(tileProvider));
mapInstance.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
public boolean onMarkerClick(Marker marker) {
Long val = listeners.get(marker);
if (val != null) {
MapContainer.fireMarkerEvent(InternalNativeMapsImpl.this.mapId, val.longValue());
return true;
}
return false;
}
});
mapInstance.setOnCameraChangeListener(new GoogleMap.OnCameraChangeListener() {
public void onCameraChange(CameraPosition position) {
MapContainer.fireMapChangeEvent(InternalNativeMapsImpl.this.mapId, (int) position.zoom, position.target.latitude, position.target.longitude);
}
});
mapInstance.setOnMapClickListener(new GoogleMap.OnMapClickListener() {
public void onMapClick(LatLng point) {
Point p = mapInstance.getProjection().toScreenLocation(point);
MapContainer.fireTapEventStatic(InternalNativeMapsImpl.this.mapId, p.x, p.y);
}
});
mapInstance.setOnMapLongClickListener(new GoogleMap.OnMapLongClickListener() {
public void onMapLongClick(LatLng point) {
Point p = mapInstance.getProjection().toScreenLocation(point);
MapContainer.fireLongPressEventStatic(InternalNativeMapsImpl.this.mapId, p.x, p.y);
}
});
mapInstance.setMyLocationEnabled(showMyLocation);
mapInstance.getUiSettings().setRotateGesturesEnabled(rotateGestureEnabled);
}
});
}
Secondly i added a addTilexyz method also in the same way as addMarkers
public long addTilexyz(final String Turl) {
uniqueIdCounter++;
final long key = uniqueIdCounter;
AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() {
public void run() {
TileProvider tileProvider;
tileProvider = new UrlTileProvider(256, 256) {
// Tileurl = "http://t1.openseamap.org/seamark/";
#Override
public synchronized URL getTileUrl(int x, int y, int zoom) {
// The moon tile coordinate system is reversed. This is not normal.
int reversedY = (1 << zoom) - y - 1;
String s = String.format(Locale.US, Turl , zoom, x, reversedY);
URL url = null;
try {
url = new URL(s);
} catch (MalformedURLException e) {
throw new AssertionError(e);
}
return url;
}
};
mMoonTiles = mapInstance.addTileOverlay(new TileOverlayOptions().tileProvider(tileProvider));
}
});
return key;
}
In the InternalNativeMaps file i added te method
public long addTilexyz(String Turl);
And in the Mapcontainer file i added
public MapObject addTilexyz(String Turl) {
if(internalNative != null) {
MapObject o = new MapObject();
Long key = internalNative.addTilexyz(Turl);
o.mapKey = key;
markers.add(o);
return o;
} else {
}
MapObject o = new MapObject();
return o;
}
I am puzzeled what is wrong with the code. I wonder if the commands
Long key = internalNative.addTilexyz(Turl);
and
mMoonTiles = mapInstance.addTileOverlay(new TileOverlayOptions().tileProvider(tileProvider));
put the tileoverlay on the googlemap. Or is the tileurl wrong. http://t1.openseamap.org/seamark/z/x/y.png is correct.
We don't expose layers in the native maps at this time, you can fork the project and just add an API to support that to the native implementations.
I'm using PrimeFaces, in order to build a BarChart. My goal is to compare some Testprojects to each other. Each Bar should be a Testproject from which you can read off the different Phases in which the project is situated.
My question is: I have a View where I can add new Testprojects. When I add one, there is a new Bar. But If I want to add another one, the old Bar is owerwritten. Of course It is, because of set... but I would like to do something like add(testprojectProducer.getTestproject().getName(), 1).
The chart schould be able to remembe the old bar and add the new one. Is there a way or do I have to say goodby to primefaces and build my own chart?
Here is my code:
#ManagedBean
public class ChartView implements Serializable {
private static final long serialVersionUID = 9181815723688700642L;
private BarChartModel barModel;
#Inject
private TestprojectProducer testprojectProducer;
#PostConstruct
public void init() {
createBarModel();
new ArrayList<String>();
}
private BarChartModel initBarModel() {
BarChartModel model = new BarChartModel(); //Diagram
ChartSeries cs= new ChartSeries(); // Balken
cs.setLabel("Testprojekte");
cs.set("Testprojekt 1",5);
cs.set(testprojectProducer.getTestproject().getName(), 1);
model.addSeries(cs);
return model;
}
public void createBarModel() {
barModel =initBarModel();
barModel.setTitle("");
barModel.setLegendPosition("");
barModel.setSeriesColors("C80000");
Axis xAxis = barModel.getAxis(AxisType.X);
xAxis.setLabel("Testprojekte");
Axis yAxis = barModel.getAxis(AxisType.Y);
yAxis.setLabel("Phasen");
yAxis.setMin(0);
yAxis.setMax(7);
}
public BarChartModel getBarModel() {
return barModel;
}
public void setBarChartModel(BarChartModel barModel){
this.barModel= barModel;
}
}
I hope there is a solution to my problem. Thank you!
I resolved my problem. When you use 'HashMap', then It's not that hard:
private BarChartModel initBarModel() {
BarChartModel model = new BarChartModel();
ChartSeries cc = new ChartSeries();
cc.setLabel("Testprojekte");
HashMap<Object, Number> groupData = new HashMap<Object, Number>();
for (int i = 0; i < 3; i++) {
groupData.put(testProjectListProducer.getList().get(i).getName(), 2);
}
cc.setData(groupData);
model.addSeries(cc);
return model;
}
I want to add dynamic checkbox in a grid componemt in AS3. Here is the link. I want to do it in Flash AS3.0 not in Flex.
For custom cells you need to you use custom cellRenderer on the column.
Main
var sampleItem1:Object = {Name:"John Alpha", Number:"555-123-0101", Email:"jalpha#fictitious.com"};
var dg:DataGrid = new DataGrid();
var dgc:DataGridColumn = new DataGridColumn("Name");
dg.addColumn(dgc);
dgc = new DataGridColumn("Number");
dgc.cellRenderer = "CustomCellRenderer"; // here you set your custom renderer for this column
dg.addColumn(dgc);
dgc = new DataGridColumn("Email");
dg.addColumn(dgc);
dg.addItem(sampleItem1);
CheckBoxCellRenderer.as
package
{
import fl.controls.CheckBox;
import fl.controls.listClasses.ICellRenderer;
import fl.controls.listClasses.ListData;
public class CustomCellRenderer extends CheckBox implements ICellRenderer {
private var _listData:ListData;
private var _data:Object;
public function CustomCellRenderer() {
}
public function set data(d:Object):void {
_data = d;
label = d.label;
}
public function get data():Object {
return _data;
}
public function set listData(ld:ListData):void {
_listData = ld;
}
public function get listData():ListData {
return _listData;
}
}
}
source1 source2
I've to JTables. I drag a row from the first table and drop it to the second.
The DnD operation works fine so far, but how can easily refresh the second table after
dropping operation? I've implemented a TableModelListener, but it works only when I
double click on a line of a table.
My question: which event listener do I need to solve my problem? Any solutions or examples?
btw: the DnD operation is performing with the tranferHandler
ok here's some code:
TableExample for creating the to tables
ListHandler1 for DnD operations
SearchRenderer for updating row heights after DnD or table changings
please keep in mind that i wrote quickly. ..
Thanks and regards!
TableExample:
package GUI_Examples;
import java.awt.Component;
import java.awt.Dimension;
import javax.swing.*;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.table.*;
public class TableExample implements TableModelListener{
String [] title = new String [] {"Title A", "Title B"};
String [] title2 = new String [] {"Title C", "Title D"};
Object [][] data = new String [][] {{"aaaaaaaaaaaa aaaaaa aaaaaaa", "bbbbbbbb bbbb bbbbbb bbbbbb"},
{"cccccccccc cccccccc ccccccc", "ddddddd ddd dddddddd dddddd"},
{"eeeeeeeeee eeeeeeee eeeeeee", "fffffff ffff ffffff fffffff"}};
Object [][] data2 = new String [][] {{"",""}};
private JTable table;
private JTable table2;
private JFrame frame;
private DefaultTableModel model;
private DefaultTableModel model2;
private JScrollPane pane1;
private JScrollPane pane2;
private SearchRenderer1 myRenderer;
private SearchRenderer1 myRenderer2;
TableExample() {} //constructor
public JPanel createTable() {
JPanel panel = new JPanel();
//creating tables and table models
model = new DefaultTableModel(data, title);
model2 = new DefaultTableModel(data2, title2);
table = new JTable(model);
table2 = new JTable(model2);
//setting renderers
myRenderer = new SearchRenderer1();
table.setDefaultRenderer(String.class, myRenderer);
table.getColumnModel().getColumn(0).setCellRenderer(myRenderer);
table.getColumnModel().getColumn(1).setCellRenderer(myRenderer);
myRenderer2 = new SearchRenderer1();
table2.setDefaultRenderer(String.class, myRenderer2);
table2.getColumnModel().getColumn(0).setCellRenderer(myRenderer2);
table2.getColumnModel().getColumn(1).setCellRenderer(myRenderer2);
//setting sizes
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
table.getColumnModel().getColumn(0).setPreferredWidth(60);
table.getColumnModel().getColumn(1).setPreferredWidth(60);
table2.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
table2.getColumnModel().getColumn(0).setPreferredWidth(60);
table2.getColumnModel().getColumn(1).setPreferredWidth(60);
//Drag&Drop operations
table.setDragEnabled(true);
table2.setDropMode(DropMode.INSERT);
table2.setTransferHandler(new ListHandler1(model2));
pane1 = new JScrollPane(table);
pane2 = new JScrollPane(table2);
pane1.setPreferredSize(new Dimension(150,300));
pane2.setPreferredSize(new Dimension(150,300));
updateRowHeights();
updateRowHeights2();
panel.add(pane1);
panel.add(pane2);
return panel;
}
void showTable() {
//create and show frame
JPanel testPanel = createTable();
frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(testPanel);
frame.pack();
frame.setVisible(true);
}//showTable
void updateRowHeights() {
for (int row = 0; row < table.getRowCount(); row++) {
int rowHeight = table.getRowHeight();
Component comp = table.prepareRenderer(table.getCellRenderer(row, 1), row, 1);
rowHeight = Math.max(rowHeight, comp.getPreferredSize().height);
table.setRowHeight(row, rowHeight);
}
}
void updateRowHeights2() {
for (int row = 0; row < table2.getRowCount(); row++) {
int rowHeight = table2.getRowHeight();
Component comp2 = table2.prepareRenderer(table2.getCellRenderer(row, 1), row, 1);
rowHeight = Math.max(rowHeight, comp2.getPreferredSize().height);
table2.setRowHeight(row, rowHeight);
}
}
public static void main(String[] args) {
TableExample example = new TableExample();
example.showTable();
}//main
#Override
public void tableChanged(TableModelEvent e) {
updateRowHeights();
updateRowHeights2();
}
}//TableExample
ListHandler
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import javax.swing.TransferHandler;
import javax.swing.table.DefaultTableModel;
public class ListHandler1 extends TransferHandler {
DefaultTableModel model = new DefaultTableModel();
ListHandler1(DefaultTableModel tableModel) {
this.model=tableModel;
} //constructor
/**
*
*/
private static final long serialVersionUID = 1L;
/* canImport: This method tests suitability of a drop operation. Here we filter out the clipboard paste operations
* and allow only String drop operations. If the method returns false, the drop operation is cancelled.(non-Javadoc)
* #see javax.swing.TransferHandler#canImport(javax.swing.TransferHandler.TransferSupport)
*/
public boolean canImport(TransferSupport support) {
if (!support.isDrop()) {
return false;
}
return support.isDataFlavorSupported(DataFlavor.stringFlavor);
}
/*The importData() method transfers the data from the clipboard or from the drag and drop operation to the drop location.
* (non-Javadoc)
* #see javax.swing.TransferHandler#importData(javax.swing.TransferHandler.TransferSupport)
*/
public boolean importData(TransferSupport support) {
if (!canImport(support)) {
return false;
}
Transferable transferable = support.getTransferable(); //The Transferable is the class, where the data is bundled.
String line;
try {
line = (String) transferable.getTransferData(DataFlavor.stringFlavor); //We retrieve our data.
} catch (Exception e) {
return false;
}
String item [] = line.split("\t");
model.addRow(new Object[]{item[0],item[1]});
return true;
}
}
SearchRenderer:
import java.awt.*;
import javax.swing.*;
import javax.swing.table.*;
public class SearchRenderer1 extends JTextArea implements TableCellRenderer {
private static final long serialVersionUID = 1L;
public SearchRenderer1() {
setLineWrap(true);
setWrapStyleWord(true);
} //constructor
public Component getTableCellRendererComponent (JTable table,
Object value,
boolean isSelected,
boolean hasFocus,
int row,
int column ) {
this.setText((String)value);
//for update row height
this.setSize(table.getColumnModel().getColumn(column).getWidth(),Short.MAX_VALUE);
if (isSelected) {
this.setBackground(new java.awt.Color(255, 240, 200));
}
else {
this.setBackground(new java.awt.Color(255, 255, 255));
}
return this;
}//getTableCellRendererComponent
}