Win a copy of Penetration Testing Basics this week in the Security forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Jtable dialog box

Matt Jacks
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to pop up a dialog from one of the tables on my screen. I am having issues. I am not sure if I set up the editor properly. I have seen code where dialogs are created outside of the custom editor's code and inside, which is proper? I know i have to use a button and encapsulate the button with the editor, should i show the dialog when the button is pushed, or when the editor begins editing? Where can I find examples/information
keiyia jackson
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is what i was given for a similar questions

table = new JTable( rr, clm );
//Registrating for cell selection.
ListSelectionModel cellSelectionModel=table.getSelectionModel();
//assign the selection mode
//add the listener to the table selection model
// 4. add the table to the container
JScrollPane scroller = new JScrollPane(table );
getContentPane().add(scroller, "North" );
JPanel jpnl1 = new JPanel();
back = new JButton("Back to Do a New Search");
jpnl1.add(Box.createRigidArea(new Dimension(5,5)));
getContentPane().add(jpnl1, "South");

JPanel jpnl2 = new JPanel();
JLabel displayheadline = new JLabel("Click a airline that you
prefer to make a booking");
displayheadline.setFont (new Font("SansSerif",Font.BOLD,14));
getContentPane().add(jpnl2, "Center");
//7. List selection listener method to be implemented
public void valueChanged(ListSelectionEvent e) {
int rows;
String selectedData = null;
int[] selectedRow = table.getSelectedRows();
JFrame f3=null;
Vector row_selected = new Vector();
Vector row = new Vector();
for (int j=0; j<clm.size();j++) {>
selectedData = (String)
f3 = new
BookSeats(hostName,portNum,dbName,row_selected,clm); //opened a new window;
public void actionPerformed(ActionEvent evt)
{ JButton arg = (JButton)evt.getSource();
if (arg.equals(back))
{ if(Start.operMode.equals("Local")) {
SearchInput f = new SearchInput(dbName);; }
else if (Start.operMode.equals("Network"))
SearchInput f = new SearchInput(hostName,portNum);; }
{ //for future button; handling code will go here

* Notifies this component that it has been added to a container
* This method should be called by <code>Container.add</code>, and
* not by user code directly.
* Overridden here to adjust the size of the frame if needed.
* @see java.awt.Container#removeNotify
public void addNotify()
// Record the size of the window prior to calling parents addNotify.
Dimension size = getSize();
if (frameSizeAdjusted)
frameSizeAdjusted = true;
// Adjust size of frame according to the insets and menu bar
javax.swing.JMenuBar menuBar = getRootPane().getJMenuBar();
int menuBarHeight = 0;
if (menuBar != null)
menuBarHeight = menuBar.getPreferredSize().height;
Insets insets = getInsets();
setSize(insets.left + insets.right + size.width, +
insets.bottom + size.height + menuBarHeight);
void exitApplication()
try {
// Beep
// Show a confirmation dialog
int reply = JOptionPane.showConfirmDialog(this,
"Do you really want to
"JFC Application - Exit" ,
// If the confirmation was affirmative, handle exiting.
if (reply == JOptionPane.YES_OPTION)
this.setVisible(false); // hide the Frame
this.dispose(); // free the system resources
System.exit(0); // close the application
} catch (Exception e) { }
* This is an Inner class for Window clossing. It gets WindowEvent and
* eventually calls the exitApplication method of the out class.
class SymWindow extends java.awt.event.WindowAdapter
public void windowClosing(java.awt.event.WindowEvent event)
Object object = event.getSource();
if (object == DisplayTable.this)
void Start_windowClosing(java.awt.event.WindowEvent event)
void Start_windowClosing_Interaction1(java.awt.event.WindowEvent event) {
try {
} catch (Exception e) {

// Used by addNotify
boolean frameSizeAdjusted = false;
Vector rr = new Vector();
Vector clm = new Vector();
JTable table;
JButton back=null;
JButton exit=null;
String hostName="";
String dbName;
String portNum;
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this site.SwingExamples
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic