Communicating between JPanels
Hi,
I have a program that has a number of JPanels:
- 1 JPanel on the left, split into 4 vertically, each cell holding another JPanel:
Each of the 4 panels contains 2 buttons controlling various connections.
- 1 JPanel on the right of the window, holding a few JLabels acting as status indicators.
The desired action is as follows:
when a user clicks a button on the left hand side of the window, the content of a JLabel on the right hand side of the window is changed to reflect the change.
However, the program will not compile. I initially tried having a copy of the right hand side status object inside the classes that created the left panels...this did not work, although i can't see why.
How can I communicate between different panels within the same frame?
Thank you.
M.
throw up the code till we take a look. When communicating between different components in a GUI I normally pass a reference of the current component which caused the action to the constructor of the Action handler which will process it.
Similar Messages
-
Communicating between JPanel and JApplet
Ok... I have a JApplet that declares a JPanel in it that uses CardLayout. The cards of the CardLayout compose of JPanels. One of them is like a registration form with JTextFields and a JButton to submit. The submit button has to check to make sure all the fields are filled in correctly and then proceed onwards to the next card (JPanel). The problem comes here: How can the JPanel communicate to the CardLayout which was declared in the JApplet to move to the next card?
I have tried creating the submit button with an actionlistener in the JApplet and passing it to the JPanel, but that doesnt work because of conflicting actionlisteners. Any suggestions?Do what you where going to do with the ActionListeners, but with another interface that you create.
For example:
public interface FormListener {
public void formOk();
public void formWrong();
/********** Another file ***************/
public class FormPanel extends JPanel{
FormListener form_list = null;
public void addFormListener(FormListener l){
form_list = l;
public boolean validateForm(){
/*here you validate your form entires*/
public void actionListener(ActionEvent e){
if(e.getSource() == mySubmitButton){
if(validateForm())
form_list.formOk();
else
form_list.formWrong();
/********** Another file ***************/
public class MyApplet extends Applet implements FormListener{
FormPanel form_panel;
public void init(){
form_panel.addFormListener(this);
public void formOk(){
/* Do what you want to do when the form entires are OK*/
public void formWrong(){
/* Do what you want to do when the form entries are wrong*/
al912912 -
Design question: Communication between objects
Hi all,
Just interested in some opinions from your experience. If you have two components, say two GUI components which are repesented by two separate classes, and you need to have these classes communicate in a relatively small way, how would you do it?
What I've done is passed a reference of the second object to the first.
I guess I'm wondering whether this would be considered a reasonable design, or should there be some in-between class which manages the communication between objects.
For a more concrete example: I have a main class (with my main() )which is a JFrame, and this frame has a split panel. I want the left and right sides to communicate with each other. Should I handle the communication through my main class, or should I "couple" the two classes upon initialization and let them do their communication independent of the my main class?
Thanks for any opinions or comments.>
When the user selects a node on the JTree, I want to
populate a particular ComboBox on the right based on
what the user selected in the tree. Or I may just
re-initialize the entire right component based on the
selected node on the JTree.
I guess I was wondering whether I should "marry" the
JTree and the JPanel class, and let them do their
communicating when needed, or whether I should manage
the communucations through the JFrame class.
For example, say I use the JFrame as a "message
manager". The JFrame class will listen for events
from the JTree on the left side, and then send the
appropriate information to the right side. This way
the JTree class and the JPanel class would have no
knowledge of each other. They are glued together
through my JFrame.
Thanks for your opinions.
Then you must register a selection listener with the JTree with addTreeSelectionListener this listener has a reference to the combo. The listener can be a new class (inner class or anonymous) used only for this purpose.
Bye. -
I have done my due diligence in searching the archives and posts, but have not found this question.
I have two panels in my NetBeans application. On panel A is a text box, and in panel B is a button. I wish to push the button on B and have a message placed in the text box in A.
(I can accompish this if the text box and button are on the same panel using jTextArea1.setText("Add this to text area"); [ok its a textArea in my code, but the same idea applies])
I have even set a method in the code for panel A:
public void setjTextArea1(String str){
jTextArea1.setText(jTextArea1.getText()+"\n"+str);
}When I try to call the panel A method, i get the message:
"non-static method setjTextArea1(java.lang.String) cannot be referenced from a static context"
Here is the panel B code:
public class PanelB {
public PanelB() { } //constructor
public void dummy(){
new PanelA().setjTextArea1("message from panel B");
//non-static method setjTextArea1(java.lang.String) cannot be referenced from a static context
}There are many ways to allow one class to "talk" to another. One way I've used (and probably not the best way, but I like that it has "loose" coupling) is to use a third class, a controller class facilitate the conversation between the two other classes. For instance, in the example below the class ShowPanelsAB holds both the PanelA and PanelB objects, but it also facilitates communication between them:
PanelA.java: the panel that holds the JTextArea. Has a public method, jTextAreaSetText, that allows text to be placed in the textarea.
import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JTextArea;
public class PanelA extends JPanel
private JTextArea jTextArea = new JTextArea(5, 20);
public PanelA()
super(new BorderLayout());
add(jTextArea, BorderLayout.CENTER);
public void jTextAreaSetText(String s)
jTextArea.setText(s);
}PanelB.java: Holds the button. Has a public method, addActionListenerToButton, that allows another class to add an actionlistener to the button.
import java.awt.BorderLayout;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JPanel;
public class PanelB extends JPanel
private JButton jButton = new JButton("Press Me");
public PanelB()
super(new BorderLayout());
JPanel buttonPane = new JPanel();
buttonPane.add(jButton);
add(buttonPane, BorderLayout.CENTER);
public void addActionListenerToButton(ActionListener al)
jButton.addActionListener(al);
}ShowPanelsAB.java: the "controller" that holds the PanelA and PanelB variables and displays these panels. It also allows communication between the panels.
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Random;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class ShowPanelsAB extends JPanel
private PanelA panelA;
private PanelB panelB;
private Random rand = new Random();
public ShowPanelsAB()
super(new GridLayout(0, 1, 5, 5));
setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
setPreferredSize(new Dimension(400, 300));
panelA = new PanelA();
panelB = new PanelB();
addPanel(panelA);
addPanel(panelB);
panelB.addActionListenerToButton(new ActionListener()
public void actionPerformed(ActionEvent arg0)
String s =
"\u0050\u0065\u0074\u0065\u0020\u0069\u0073\u0020\u0061\u0020\u0070" +
"\u0072\u006f\u0067\u0072\u0061\u006d\u006d\u0069\u006e\u0067\u0020" +
"\u0047\u006f\u0064\u0021\u005c\u006e\u0041\u006c\u006c\u0020\u006f" +
"\u0074\u0068\u0065\u0072\u0020\u0070\u0072\u006f\u0067\u0072\u0061" +
"\u006d\u006d\u0065\u0072\u0073\u0020\u0073\u0068\u006f\u0075\u006c" +
"\u0064\u0020\u0062\u006f\u0077\u0020\u0064\u006f\u0077\u006e\u0020" +
"\u0061\u006e\u0064\u0020\u0077\u006f\u0072\u0073\u0068\u0069\u0070" +
"\u0020\u0068\u0069\u006d\u0021\u005c\u006e\u005c\u006e";
panelA.jTextAreaSetText(s);
private void addPanel(JPanel p)
int borderWidth = 10;
Color c = new Color(rand.nextInt(256), rand.nextInt(256), rand.nextInt(256));
p.setBorder(BorderFactory.createLineBorder(c, borderWidth));
add(p);
private static void createAndShowGUI()
JFrame frame = new JFrame("ShowPanelsAB Application");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(new ShowPanelsAB());
frame.pack();
frame.setVisible(true);
frame.setLocationRelativeTo(null);
public static void main(String[] args)
javax.swing.SwingUtilities.invokeLater(new Runnable()
public void run()
createAndShowGUI();
} -
What's difference between JPanel.remove(); and JPanel = null
nice day,
how can remove JPanel (including its JComponents), safe way, can you explain the difference between JPanel.remove () and JPanel = null,
1/ because if JPanel does not contain any static JComponents
2/ or any reference to static objects,
then works as well as JPanel.remove or JPanel = null,
or what and why preferred to avoid some action (to avoid to remove or to avoid to null)mKorbel wrote:
nice day,
how can remove JPanel (including its JComponents), safe way, can you explain the difference between JPanel.remove () and JPanel = null, Remove the JPanel from the container it was part of and make sure you do not keep any references to it from your own classes. Don't make it any more difficult than it has to be. -
Is in PI7.1 possible asynchronous communication between SOAP and ABAPProxy?
Hi,
when method execute_asynchronous has disapeared since XI/PI 7.1, is
there still way how to use ABAP proxy in asynchronous way?
We need to build asynchronous connection SOAP->PI->ABAP_Proxy.
In PI, both interfaces are defined as asynchronous (outbound for SOAP and
inbound for ABAP Proxy).
Despite of this fact, when message is sent, it is processed
synchronous way.
I have set breakpoint in my implementation of method for ABAP Proxy
message processing. When message is sent and breakpoint is reached,
whole connection stays open (between SOAP and PI and between PI and
ABAP Proxy) and waits for processing method (the breakpointed one) to
return. Only when processing method returns, is connection finelly
closed.
If i understand it correctly, this is synchronous behavior. In
asynchronous behavior, as i understand it, should be connection
between PI and ABAP Proxy of application server closed immediately
after message has been delivered. This mean before my processing
method is even called.
The same could be said about SOAP and PI communication. Connection
should be closed immediately after PI has received message. From
definition of asynchronous communication of PI is obvious, that PI
should receive message correctly and close connection to sender system
even when receiver is unreachable. It should deliver message later
when, receiver system is back on line. So why it keeps connection to
sender system open while it waits for receiver?
Why is this happening, when both interfaces are defined as
asynchronous? Could be the reason for this, if APPLICATION
ACKNOWLEDGEMENT is set on by default? If so, how can i change it
to SYSTEM ACKNOWLEDGEMENT, or disable it at all?
Or is this kind of asynchronous communication even possible since
XI/PI 7.1 ?
Processing of message we are sending can take some time, so we dont
want connection pending open while waiting for finish of
processing. Thats the reason why we have chose asynchronous model to
use.Quote from How to Use the J2EE SOAP Adapter:
"If you select Best Effort, the Web service client will receive a response
message in the SOAP body. Otherwise, the Web service client will not receive a
response message if no error occurs."
"if no error occurs" - that is the problem. In either case he still
waits if some error occure or not. I dont want it. Once PI has
received message, I want the connection with sender to be closed. If
there will be error in communication between PI and reciever, I want
to see it only in PI log. That mean no notification to sender to be
send about that error.
Is that possible? -
Communication between Best Buy and Apple
Where is the communication between these two companies? It's frustrating to have NO CLUE if a phone will come in a day or in 5 weeks. Who at Apple is deciding what they end to what stores? Obviously, Best Buy has to pay for the phones. There has to be some sort of communication.
Would it really be that hard for someone high up in Best Buy to communicate with Apple? Maybe a list from each store of their orders and what they are waiting on. Give that to Apple. Apple can give some sort of answer. Exepect this much in this time frame... expect this much later. I mean, something. Instead of leaving everyone in the dark, completely.
Someone at Best Buy corporate has to have SOME clue how Apple is shipping and to what stores. To say no one has no clue at all, is nuts. And if it's true... Best Buy needs to get a clue. DO SOME WORK FOR YOUR CUSTOMERS. At least get some truth, so if we need to go elsewhere, we can. It would be better for both sides.Apparently since they come on UPS, they don't know when the shipments are coming in or how much. Which I think is bull.
If that's the case, what I want to know is HOW do they know they received the amount they were expecting? If they don't know how much they're getting or when they're getting a shipment, then what's stopping the delivery man from stealing a box, and they wouldn't know any better? Maybe the higher up manager's know, and they aren't allowed to reveal that info, but there has to be a checks system in there somewhere verifying the stock received. -
How to realize communication between two iViews of the same window but not the same portal page? I tried with using firing portal events but this doesnt seem to work with Mozilla Firefox. Do you have any other ideas?
The sending iView is a portal application the receiving iView a Web Dynpro for ABAP application (so I cant use JavaScript, I guess).
Thanks!
René
Edited by: Rene Guenther on Jan 10, 2008 3:29 PMHi Mrkvicka,
To enable communication between iviews you need to use the EPCF .
You can raise an event in the component of the first iview and define an OnClick event.
this event you can subscribe from the other iview
Refer to this link to get a more clear picture
DropDown Selection and EPCF
also refer to
EPCF
hope this helps,
Regards,
Uma. -
Communication between jsp and abstractportalcomponent
Hello All
Communication between jsp and abstractPortalComponent.
jsp contains one input text field and one submit button.
when the user clicks on submit button it will call the component and that input value will
display in same jsp page.
how this communication will happen?
Rgrds
SriHi Srikanth,
In the JAVA File,
OnSubmit Event,
String inputvalue ;
InputField myInputField = (InputField) getComponentByName("Input_Field_ID");
if (myInputField != null) {
inputvalue = myInputField.getValueAsDataType().toString();
request.putValue("textvalue", inputvalue);
request is IPORTALCOMPONENTREQUEST Object.
In JSP File, to retreive the value,
<%
String textstring = (String) ComponentRequest.getValue("textvalue");
%>
In PORTALAPP.XML File,
<component name="component name">
<component-config>
<property name="ClassName" value="classname"/>
<property name="SafetyLevel" value="no_safety"/>
</component-config>
<component-profile>
<property name="tagLib" value="/SERVICE/htmlb/taglib/htmlb.tld"/>
</component-profile>
</component>
Using the code above, You can pass and read values between abstract portal component and Jsp Page.
Instead of this, I suggest you to use JSPDYNPAGE Component for Data Exchange.
Check the [Link|http://help.sap.com/saphelp_nw2004s/helpdata/de/ce/e0a341354ca309e10000000a155106/frameset.htm].
Hope this helps you.
Regards,
Eben Joyson -
Communication between : AP and WLAN controller
Hi,
The communication between AP and WLAN Controller is ( Data and Control ) UDP.
Source port 1024 and destination port 12222 and 12223. Actually which device listen to which port or both should listen as control and data can be generated from both the devices.
How does the user ( wireless client) traffic is switched - if user traffic is a TCP traffic. It will be sent to WLANC and then WLANC forwards it to respective VLAN or default gateway ( depending upon the destination in the packet ).
Please explain / share the experience.
any link on cisco.com
Thanka in advance
Subodh"the LWAPP Control and Data messages are encapsulated in UDP packets that are carried over the IP network. The only requirement is established IP connectivity between the access points and the WLC. The LWAPP tunnel uses the access point's IP address and the WLC's AP Manager interface IP address as endpoints. The AP Manager interface is explained in further detail in the
implementation section. On the access point side, both LWAPP Control and Data messages use an ephemeral port that is derived from a hash of the access point MAC address as the UDP port. On the WLC side, LWAPP Data messages always use UDP port 12222. On the WLC side, LWAPP Control messages always use UDP port 12223.
The mechanics and sequencing of Layer 3 LWAPP are similar to Layer 2 LWAPP except that the packets are carried in UDP packets instead of being encapsulated in Ethernet frames."
Taken from "Cisco 440X Series Wireless LAN Controllers Deployment Guide" -
Communication between HP eprint and Google Cloud Print
Hi,
the communication between HP eprint and Google Cloud Print seems to be broken. At least for me.
The documents do get printed when I print vio Chrome browser or Cloud Print dashboard -- but the status in cloud print remains as "submitted". It seems like somehow the HP eprint status doen't get reported back to cloud print. In HP eprintcenter the log says "printed".
Well, I wonder who will take care of this problem ... (Hope it will not result in fingerpointing only ...)
Thanks for your support!
Best,
George
This question was solved.
View Solution.Are you able to log back in later and the status at Google Cloud print update to reflect the true outcome of the print job? Or does it just remain as "submitted". Otherwise, if it is printing and showing in the log at ePrint Center (EPC) as printed, the issue would not be on the ePrint side but on Google's
I am a former employee of HP...
How do I give Kudos?| How do I mark a post as Solved? -
Communication between Lab view and Controller via USB
USB communication between C8051F320 and Lab View. I try doing methods given in the NI site(http://zone.ni.com/devzone/cda/tut/p/id/4478) and atlast, it gives me error −1073807302 so if any one can answer my question please do post me the details concerned to it.
My devices show up as NI-VISA USB but I'm not sure if that makes a difference and I'm not using USB RAW either. One thing that you can run is a VISA Property node like below and see what it reports. Also, what version of VISA are you using? If you are not using 4.0, you can download it from http://digital.ni.com/softlib.nsf/webcategories/85256410006C055586256BBB002C0E91?opendocument&node=1....
Message Edited by Dennis Knutson on 01-31-2007 07:29 AM
Attachments:
USB RAW Property.PNG 3 KB -
Communication between the DNS/DHCP Manager and OES Server
No communication between the DNS/DHCP Manager Console and OES server (status,start,stop)
The screenshot shows the tab "DHCP (OES Linux)" in the DNS / DHCP Manager console
in the bottom of the image it shows the state of the DHCP servers.
allDHCP.JPG
The dhcp service is started on all these servers
You can see that the status is known only for four servers.
The button "start/stop DHCP service" works fine on this servers and
the dhcp service can be canceled and also restarted
But the status of the "dhcp service" is not recognized for all the other DHCP servers
and so we can not start or stop dhcp service on these servers.
All servers were installed at different times (last three years) with OES11 and
are upgraded to OES11SP2 with all patches.
The server keto (DHCP_keto) is a new installation OES11SP2 few days ago.
All OES servers were set up identically from me. LDAP, LUM, DMS, DHCP works fine.
Which service on the OES server is responsible for
communication (status indicator) between the DNS/DHCP Manager and the OES serve?
How the status query is performed by the DNS/DHCP Manager?
How can I test the communication to the server on the client (console)?
Which configurationfiles I should be compare on the server?
Thanks in advance
Gernotgernot,
It appears that in the past few days you have not received a response to your
posting. That concerns us, and has triggered this automated reply.
Has your problem been resolved? If not, you might try one of the following options:
- Visit http://www.novell.com/support and search the knowledgebase and/or check all
the other self support options and support programs available.
- You could also try posting your message again. Make sure it is posted in the
correct newsgroup. (http://forums.novell.com)
Be sure to read the forum FAQ about what to expect in the way of responses:
http://forums.novell.com/faq.php
If this is a reply to a duplicate posting, please ignore and accept our apologies
and rest assured we will issue a stern reprimand to our posting bot.
Good luck!
Your Novell Forums Team
http://forums.novell.com -
Communication between two clients
In Java Networking, communication between server-client or bwtween server-multiple clients is general. But How will be the communication between two cients, means two clients can send & receive messages to & from each other(being guided by server).
Sorry,
I didn't get your reply clearly.
I want, if Server is running, and two clients(two instance of a same program) are opened, whatever message(string)client1 send to Server,then the Server needs to send those to client2.Again, the some response should come from client2 to client1 thru Server.
How can I implement this?
If you have idea, or some sample code about this, please let me know.
Regards. -
Communication between a driver and application.
Communication between a driver and application.
I am writing a driver for a PCI card. I have found very good examples of how the driver should be build.
Where do I find the information about how the user mode application should be talking the driver.
So If you have any idea that will help me, please let me know.Hi,Sir
This for your reference.
It will create pci adapter device node at /devices .
You can use AP function call ioctl to Communicate with your device driver.
static int
xxattach(dev_info_t *dip, ddi_attach_cmd_t cmd)
int instance = ddi_get_instance(dip);
switch (cmd) {
case DDI_ATTACH:
allocate a state structure and initialize it.
map the device�s registers.
add the device driver�s interrupt handler(s).
initialize any mutexes and condition variables.
create power manageable components.
* Create the device�s minor node. Note that the node_type
* argument is set to DDI_NT_TAPE.
if (ddi_create_minor_node(dip, "minor_name", S_IFCHR,
instance, DDI_NT_TAPE, 0) == DDI_FAILURE) {
free resources allocated so far.
/* Remove any previously allocated minor nodes */
ddi_remove_minor_node(dip, NULL);
return (DDI_FAILURE);
* Create driver properties like "Size." Use "Size"
* instead of "size" to ensure the property works
* for large bytecounts.
xsp->Size = size of device in bytes;
maj_number = ddi_driver_major(dip);
if (ddi_prop_update_int64(makedevice(maj_number, instance),
dip, "Size", xsp->Size) != DDI_PROP_SUCCESS) {
cmn_err(CE_CONT, "%s: cannot create Size property\n",
ddi_get_name(dip));
free resources allocated so far
return (DDI_FAILURE);
Maybe you are looking for
-
Explain about JAR,EAR and WAR files
Explain :what is JAR,EAR and WAR files and how is useful in creating archive files in java with more example?
-
Stock posting of 08 inspection lot which is having status of LTCA
Hi Freinds, I am having problem in posting the stock from Quality to unrestricted. The details are as follows; A stock transfer Inspection lot is created and by mistake given the UD as "Rejected" and cancelled the Inspection lot. Later it has been re
-
having deleted the driver off the desktop rsently(thinking it was the DVD doubled install) i took my APPLE to my PC doctor.i showed him the 3 CDs that came with it and explained the deletion,and he said they can't be used to reinstall the driver/safa
-
2line items in accounting after billing
hi, after releasing billing to accounting. 2 line items generating for sales revenue account. eg: Sales revenue a/c,- 101010 - 5000.00 Tax a/c-------198.50 Sales revenue a/c,- 101010 - 0.50 here the price difference is 0.50 paise , for this differenc
-
Is it possible to download KP06 template to excel and later upload the file, after filling in values Thanks in Advance Madhu