Solved

help something wrong it is simple to

Posted on 2004-04-02
7
192 Views
Last Modified: 2010-03-31
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class VboxLayout2 extends JPanel
{ // Opens class

    public VboxLayout2()
    {
        super();

Font f1 = new Font("Courier New", Font.BOLD, 15);

jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jPanel2 = new javax.swing.JPanel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jPanel3 = new javax.swing.JPanel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jPanel4 = new javax.swing.JPanel();
jLabel10 = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
jLabel12 = new javax.swing.JLabel();

setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));

jPanel1.setLayout(new javax.swing.BoxLayout(jPanel1, javax.swing.BoxLayout.Y_AXIS));

jLabel1.setText("jLabel1");
jPanel1.add(jLabel1);

jLabel2.setText("jLabel2");
jPanel1.add(jLabel2);

jLabel3.setText("jLabel3");
jPanel1.add(jLabel3);

add(jPanel1);

jPanel2.setLayout(new javax.swing.BoxLayout(jPanel2, javax.swing.BoxLayout.Y_AXIS));

jLabel4.setText("jLabel4");
jPanel2.add(jLabel4);

jLabel5.setText("jLabel5");
jPanel2.add(jLabel5);

jLabel6.setText("jLabel6");
jPanel2.add(jLabel6);

add(jPanel2);

jPanel3.setLayout(new javax.swing.BoxLayout(jPanel3, javax.swing.BoxLayout.Y_AXIS));

jLabel7.setText("jLabel7");
jPanel3.add(jLabel7);

jLabel8.setText("jLabel8");
jPanel3.add(jLabel8);

jLabel9.setText("jLabel9");
jPanel3.add(jLabel9);

add(jPanel3);

jPanel4.setLayout(new javax.swing.BoxLayout(jPanel4, javax.swing.BoxLayout.Y_AXIS));

jLabel10.setText("jLabel10");
jPanel4.add(jLabel10);

jLabel11.setText("jLabel11");
jPanel4.add(jLabel11);

jLabel12.setText("jLabel12");
jPanel4.add(jLabel12);

add(jPanel4);



   
    }
}
0
Comment
Question by:Drop_of_Rain
  • 3
  • 2
  • 2
7 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 100 total points
ID: 10745260
You simply need to declare all your panels and labels as instance variables
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10745275
If the component's going to be 'read only' then the variables can be local, like the Font one
0
 

Author Comment

by:Drop_of_Rain
ID: 10745404
I don't know really how that went by me. I saw it and didn't try it.
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 15

Expert Comment

by:Javatm
ID: 10745406
There is no explanation on the real problem, Can you pls. discuss the problem ?

But any how I tried modifying your codes :

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class VboxLayout2 extends JPanel
{ // Opens class

    public VboxLayout2()
    {
        super();

       Font f1 = new Font("Courier New", Font.BOLD, 15);

      JPanel jPanel1 = new JPanel();
      JLabel jLabel1 = new JLabel();
      JLabel jLabel2 = new JLabel();
      JLabel jLabel3 = new JLabel();
      JPanel jPanel2 = new JPanel();
      JLabel jLabel4 = new JLabel();
      JLabel jLabel5 = new JLabel();
      JLabel jLabel6 = new JLabel();
      JPanel jPanel3 = new JPanel();
      JLabel jLabel7 = new JLabel();
      JLabel jLabel8 = new JLabel();
      JLabel jLabel9 = new JLabel();
      JPanel jPanel4 = new JPanel();
      JLabel jLabel10 = new JLabel();
      JLabel jLabel11 = new JLabel();
      JLabel jLabel12 = new JLabel();

      setLayout(new FlowLayout(FlowLayout.LEFT));

      jPanel1.setLayout(new BoxLayout(jPanel1, BoxLayout.Y_AXIS));

      jLabel1.setText("jLabel1");
      jPanel1.add(jLabel1);

      jLabel2.setText("jLabel2");
      jPanel1.add(jLabel2);

      jLabel3.setText("jLabel3");
      jPanel1.add(jLabel3);

      add(jPanel1);

      jPanel2.setLayout(new BoxLayout(jPanel2, BoxLayout.Y_AXIS));

      jLabel4.setText("jLabel4");
      jPanel2.add(jLabel4);

      jLabel5.setText("jLabel5");
      jPanel2.add(jLabel5);

      jLabel6.setText("jLabel6");
      jPanel2.add(jLabel6);

      add(jPanel2);

      jPanel3.setLayout(new BoxLayout(jPanel3, BoxLayout.Y_AXIS));

      jLabel7.setText("jLabel7");
      jPanel3.add(jLabel7);

      jLabel8.setText("jLabel8");
      jPanel3.add(jLabel8);

      jLabel9.setText("jLabel9");
      jPanel3.add(jLabel9);

      add(jPanel3);

      jPanel4.setLayout(new BoxLayout(jPanel4, BoxLayout.Y_AXIS));

      jLabel10.setText("jLabel10");
      jPanel4.add(jLabel10);

      jLabel11.setText("jLabel11");
      jPanel4.add(jLabel11);

      jLabel12.setText("jLabel12");
      jPanel4.add(jLabel12);

      add(jPanel4);
   
    }
}
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10745418
8-)
0
 

Author Comment

by:Drop_of_Rain
ID: 10745618
Javatm  I simply forgot to drclar the JPanels as variables!
0
 
LVL 15

Expert Comment

by:Javatm
ID: 10746008
:) Ok, No Worries . . .
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
hash value 2 38
Java virtual machine monitoring tools 3 39
maven java path setting 5 50
word0 challenge 3 58
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now