December 28, 2008 at 11:50 PM
Hi friend,
import java.awt.*;
import java.awt.Container;
import javax.swing.*;
public class JTableFrameDemo {
public static void main(String args[]) {
Object rows[][] = { { "Amar", "MCA" }, { "vinod", "M.ED" }, { "Suman", "BIT" }, { "Amit", "Msc" }, {"Deepak", "BIT"}, { "Ravi", "MCA" } };
Object headers[] = { "Upper", "Lower" };
JTable table = new JTable(rows, headers);
table.setTableHeader(null);
JScrollPane scrollPane = new JScrollPane(table);
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(scrollPane, BorderLayout.CENTER);
frame.setSize(300, 150);
frame.setVisible(true);
}
}
class HeaderlessTable extends JTable {
public HeaderlessTable(Object rowData[][], Object columnNames[]) {
super(rowData, columnNames);
}
protected void configureEnclosingScrollPane() {
Container container = getParent();
if (container instanceof JViewport) {
Container viewParent = container.getParent();
if (viewParent instanceof JScrollPane) {
JScrollPane scrollPane = (JScrollPane)viewParent;
JViewport viewport = scrollPane.getViewport();
if(viewport == null || viewport.getView() != this) {
return;
}
scrollPane.setBorder(UIManager.getBorder("Table.scrollPaneBorder"));
}
}
}
}
-------------------------------------------
Visit for more information.
http://www.roseindia.net/java/example/java/swing/Thanks.
Related Tutorials/Questions & Answers:
Advertisements
Java draw triangle draw method?Java draw triangle
draw method? hi
how would i construct the
draw method for an triangle using the 'public void
draw (graphics g ) method? im unsure
how to use the g.fillPolygon and g.drawPolygon?
i have this for drawing
How can i draw a line using java swingsHow can i
draw a line using
java swings Sir my program contains different components i am using
JFrame. I want to
draw a straight line between components(Jtextfeilds, Jlabels).So could you help me for it.
Thank You
How can i draw a line using java swingsHow can i
draw a line using
java swings Sir my program contains different components i am using
JFrame. I want to
draw a straight line between components(Jtextfeilds, Jlabels).So could you help me for it.
Thank You
how to draw network(lines and nodes) in java - Applethow to
draw network(lines and nodes) in java Hi,
Iam doing my MSC project. I want to know,
how can we
draw a network(with lines and nodes, any number of lines and nodes... say 5). I also want to know
how can we
draw a graph
How to draw pie chart in J2MEHow to
draw pie chart in J2ME Hi, I'm developing a program using J2ME and I want to
draw a pie chart but it seems J2ME language hasn't available chart component like JFreeChart in
Java! could any one help me
how can I
draw a pie
how to add scrollbar to JFramehow to add scrollbar to JFrame hello friends
i am making a
java application in which i have a frame to which i wanted to add scrollbars but when i add my panel to scrollpane and then add that scrollpane to
JFrame than
how to add scrollbar to JFramehow to add scrollbar to JFrame hello friends
i am making a
java application in which i have a frame to which i wanted to add scrollbars but when i add my panel to scrollpane and then add that scrollpane to
JFrame than
how to add scrollbar to JFramehow to add scrollbar to JFrame hello friends
i am making a
java application in which i have a frame to which i wanted to add scrollbars but when i add my panel to scrollpane and then add that scrollpane to
JFrame than
how to add scrollbar to JFramehow to add scrollbar to JFrame hello friends
i am making a
java application in which i have a frame to which i wanted to add scrollbars but when i add my panel to scrollpane and then add that scrollpane to
JFrame than
how to add scrollbar to JFramehow to add scrollbar to JFrame hello friends
i am making a
java application in which i have a frame to which i wanted to add scrollbars but when i add my panel to scrollpane and then add that scrollpane to
JFrame than
How to draw globe, draw globe, globe
How to
draw globe
....
New File: Start by taking a new document.ADS_TO_REPLACE_1
Draw Circle: Choose any color and Ellipse Tool (U key)
to
draw a circle as
given below.
World Map
How to add dynamic table in javaHow to add dynamic
table in java
How to add dynamic
table in
java...);
}
JScrollPane scrollPane = new JScrollPane(
table );
p.add( scrollPane );
JFrame f=new...();
}
catch(Exception e){
System.out.println(e);
}
JTable
table = new JTable(data
JFrame Jframe.
How can i do it. Please help me to do it. Or what else can i have
Java Image On JFrame TitleHow to set Image On
JFrame
In this section, you will learn
how to set an image on
JFrame title using
Java program. For
this, we have created an object of
JFrame class. Then, we have used Toolkit.getDefaultToolkit().getImage
JFrameJFrame write an application with a
JFrame that five labels describing reasons that a customer might not buy your product(for example "Too expensive") every time the user clicks a Jbutton, remove one of the negative reasons
jframejframe Create a
JFrame for the Summervale Resort. Allow the user to view the information about different rooms available, dining options and activities offered. Include at least two options in each menu and display appropriate
How to draw a wall, draw a wall, a wall
How to
draw a wall
Now we are going to teach you to
draw a real wall by the photoshop, it is
very easy by my this example.
Select color: First take a new document and choose
jframejframe
how to create a jframe.provide me the
java code pls
How to create file from input values in Jframe ?How to create file from input values in
Jframe ? hi i m doing my project using
java desktop application in netbeans.i designed a form to get... an object for it.my
java code is
public class submit {
JFrame frame;
JTextArea
Draw a diamond - Java BeginnersDraw a diamond I want to
draw a diamond shapein
java using (*) in 9 lines.
Here is the code
import java.util.*;
public class Diamond
{
static Scanner console=new Scanner(System.in);
public static void main(String[]args
setbackground image to JFrame - Java Beginnerssetbackground image to
JFrame how to setbackground image to
JFrame... TransparentBackgroundImage
{
public static void main(String[] args) {
JFrame frame = new
JFrame();
frame.addWindowListener( new WindowAdapter() {
public
Java Swing: Draw rectangle on mouse clickJava Swing:
Draw rectangle on mouse click
In this tutorial, you will learn
how to
draw a rectangle on mouse click.
Sometimes, there is a need of mouse clicks...(String[] args) {
JFrame f = new
JFrame("
Draw Rectangle On Mouse Click
How to draw a television How to
draw a television
Try to
draw a television... Shape: First
draw a Rectangle shape
with black color by using Rectangle tool (U... and rounded rectangle tool (U key) to
draw a rounded rectangle shape.ADS_TO_REPLACE_5
how to open one Jframe from main method callhow to open one
Jframe from main method call I have downloaded a snake game project in
java. Initially the project contains three
java files i.e...", Rules.java
Now this project having five
java classes in this project-
Engine.java