Solved

help something wrong it is simple to

Posted on 2004-04-02
7
199 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
HashTable highest marks enumeration alternative 9 43
jdbc error in jsp application 20 63
how to install java on RHEL image on EC2 4 41
by zero exception 10 52
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 contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

831 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