Solved

help something wrong it is simple to

Posted on 2004-04-02
7
208 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
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!

 
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

695 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