How to change JFrame label from JPanel swing?

From the code you have provided I assumed that the jLabel1 is public since you are calling it within a method of the panel.

From the code you have provided I assumed that the jLabel1 is public since you are calling it within a method of the panel. Thus I think that your problem here might be that there are to many changes when you move the mouse and the label is not being repainted quickly enough. To make sure its repaint happens ASAP use code below: private void setLabelText(String text) { jLabel1.

SetText(text); jLabel1. PaintImmediately(jLabel1.getVisibleRect()); } Hope that was it.

My code: pastebin. Com/7ZvF3HyK – mientus May 1 at 14:34 @mientus I have some code which I will edit into my current answer which will show you have simply you can get your label. Currently I expired my max edits for the day.

– Boro May 1 at 14:42 dobra misiek napisze Ci maila o co mi chodzi ;d – mientus May 1 at 14:46 @mientus spoko. OK. Please check the link in the meantime sscce.org.

– Boro May 1 at 14:49.

Make jLabel1 public in JFrame so that JPanel can access it. And if both JFrame and JPanel belongs to same class then just make jLabel1 global and it will be accessible by jPanel.

I don't have JFrame variable! – mientus May 1 at 14:12 @mientus: Are bothjFrame, jPanel in same class? – Harry Joy May 1 at 14:13 @mientus the best if you can give use more/all code.

– Boro May 1 at 14:16 @mientus: seems like both are in different classes. In this case make jLabel1 publicly available by declaring it public or making getter method for it. Then in class where jPanel is you have to create an instance of Class which has jFrame and then do your work.

– Harry Joy May 1 at 14:23 jFrame and jPanel aren't these same class. – mientus May 1 at 14:24.

You don't have to reference it as JFrame. JLabel if they are in the same window .. You just have to make the JLabel public and call the method jLabel1.setText() simple.. can you tell us more about where the components are placed?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions