Home Answers Viewqa Java-Beginners how to draw a table on jframe in java

 
 


siva
how to draw a table on jframe in java
1 Answer(s)      4 years and 6 months ago
Posted in : Java Beginners

View Answers

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 Pages:
how to draw a table on jframe in java - Java Beginners
how to draw a table on jframe in java  how to draw a table on jframe in java?  Hi friend, import java.awt.*; import... scrollPane = new JScrollPane(table); JFrame frame = new JFrame
jframe
jframe  how to create a jframe.provide me the java code pls
how can i draw a table using applet or swings - Java Beginners
how can i draw a table using applet or swings  Hi RoseIndia, Actually, I was trying for creating a table using applet or swings.......... My task is create a table and enter the integer values during run time......I have
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
JFrame
Jframe. How can i do it. Please help me to do it. Or what else can i have
how to add scrollbar to JFrame
how 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 JFrame
how 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 JFrame
how 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 JFrame
how 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 JFrame
how 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 can i draw a line using java swings
How 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 swings
How 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 pie chart in J2ME
How 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
Draw Pie Chart
Draw Pie Chart       This Java Pie Chart example is going to show you how to draw Pie Charts in Java. This Java Pie Chart example is drawing a pie chart to show
Java Swing: Draw rectangle on mouse click
Java 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...) { JFrame f = new JFrame("Draw Rectangle On Mouse Click
how to draw network with nodes - Java Beginners
how to draw network with nodes  how can i draw a network graph (game theory) with 3 nodes and each node display some information
setbackground image to JFrame - Java Beginners
setbackground 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
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
JFrame Components Printing - Swing AWT
JFrame Components Printing  hi sir i am doing a project so i am working in netbeans i have to print a JFrame it contains Labels and few textboxfields so i want to take the whole JFrame contents for printing so would you
How to add dynamic table in java
How 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
how to draw network(lines and nodes) in java - Applet
how 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
Java Image On JFrame Title
How 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
insert image in JFrame - Development process
insert image in JFrame  how to insert a image in JFrame.please...); } static public void main(String args[]) throws Exception { JFrame frame = new JFrame("Display image"); Panel panel = new ShowImage
Refresh JFrame
Refresh JFrame  How to refersh a JFrame and its componets
how to reset JFrame
how to reset JFrame  how to reset JFrame
Table Creation
Table Creation  hi! I want a table which looks like following can u tell me how it can be made with java swings.. YEAR 2005 Jan Feb... BOD COD Can u tel me how i am able
Java Spring Desktop application with multiple classes and jframe
Java Spring Desktop application with multiple classes and jframe  Hi i am developing a desktop java spring application..It has many Jframes forms and classes...How to close one Jframe from another..Please tell... First jframe
Create a Table - Java Beginners
Create a Table in Java  How can i create table in Java?  Java Example Code - Creating table in JAVA- - - - - - - - - - - - - - - - - - - - - - Hi, here i am giving you a java program code, that creates a table with two
how to display a table and buttons in swings - Java Beginners
how to display a table and buttons in swings  Hi frends, Actually i want to display a table during runtime and at the same time i also want to add different buttons below this displayed table using swings.....please can any
how to draw a network with nodes and lines connecting them - Java Beginners
how to draw a network with nodes and lines connecting them   HI, can anyone tell me, how to draw a network with nodes connected with lines in java....( say for 3 nodes). Actually iam doing a project. In that, i need to show
Draw Line
Draw Line  sir i want to draw a moving line in j2me.That line should also show arrow in moving direction. How can we do so
Draw An Arc in Graphics
Draw An Arc in Graphics       In this section, you will learn how to draw an arc in Graphics. An arc of a circle is a segment of the circumference of the circle. To draw an arc
how to draw lines,circles, rectangles on JSP (using Java Graphics)
how to draw lines,circles, rectangles on JSP (using Java Graphics)  how to draw lines,circles, rectangles on JSP (using Java Graphics)   Hello Anuj Try the Following Code : image.jsp <%@ page contentType="image
Draw a Triangle using a Line2D
Draw a Triangle using a Line2D       This section illustrates you how to draw a triangle using a Line2D. To draw a triangle, we are using Line2D class of package java.awt.geom.
Draw Ellipse in Rectangle
Draw Ellipse in Rectangle       This section illustrates you how to draw ellipse inside the rectangle. To draw an Ellipse inside the rectangle, we have defined two classes
refresh checkbox jframe
refresh checkbox jframe  How to refresh checkbox button in JFrame
JFRAME - Java Beginners
javax.swing.*; import java.awt.event.*; public class MenuExample extends JFrame
How to draw to graph in Ms Excel from the data which is sent from an java application....?
How to draw to graph in Ms Excel from the data which is sent from an java application....?  How to draw to graph in Ms Excel from the data which is sent from an java application
Draw text like a curve
Draw text like a curve       This section illustrates you how to draw the text like a curve. To draw the text, we have used the Font class which represents the font
Draw Statistical chart in jsp
Draw Statistical chart in jsp       This section illustrates you how to draw statistical chart in jsp by getting values from database.. To draw a bar chart, we have
Lottery Draw - Java Beginners
Java lottery program  Please send me an example for the Lottery Draw application in Java.Thanks in advance
How to draw globe, draw globe, globe
How to draw globe      .... New File: Start by taking a new document. Draw Circle: Choose any color and Ellipse Tool (U key) to draw a circle as given below. World Map: Capture a world map
draw chart in web application
draw chart in web application  how to draw bar chat from the record store in database? i.e. draw the bar chart according to selected record
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...; color and rounded rectangle tool (U key) to draw a rounded rectangle shape
how to use stringtokenizer on table? and display in table format.
how to use stringtokenizer on table? and display in table format.  table is retrieved from mysql database and each row contains data like(java,c,c++,.net
How to draw a house, draw a house, a house
How to draw a house       Use this example to draw a house in the photoshop, it has been...; color and Rectangle tool (U key) to draw a rectangle shape like a window. Go
how to create a table
how to create a table  create table tablename (name varchar(10),name.... Use the following query: create table tablename (name varchar(10),address varchar(10)); For more information, visit the following link: Java Create
How To Display MS Access Table into Swing JTable - Java Beginners
How To Display MS Access Table into Swing JTable  How to Display... JScrollPane( table ); p.add( scrollPane ); JFrame f=new JFrame(); f.add(p...){ System.out.println(e); } JTable table = new JTable(data, columnNames); TableColumn
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
Java Swing : JFrame Example
Java Swing : JFrame Example In this section, you will learn how to create a frame in java swing. JFrame : JFrame class is defined in javax.swing.JFrame.... holds all the non-menu components displayed by the JFrame. The content pane