Solved

help something wrong it is simple to

Posted on 2004-04-02
7
204 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
iterator/ListIterator approach 17 54
Java class and jar 3 42
DTD and JAVA versions 1 32
Pass multiple values or string arrays in java as a parameter 3 46
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

733 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