Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Java swing code
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Tamil
Java swing code
2 Answer(s)      5 years and 10 months ago
Posted in : Java Beginners



Advertisement
View Answers

March 16, 2009 at 12:38 AM


Hi Friend,

Please visit the following link for any kind of help in Swing. We have a huge amount of good examples on JTable here.

http://www.roseindia.net/java/example/java/swing

I hope this would be helpful to you.

Thanks
RoseIndia Team


March 30, 2009 at 1:11 PM


hi friend,

Try the following code, you will get the result.

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.table.*;
class CustomTableCellRenderer extends DefaultTableCellRenderer{
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
{
Component cell = super.getTableCellRendererComponent (table, value, isSelected, hasFocus, row, column);
if( value instanceof Integer ){
Integer amount = (Integer) value;
if( amount.intValue() == 1 ){
cell.setBackground( Color.blue );
}
else{
cell.setBackground( Color.white );
}
}
return cell;
}
}
class ExampleTableModel extends AbstractTableModel{
private final String[] columnNames = { "Name", "Income" };
final Object[][] data = {
{"A", new Integer(1) },
{"B", new Integer(2) },
{"C", new Integer(3) },
{"D", new Integer(4) }
};
public Class getColumnClass( int column ) {
return getValueAt(0, column).getClass();
}
public int getColumnCount() {
return columnNames.length;
}
public String getColumnName( int column ) {
return columnNames[column];
}
public int getRowCount() {
return data.length;
}
public Object getValueAt( int row, int column ) {
return data[row][column];
}
}
public class TableCellExample {
public static void main( String[] args ) {
JTable table = new JTable( new ExampleTableModel() );
TableCellRenderer renderer = new CustomTableCellRenderer();
try{
table.setDefaultRenderer( Class.forName
( "java.lang.Integer" ), renderer );
}
catch( Exception ex ){}
JFrame frame = new JFrame();
frame.getContentPane().add( table );
frame.pack();
frame.setVisible( true );
}
}

Thanks


Related Tutorials/Questions & Answers:
Java swing code
Java swing code  can any one send me the java swing code for the following: "A confirmation message after the successful registration of login form
Java swing code
Java swing code  can any one send me the java swing code for the following: "A confirmation message after the successful registration of login form
Advertisements
Java swing code
Java swing code  can any one send me the java swing code for the following: "A confirmation message after the successful registration of login form
Java swing code
Java swing code  can any one send me the java swing code for the following: "A confirmation message after the successful registration of login form
Java swing code
Java swing code  can any one send me the java swing code for the following: "A confirmation message after the successful registration of login form
Java swing code
Java swing code  can any one send me the java swing code for the following: "A confirmation message after the successful registration of login form
Java swing code
Java swing code  can any one send me the java swing code for the following: "A confirmation message after the successful registration of login form"   import javax.swing.*; import java.sql.*; import java.awt.*; import
Java Swing code for zoom in and out
Java Swing code for zoom in and out  hi.......... I require a code in java swing for image zoom in and zoom out can u tell me how it can be done or what is the code plz help
java code - Swing AWT
java code  Imagine you need to open a standard combination dial lock... to write a Java program that prints all possible combinations so you can print them... to open the lock  Hi Friend, Try the following code: class
java code - Swing AWT
java code  i want to open a new dialog box after clicking "upload" button, it should have a text field, browse button to browse the file from directory  Hi Friend, Try the following code: 1)OpenDialog.java import
java code - Swing AWT
java code  Hello .anyone can plz tell me code for this .First create a button wen it is clicked its enters into another window asking for Name .After...   Hi Friend, Try the following code: import java.io.*; import
Java Code - Swing AWT
Java Code  Write a Program using Swings to Display JFileChooser that Display the Naem of Selected File and Also opens that File
Java Code - Swing AWT
Java Code  How to Display a Save Dialog Box using JFileChooser and Save the loaded Image from Panel in any Location.  Hi Friend, Try the following code: import java.io.*; import java.awt.*; import java.util.
Java Code - Swing AWT
Java Code  How to Make an application by using Swings JMenuBar and other components for drawing various categories of Charts(Line,Bar etc
Java swing code - Java Beginners
Java swing code  How to set a font for a particular cell in JTable... in Swing. We have a huge amount of good examples on JTable here. http://www.roseindia.net/java/example/java/swing I hope this would be helpful to you
Java swing code - Java Beginners
Java swing code  How to validate input data entered into the swing applications in java?   Hi Friend, Try the following code: import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.util.
swing login code
swing login code  code for the login form
code - Swing AWT
code  i want example problem for menubar in swings  Hi Friend, Please visit the following links: http://www.roseindia.net/java/example/java/swing/SwingMenu.shtml http://www.roseindia.net/java/example/java/swing
Causing Deadlocks in Swing Code
Causing Deadlocks in Swing At First Consider the Deadlocks A deadlock... that resources. It is a common problem in multithreading. Consider the Sample code... and by adding  the new DesktopPain to the Content Pain it starts the Swing Thread
java swing - Swing AWT
java swing  how to add image in JPanel in Swing?  Hi Friend, Try the following code: import java.awt.*; import java.awt.image....: http://www.roseindia.net/java/example/java/swing/ Thanks
java swing - Swing AWT
java swing   how i can insert in JFrame in swing?  Hi Friend, Try the following code: import java.awt.*; import javax.swing.*; import java.awt.event.*; class FormDemo extends JFrame { JButton ADD; JPanel
java swing - Swing AWT
java swing   Iam developing a java web browser.Actually my code works fine ie. i can load a web page without proxy.But in my place i have only proxy... a proxy or how to make my java web browser to listen to proxy setting??? please help
java swing - Swing AWT
java swing  how i can insert multiple cive me exampleolumn and row in one JList in swing?plz g  Hi Friend, Please clarify your question. Thanks
java swing
java swing  view the book details using swing
Java swing
Java swing  Does Swing contains any heavy weight component
Java swing
Java swing  what are the root classes of all classes in swing
java swing
java swing  what is java swing   Swing is a principal GUI toolkit for the Java programming language. It is a part of the JFC (Java Foundation Classes), which is an API for providing a graphical user interface for Java
Java swing
are displayed in the table..I need the source code in java swing...Java swing  If i am login to open my account the textfield,textarea and button are displayed. if i am entering the time of the textfield
provide code - Swing AWT
); } } ------------------------------------- visit for more information. http://www.roseindia.net/java/example/java/swing/ Thanks...provide code  Dear frnds please provide code for two player CHESS
java swing
java swing  how to connect database with in grid view in java swing   Hi Friend, Please visit the following link: Grid view in java swing Thanks
Java swing
Java swing  Write a java swing program to calculate the age from given date of birth
Advertisements
 

 

 

DMCA.com