Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-20-2008, 08:56 AM
Member
 
Join Date: Jun 2008
Posts: 2
Clarion is on a distinguished road
Jframe In Jtable cell
hai,

Can Anyone help me to create a Jframe in Jtable cell as we create popmenu and dialog box on click event..

just send the code ..

clarion
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 06-20-2008, 09:28 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,970
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
It's better try something first yourself. We don't take homeworks for others. Try something my friend. If you stuck with some, ask here.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
(Close on September 4, 2008)

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 06-20-2008, 10:28 PM
Senior Member
 
Join Date: Jun 2008
Posts: 180
Fubarable is on a distinguished road
Quote:
just send the code ..
No

That kind of statement ruffles my feathers. As noted above it is better for you to try yourself. Also, if this component will be seen within the JTable it can't be a JFrame, a JDialog or any other root container. It is ok being a JPanel however.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 06-21-2008, 07:14 AM
Member
 
Join Date: Jun 2008
Posts: 2
Clarion is on a distinguished road
hai friends,
I am really sorry for sending like that...(Just send the code)...Dont mistake me Past 2 weeks I started working in java.Just i tried something,here the code of my program....(this also i have taken from net and editted according to my need)....

I have attached only my main class here....
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;

import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.BorderFactory;
import javax.swing.DefaultCellEditor;
import javax.swing.InputMap;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.KeyStroke;

public class Test extends JFrame {
JTable table;

public Test() {
table = new JTable(15, 5) {
public boolean isCellEditable(int row, int column) {
return column % 2 == 0;
// return true;
}

public void changeSelection(final int row, final int column,
boolean toggle, boolean extend) {

super.changeSelection(row, column, toggle, extend);

if (editCellAt(row, column)) {
getEditorComponent().requestFocusInWindow();
}
}

};

table.setPreferredScrollableViewportSize(table.get PreferredSize());
table.putClientProperty("terminateEditOnFocusLost" , Boolean.TRUE);

TextAreaRenderer textAreaRenderer = new TextAreaRenderer();
TextAreaEditor textEditor = new TextAreaEditor();
table.getColumnModel().getColumn(4).setCellRendere r(textAreaRenderer);
table.getColumnModel().getColumn(4).setCellEditor( textEditor);

JTextField tf = new JTextField();
tf.setBorder(BorderFactory.createEmptyBorder());
table.setDefaultEditor(Object.class, new DefaultCellEditor((tf)));

JScrollPane scrollPane = new JScrollPane(table);

DefaultCellEditor dce = (DefaultCellEditor) table
.getDefaultEditor(Object.class);
dce.setClickCountToStart(1);

getContentPane().add(scrollPane);

InputMap im = table
.getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPO NENT);

// Have the enter key work the same as the tab key

KeyStroke tab = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0);
KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
im.put(enter, im.get(tab));

// Disable the right arrow key

KeyStroke right = KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0);
im.put(right, "none");

// Override the default tab behaviour
// Tab to the next editable cell. When no editable cells goto next cell.

final Action oldTabAction = table.getActionMap().get(im.get(tab));
Action tabAction = new AbstractAction() {
public void actionPerformed(ActionEvent e) {
oldTabAction.actionPerformed(e);
JTable table = (JTable) e.getSource();
int rowCount = table.getRowCount();
int columnCount = table.getColumnCount();
int row = table.getSelectedRow();
int column = table.getSelectedColumn();

while (!table.isCellEditable(row, column)) {
column += 1;

if (column == columnCount) {
column = 0;
row += 1;
}

if (row == rowCount) {
row = 0;
}

// Back to where we started, get out.

if (row == table.getSelectedRow()
&& column == table.getSelectedColumn()) {
break;
}
}

table.changeSelection(row, column, false, false);

JFrame frame1 = new JFrame("MOUSELISTENER FRAME");
Object rows[][] = { { "one", "ichi - \u4E00" },
{ "two", "ni - \u4E8C" }, { "three", "san - \u4E09" },
{ "four", "shi - \u56DB" }, { "five", "go - \u4E94" },
{ "six", "roku - \u516D" }, { "seven", "shichi - \u4E03" },
{ "eight", "hachi - \u516B" }, { "nine", "kyu - \u4E5D" },
{ "ten", "ju - \u5341" } };
Object headers[] = { "English", "Japanese" };
JTable table2= new JTable(rows,headers);
frame1.getContentPane().add(table2, BorderLayout.CENTER);
frame1.setSize(400, 400);
frame1.setVisible(true);
// frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLO SE);
}
};
table.getActionMap().put(im.get(tab), tabAction);
table.setSurrendersFocusOnKeystroke(true);

}

public static void main(String[] args) {
Test frame = new Test();
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}

}


with regards,
clarion
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 06-23-2008, 05:42 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,970
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
First check that your InputMap is correctly define. Seems to me, on your code it's declaration is wrong.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
(Close on September 4, 2008)

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Jtable duplicates through Hashtable (JTable condition problem) my assignment plz help salmanpirzada1 Advanced Java 2 05-15-2008 11:15 AM
GPS location / Cell id / Placing a call JavaForums Java Blogs 0 04-29-2008 02:00 PM
Limiting the capacity of a cell of JTable rameshraj Advanced Java 0 03-24-2008 03:20 PM
Select specific cell Echilon New To Java 1 01-01-2008 08:47 AM
How can i set the table's column dragable/movable false and cell editable johnt AWT / Swing 4 05-19-2007 12:15 PM


All times are GMT +3. The time now is 07:14 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org