3 Replies - 582 Views - Last Post: 24 May 2010 - 01:21 AM Rate Topic: -----

#1 Guest_lak*


Reputation:

panels in java

Posted 22 May 2010 - 01:07 AM

previously on clicking a link the add & delet functionality are called in new screen..
now i have to add in the parent screen but the add & delete are in diff classes...
how to solve this???
Is This A Good Question/Topic? 0

Replies To: panels in java

#2 aks29921  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 84
  • View blog
  • Posts: 230
  • Joined: 24-August 09

Re: panels in java

Posted 22 May 2010 - 01:21 AM

View Postlak, on 22 May 2010 - 12:07 AM, said:

previously on clicking a link the add & delet functionality are called in new screen..
now i have to add in the parent screen but the add & delete are in diff classes...
how to solve this???

i think it woill be good if you post your code so that we can see what exactly you are doing..
from your description, i feel that you should probably use inheritance in some way or maybe you can give a better description of your problem.
Was This Post Helpful? 0
  • +
  • -

#3 YasuoDancez  Icon User is offline

  • D.I.C Head

Reputation: 20
  • View blog
  • Posts: 135
  • Joined: 30-September 09

Re: panels in java

Posted 23 May 2010 - 06:40 PM

View Postlak, on 22 May 2010 - 12:07 AM, said:

previously on clicking a link the add & delet functionality are called in new screen..
now i have to add in the parent screen but the add & delete are in diff classes...
how to solve this???

It sounds like you may need to pass your screen to that parent screen.
Possible creating a constructor in your parent screen that accepts as its parameter the screen.

It may be helpful to see your code also.
Was This Post Helpful? 0
  • +
  • -

#4 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 1954
  • View blog
  • Posts: 4,053
  • Joined: 11-December 07

Re: panels in java

Posted 24 May 2010 - 01:21 AM

A JDialog seems more suited for this than a JFrame since you can have a modal dialog which handles disabling the parent window(s).

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;


// extend JDialog instead of JFrame
public class PopupDemo extends JDialog implements ActionListener {
	
	public PopupDemo() {
		// Make sure it's a model dialog.
		// i.e. you can't interact with any other
		// windows until it is dismissed
		setModal(true);
		
		// add a button to close the dialog
		JButton closePopup = new JButton("Close");
		closePopup.addActionListener(this);
		add(closePopup);
		
		// Ste the dialog to a sensible size and display
		pack();
		setVisible(true);
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		// close the dialog
		this.setVisible(false);
	}
	
	public static void main(String[] args) {
		// I've ued the main method here but really, this
		// code could be in any method of any class,
		// including an event handler methood
		System.out.println("Do some stuff before the dialog is shown.");
		new PopupDemo();
		System.out.println("The main thread is halted until the dialog is closed.");
	}

}


Was This Post Helpful? 2
  • +
  • -

Page 1 of 1