JLabel on JPanel Disappears(Small CODE!)

Um... I had posted a message a earlier just ot make the complex problem simpler. I have made this small version of my massive code and again the JLabel does not get displayed on the JPanel.
This is urgent please help me.
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
class LabelTry
     public static void main(String args[])
          JFrame aFrame= new JFrame("This is a Test");
          aFrame.addWindowListener(new WindowAdapter()
          {public void windowClosing(WindowEvent e)
          {System.exit(0);
          aFrame.setSize(500,500);
          Container c = aFrame.getContentPane();
          JPanel secPanel = new JPanel();
          secPanel.setLayout(null);
          secPanel.setBackground(Color.gray);
          secPanel.setBorder(BorderFactory.createEtchedBorder());
          JLabel aLabel = new JLabel(" ");
          aLabel.setBounds(100,100,10,10);
          aLabel.setBackground(Color.black);
          aLabel.setOpaque(false);
          aLabel.setVisible(true);
          secPanel.setOpaque(false);
          secPanel.add(aLabel);
          c.add(secPanel, BorderLayout.CENTER);
          aFrame.setVisible(true);
     }//end main
}//end class LabelTry

I've got it working now, but I cannot get it to work in a bigger program.
the code that runs properly is as follows
/;code
class LabelTry
     public static void main(String args[])
          JFrame aFrame= new JFrame("This is a Test");
          aFrame.addWindowListener(new WindowAdapter()
          {public void windowClosing(WindowEvent e)
          {System.exit(0);
          aFrame.setSize(500,500);
          Container c = aFrame.getContentPane();
          JPanel secPanel = new JPanel();
          secPanel.setLayout(null);
          secPanel.setBackground(Color.gray);
          secPanel.setOpaque(false);
          secPanel.setBorder(BorderFactory.createEtchedBorder());
          JLabel aLabel = new JLabel(" ");
          aLabel.setBounds(200,200,10,10);
          aLabel.setBackground(Color.black);
          aLabel.setOpaque(true);
          aLabel.setVisible(true);
          secPanel.add(aLabel);
          c.add(secPanel, BorderLayout.CENTER);
          aFrame.setVisible(true);
     }//end main
}//end class LabelTry
//end code

Similar Messages

  • What this small code does? And how do I do it in Unicode.

    Hi.
    I got the following code and I really don't know what it does or even why. All I know It's not UC enabled ( since it's uxinf the type x).
    I was thinking I might be converting from ascii representation to text or something like that but I'm not that sure.
    FORM TRANSLATE_FIELD USING    STRING_TRAN
                         CHANGING STRING1.
      DATA: STRING(255),
             len1(3) type i,
             LEN(3)  TYPE I,
             NUM(3)  TYPE I,
             I(3)    TYPE I.
      DATA: C VALUE 'A',
            X TYPE X.
      FIELD-SYMBOLS:<fc> type c.
      STRING = STRING_TRAN.
      len1 = strlen( STRING ).
      LEN = 0.
      NUM = 0.
      while len < len1.
        i = STRING+len(3).
        move i to x.
        assign x to <fc> casting type c.
        move <fc> to c.
        MOVE C TO STRING1+NUM.
        len = len + 3.
        NUM = NUM + 1.
      endwhile.
    ENDFORM.                    " TRANSLATE_FIELD
    Thanks
    Ariel

    Hi.
    I want to make this small code UC enabled. Since there is a move of TYPE x into char this is not OK at the mopment.
    the problem is I don't really know or understand how to convert itr to UC enabled program.
    You can notice it takes clusters of 3 chars (bytes ?) long and convert them to char.
    For example 101 = e 100 = d 099 = c.... :-> 101099101 -> ece .
    Thanks
    Ariel

  • How to create multi node /data Tree by using few loops or small code

    HI.
    I WANT TO CREATE A TREE WHICH IS HAVING MULTI NUMBER OF NODE LEVEL (USER HAVE THE ABILITY TO CREATE AS MANY AS REQUIRED NODE LEVEL OR SUBLEVEL). HOW CAN I POPULATE THE TREE WITH SMALL CODE. AS EVERY NODE LEVEL NEED ON NESTED LOOP. SO HOW CAN I MANAGE TO POPULATE THE NODE WITH FEW LOOPS. OR THERE IS ANY OTHER WAY TO MANAGE THIS PROBLEM.
    THANKS

    Hi ,
    I am trying to do the job , but i do not understand where
    is the problem with my loop , i am sending it , could you
    see it , and sujjest me , what to do. or if you have time
    can you write the code for me. as i am very much needy for
    this job.
    The Table is as:-
    CREATE TABLE TREE_01(
    RECORD_NO NUMBER(10), --
    OWN_CODE VARCHAR2(10),
    PARENT_NO NUMBER(10),
    PARENT_CODE VARCHAR2(10),
    LEVELL NUMBER(4),
    DEPT NUMBER(6),
    CONSTRAINT RNO_PK PRIMARY KEY(RECORD_NO));
    INSERT INTO TREE_01 VALUES(1,'1',0,'0',2,8540);
    INSERT INTO TREE_01 VALUES(2,'2',0,'0',2,8540);
    INSERT INTO TREE_01 VALUES(3,'3',0,'0',2,8540);
    INSERT INTO TREE_01 VALUES(4,'4',0,'0',2,8540);
    INSERT INTO TREE_01 VALUES(5,'1',1,'0',3,8540);
    INSERT INTO TREE_01 VALUES(6,'2',1,'0',3,8540);
    INSERT INTO TREE_01 VALUES(7,'3',1,'0',3,8540);
    INSERT INTO TREE_01 VALUES(8,'1',3,'0',3,8540);
    INSERT INTO TREE_01 VALUES(9,'2',3,'0',3,8540);
    the loop shoud look like
    |_DataProcessing
    | |+Work_orders
    | |_Programmers File
    | | |_James
    | | | |+Requests
    | | | |+Leves
    | | | |_Projects
    | | | |_Projects001
    | | |+Steven
    |+HealthCare
    |+Transportation
    So the loop should be such that it can be go to any level of any node.
    the Code i writter is As follows.
    The Following Procedure is called in form leve
    When new forms instance.
    PROCEDURE REFRESH_TREE2 IS
    CURSOR CUR_DEPT IS
         SELECT DEPT
         FROM TREE_01 GROUP BY DEPT;
    CURSOR CUR_LOOP1(PARENT1 NUMBER,LEVEL1 NUMBER) IS
         SELECT RECORD_NO,
         OWN_CODE,
         PARENT_NO,
         DEPT ,
         PARENT_CODE,
         LEVELL
         FROM TREE_01
         WHERE LEVELL=LEVEL1
         AND RECORD_NO=PARENT1;
    CURSOR CUR_LOOP2(PARENT2 NUMBER,LEVEL2 NUMBER) IS
         SELECT RECORD_NO,
         OWN_CODE,
         PARENT_NO,
         DEPT ,
         PARENT_CODE,
         LEVELL
         FROM TREE_01
         WHERE LEVELL=LEVEL2
         AND RECORD_NO=PARENT2;
    CURSOR LEVEL(PARENTNO NUMBER) IS
         SELECT LEVELL FROM TREE_01 WHERE PARENT_NO=PARENTNO
         ORDER BY RECORD_NO;
         V_I NUMBER;
         V_IGNORE NUMBER;
         RG_DEPT RECORDGROUP;
         RG_CABI RECORDGROUP;
         V_INIT_STATE GROUPCOLUMN;
         V_LEVEL GROUPCOLUMN;
         V_LABEL GROUPCOLUMN;
         V_ICON GROUPCOLUMN;
         V_VALUE GROUPCOLUMN;
         V_CHANGE_VALUE VARCHAR2(20);
         V_CHANGE_VALUE1 NUMBER(3);
         V_CHANGE_VALUE2 NUMBER(3);
    V_LEVEL_COUNT NUMBER;
    BEGIN
         SELECT MAX(LEVELL) INTO V_LEVEL_COUNT FROM TREE_01;
         RG_DEPT:=FIND_GROUP('DEPT');
         if not id_null(RG_DEPT) then
    delete_group(RG_DEPT);
    end if;
         RG_DEPT:=create_group('DEPT');
         V_INIT_STATE := add_group_column(RG_DEPT, 'INIT_STATE', NUMBER_COLUMN);
         V_LEVEL :=ADD_GROUP_COLUMN(RG_DEPT,'LEVEL',NUMBER_COLUMN);
         V_LABEL :=ADD_GROUP_COLUMN(RG_DEPT,'LABEL',CHAR_COLUMN,40);
         V_ICON :=ADD_GROUP_COLUMN(RG_DEPT,'ICON',CHAR_COLUMN,20);
         V_VALUE :=ADD_GROUP_COLUMN(RG_DEPT,'VALUE',CHAR_COLUMN,15);
         V_I :=1;
         FOR DEPTREC IN CUR_DEPT LOOP
         ADD_GROUP_ROW(RG_DEPT,V_I);
         SET_GROUP_NUMBER_CELL(V_INIT_STATE,V_I,1);
         SET_GROUP_NUMBER_CELL(V_LEVEL ,V_I,1);
         SET_GROUP_CHAR_CELL(V_LABEL ,V_I,FILING.ELOOK_IT(11,0,DEPTREC.DEPT));--MAIN_MINOR));
         SET_GROUP_CHAR_CELL(V_ICON ,V_I,NULL);
         SET_GROUP_CHAR_CELL(V_VALUE ,V_I,TO_CHAR(DEPTREC.DEPT)); --MAIN_MINOR));
         V_I:= V_I +1;
         V_CHANGE_VALUE := DEPTREC.DEPT;
         FOR I IN 1..V_LEVEL_COUNT LOOP
         FOR DEPTREC1 IN CUR_LOOP1(V_CHANGE_VALUE,I) LOOP --MAIN_MINOR,I) LOOP
         ADD_GROUP_ROW(RG_DEPT,V_I);
         SET_GROUP_NUMBER_CELL(V_INIT_STATE,V_I,1);
         SET_GROUP_NUMBER_CELL(V_LEVEL ,V_I,I);
         SET_GROUP_CHAR_CELL(V_LABEL ,V_I,DEPTREC1.RECORD_NO);
         SET_GROUP_CHAR_CELL(V_ICON ,V_I,NULL);
         SET_GROUP_CHAR_CELL(V_VALUE ,V_I,DEPTREC1.RECORD_NO);
         V_I:= V_I +1;
         SELECT count(LEVELL) INTO V_CHANGE_VALUE1
    FROM TREE_01
    WHERE RECORD_NO=DEPTREC1.RECORD_NO
         AND PARENT_NO=DEPTREC1.PARENT_NO
         AND LEVELL=DEPTREC1.LEVELL;
         SELECT MAX(LEVELL) INTO V_CHANGE_VALUE2
         FROM TREE_01
         WHERE RECORD_NO=DEPTREC1.RECORD_NO
         AND PARENT_NO=DEPTREC1.PARENT_NO
         AND LEVELL=DEPTREC1.LEVELL;
              FOR j IN 1..V_CHANGE_VALUE1 loop
              FOR LVL IN LEVEL(DEPTREC1.RECORD_NO) LOOP
              FOR DEPTREC2 IN CUR_LOOP2(DEPTREC1.RECORD_NO, LVL.LEVELL) LOOP
         ADD_GROUP_ROW(RG_DEPT,V_I);
         SET_GROUP_NUMBER_CELL(V_INIT_STATE,V_I,1);
         SET_GROUP_NUMBER_CELL(V_LEVEL ,V_I,LVL.LEVELL);
         SET_GROUP_CHAR_CELL(V_LABEL ,V_I,DEPTREC2.RECORD_NO);
         SET_GROUP_CHAR_CELL(V_ICON ,V_I,NULL);
         SET_GROUP_CHAR_CELL(V_VALUE ,V_I,DEPTREC2.RECORD_NO);
         V_I:= V_I +1;
         V_CHANGE_VALUE := DEPTREC2.RECORD_NO;
                   end loop;
         end loop;
         END LOOP;
         END LOOP;
         END LOOP;
         END LOOP;
         ftree.set_tree_property('NAVIGATOR.NAV_DISPLAY',ftree.record_Group, rg_dept);
         end;

  • Writing a small code in HANA

    Hi,
    I am interested in HANA ..I am totally new to this side ..
    I read all papers on HANA .Theoretically I know HANA mostly but wants to taste by practically .
    Please can somebody tell me the steps to write a small code on this ??
    What tool is required...whether tool is free ...how can I use this tool ...
    Please do the needful and guide me .
    -Ashwini

    Hi Aswinin,
    You can get 30 days free HANA trail . There you can try the theory part you learned .. Welcome to HANA , Enjoy it
    scn.sap.com/docs/DOC-28191
    Sreehari

  • Tiling JLabels on JPanel

    Okay, I am trying to tile JLabels across a JPanel. I have implemented a GridLayout (no worries, I want all JLabels to be the same size) of a 15x15 layout. Below is my code. When I run this, it only tiles the first row. Can someone tell me what I am doing wrong? As far as I can tell, my code looks correct? Thanks in advance. Oh, I am using JDK 1.4.1 on an iMac running OS 10.2.4 (Jaguar).
    //  DrawGridTest.java
    //  DrawGridTest
    //  Created by James on Sun Mar 09 2003.
    //  Copyright (c) 2003 __MyCompanyName__. All rights reserved.
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.border.*;
    public class DrawGridTest
        public static void main(String[] args)
            DrawFrame frame = new DrawFrame();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.show();
    class DrawFrame extends JFrame
        public DrawFrame()
            setTitle(" Test Grid ");
            setSize(WIDTH, HEIGHT);
            Container contentPane = getContentPane();
            JPanel panel = new JPanel(new GridLayout(15, 15));
            contentPane.add(panel);
            for (int i=0; i < 15; ++i)
                for (int j=0; j < 15; ++j)
                    if (i + j > 0) { panel.add(new GridLabel()); }
        // declare instance variables
        public static final int WIDTH = 500;
        public static final int HEIGHT = 500;
    class GridLabel extends JLabel
        public GridLabel()
            super();
            Border border = BorderFactory.createLineBorder(Color.black);
            this.setBorder(border);
    }

    Well, the (i+j>0) thing was from an example about tiling an image. I thought it would help.
    I changed the setSize method to instantiate a Dimension object, and it's kind of working. Someone mentioned setting the size of the components. I have not found a way to set the size of a JLabel or a JPanel. How do I set the size for each of these? Then I can set the size of the JLabel and compute the size needed for a 15x15 grid on a JPanel. Disclaimer, this is not for work or school. Just something I'm working on. Thanks a lot for all the help.
    James

  • Small code correction

    I am new in Java, I need help for small correction of applet code(I'm not confident how to make this correctly)- I need clean a popup banner at applet loading. The about part , which appears by click on 'about' button, can be left without changes, it does not prevent me.
    Part of a code containing a popup:
    import a.*;
    import java.applet.Applet;
    import java.applet.AppletContext;
    import java.awt.*;
    import java.awt.event.*;
    import java.net.MalformedURLException;
    import java.net.URL;
    import java.util.*;
    public final class dbView extends Applet
    implements Runnable, ActionListener, o, ItemListener
    public void stop()
    if(A != null)
    A.dispose();
    if(t != null)
    t.dispose();
    private void _mthvoid()
    B = a.i.a(getClass(), "Begin.gif");
    e = a.i.a(getClass(), "Right.gif");
    z = a.i.a(getClass(), "Left.gif");
    u = a.i.a(getClass(), "End.gif");
    b = a.i.a(getClass(), "Redo.gif");
    J = a.i.a(getClass(), "Binocular.gif");
    m = a.i.a(getClass(), "Home.gif");
    MediaTracker mediatracker = new MediaTracker(this);
    mediatracker.addImage(B, 0);
    mediatracker.addImage(e, 0);
    mediatracker.addImage(z, 0);
    mediatracker.addImage(u, 0);
    mediatracker.addImage(b, 0);
    mediatracker.addImage(J, 0);
    mediatracker.addImage(m, 0);
    try
    mediatracker.waitForAll();
    catch(InterruptedException interruptedexception) { }
    private int _mthdo(String s1, String s2)
    return s1.indexOf(s2);
    public String getAppletInfo()
    return "Name: Beer Viewer.java\r\nLager Beer: 1.01\r\nPromouter: Best Beer\r\nBest Beer in the world!\r\nFamous light brand.\r\nLegendary Lager Beer\r\ne-mail: [email protected]";
    private void a(Graphics g1)
    g1.setColor(Color.white);
    g1.drawString("Best Beer in the world!", 125, 260);
    g1.drawString("Famous light brand.", 125, 270);
    g1.drawString("Legendary Lager Beer", 125, 280);
    g1.drawString("e-mail: [email protected]", 125, 290);
    private final void _mthfor(String s1)
    if(s1 == null || s1.length() == 0)
    d = false;
    StringBuffer stringbuffer = new StringBuffer();
    stringbuffer.append("Beer Viewer\n");
    if(d)
    stringbuffer.append("Ask for beer: ").append(s1).append("\n");
    stringbuffer.append("Best Beer in the world!, Famous light brand\n");
    stringbuffer.append("Legendary Lager Beer\n");
    stringbuffer.append("Codebase: ").append(getCodeBase().toString()).append("\n");
    stringbuffer.append("Documentbase: ").append(getDocumentBase().toString()).append("\n");
    k = stringbuffer.toString();
    if(d)
    o = new c(this, k);
    private void f()
    remove(q);
    q.invalidate();
    _mthvoid();

    yes

  • Good ideas for pattern design to achieve small code size?

    Hi there,
    i am developing a benchmark set for testing Java performance on J2ME. As this is for resource-constrained devices (PDA, cellphone), the code's size should be as small as possible.
    Here is the funny question: for example i have a class with name "LoopBenchmark", it has its own configuration such as "loop times", "operationType". The main program, running on a desktop could judge the configuration and load the class, Say with following snippet:
    switch(operationType) {
    case: ASSIGNMENT
    for (int i = 0; i < loopTimes; i++)
    int test = 123;
    break;
    case: ADDITION
    for (int i = 0; i < loopTimes; i++)
    int test = 3+7;
    break;
    case: MULTIPLICATION
    for (int i = 0; i < loopTimes; i++)
    int test = 3*7;
    break;
    default:
    System.out.println("unknown operation type");
    I want to create a JAR which could be load to a PDA and running there later. Of course, i hope the JAR could be as small as possible. How can i get just for example:
    for (int i = 0; i < loopTimes; i++)
    int test = 3+7;
    if i know already from the configuration that user wants to run addtion only? I don't want to pack all such SWITCH-CASE handling into the JAR file. Any ideas?
    cheers,
    eedych

    i think that what YATArchivist said goes further than that..
    int switchSelector=2;
    switch(switchSelector){
    case: 0
    //effectively not compiled
    case: 1
    //effectively not compiled
    case: 2
    //yeah you will get this bit
    .....its a guess bassed on faith in the compiler, i admit, but worth a look
    very possible to do, and even 20 year old compilers did this, so i see no reaon why java wont, they would calculate the range of values a variable may have at any point and issue warnings if your program was going to generate errors/ contain redundant code

  • Problem with a small code

    Hello , Can anyone plz tell me how do i get this output from this sample code ? im new to java...
    public class Fact2
    int factorial (int n) {
    int res;
    System.out.println(n);
    if (n == 1) return 1;
    res = factorial (n - 1) * n ;
    System.out.println("res " + res);
    return res;
    public static void main (String [] args) {
    Fact2 f= new Fact2();
    System.out.println("The factorial of this number is " + f.factorial(5));
    The output is :
    C:\Documents and Settings\AM>java Fact2
    5
    4
    3
    2
    1
    res 2
    res 6
    res 24
    res 120
    The factorial of this number is 120
    Here , from 5 to 1 is understood and also the last phrase of course , but from where did the variable "res" have these values 2,6,24 ....

    2: int factorial (int n) {
    3: int res;
    4: System.out.println(n);
    5: if (n == 1) return 1;
    6: res = factorial (n - 1) * n ;
    7: System.out.println("res " + res);
    8: return res;
    9: }
    When you call factorial(5) this will happen:
    It prints 5 (line 4)
    It calls factorial(4) (line 6) - (and waits for it result!!!!!)
    factorial(4) shall print 4, and calls factorial(3)
    prints 3, calls factorial(2)
    prints 2, calls factorial(1)
    prints 1, returns 1returns from factorial(1), multiplies it by 2 (line 6), result = 2
    prints the result to the screen (line 7)
    returns the result (line 8) (thus 2)multiplies the result of factorial(2) with 3 (line 6), result = 6
    prints this result, and returns itmultiplies the result of factorial(3) with 4, result = 24
    prints this result, and returns itmultiplies the result of factorial(4) with 5, result = 120
    prints this result and returns itHope this get things clear to you

  • JPanel disappear

    I put a JPanel in a JFrame.After that I created a new JFrame where I put the last JPanel.When I saw the first JFrame the JPanel did not exist anymore.Why?
    Please help!

    A Component can only be in one Container at a time. Sorry.

  • Mat****a DVD-RAM-841S - Failure and disappeared icon - Code 19

    Hi.
    I am hoping some one can help asap as its a massive problem.
    I turned my A series dual core laptop on to find no DVD drive present, no icons, and nothing working.
    So i checked the device drivers to find this problem:
    *Windows cannot start this hardware device because its configuration information (in the registry) is incomplete or damaged. (Code 19)*
    *Click 'Check for solutions' to send data about this device to Microsoft and to see if there is a solution available.*
    I have checked and there was no solution.
    I have uninstalled and resintalled the device drivers and no luck it says it wont work.
    Please help :)
    Thank you

    Right i followed that link and tried to install the automatic guide...
    Sadly my computer wouldnt activate it and it refused to open.
    So i follwed step 2 and for first time in my life used the registry editor.... that was interesting!
    BUT i got it working, i deleted the values it said and rebooted and BANG! DVD drive is back!
    Thank you very much that was a great reply and good fast service :)

  • Just want to know it this small code is right

    Hello everyone, im back :P
    well, i've been doing exercises, but i don't have the solution yet...so could you tell me if this code is right? thanks.
    About the constructors etc..i think its right, but i not sure about the last method ( distanceFromTwoPoints() )
    If i'd like to test this class, i would ask for 4 coord. (x1,y1) and (x2, y2)..
    And solved the distance between those two points..well
    I don't understand..
    On that code how can i calculate the distance from two points if i just have x1 and y1, i mean ...when i wrote that boolean method ( if the two points are equal) the the "p" variable reference is pointing to x1 and y1 , right? maybe that boolean method is wrong too, cuz i want to compare (x1, y1 ) with (x2, y2) well....when i wrote :
    this.x1 == p.x1 etc both are references to x1 and y1, so returns always true.
    Do i need to write a setMethod to change the values ?
    Is that code comparing two points? thats all i want to know...if yes, so how can i test it?
    public class Point {
         private double x1;
         private double y1;
         public Point(final double x1, final double y1){
              this.x1 = x1;
              this.y1 = y1;          
         public double getX1() {
              return x1;
         public double getY2() {
              return y1;
         public boolean isEqual(final Point p){
              return (this.x1 == p.x1 && this.y1 == p.y1);
         public double distanceFrom2Points (int x1, int y2, Point p){
              return Math.sqrt((this.x1 - p.x1)*(this.x1 - p.x1) + (this.y1 - p.y1)*(this.y1 - p.y1));
    I think this code is just working with two coord. x1 and y1 :S where do i put x2 and y2?
    "p" is a reference to the x1 and y1 variables, so where are the x2 and y2?
    im confused :P
    thanks

    public class Point {
         private double x;
         private double y;
         public Point(final double x, final double y){
              this.x = x;
              this.y = y;          
         public double getX() {
              return x;
         public double getY() {
              return y;
         public boolean isEqual(final Point p){
              return (this.x == p.x && this.y == p.y);
         public double distanceFrom2Points ( Point p){
    return Math.sqrt((this.x - p.x) * (this.x - p.x) + (this.y - p.y) * (this.y - p.y));
    public class TestingPoint {
         public static void main(String[] args) {
              System.out.print("X1: ");
              double x1 = Teclado.doubleLido();
              System.out.print("Y1: ");
              double y1 = Teclado.doubleLido();  
              //Teclad.intLido() reads from the console, something like:
             //Keyboard.intRead(); we use that.
              System.out.print("X2: ");
              double x2 = Teclado.doubleLido();
              System.out.print("Y2: ");
              double y2 = Teclado.doubleLido();
              Point p1 = new Point(x1, y1);
              Point p2 = new Point(x2, y2);
        double distance = p2.distanceFrom2Points(p1.distanceFrom2Points
                                                   (x1,x2));
         System.out.println("The distance is "+distance);
    }the compilation ERROR says: The method distanceFrom2Points(Point) in the type Point is not applicable for the arguments (double, double)
    these are the two classes.
    What is wrong ?
    thanks!

  • Can't find the error on this small code :S

    Hi , i've just compiled this code and i can't find what is wrong! :(
    The compiler is ok, but the output print its not what i was expect.
    If u insert 121 (capicua) the answer is: This number its not a capicua :S
    what is wrong?
    thanks!!
    Note: Don't create another code plz.
    import java.io.*;
    public class Capicua {
         public static void main (String[] args) throws Exception {
              int digit, num;
              int inverted = 0;
                   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
                   System.out.print(" Insert number: ");
                   num=Integer.parseInt(br.readLine().trim());
                   while(num > 0) {
                   digit = num % 10;
                   num = num /10;
                   inverted = inverted * 10 + digit;
                   if(num == inverted) {
                        // to be capicua the number inserted must
                        //be equals to the inverted
                        System.out.println("Its Capicua!");      
                   }else{
                        System.out.println("This number is not a Capicua!");
    }

    Please use code tags (see button above posting box) when posting code. It makes it much easier to read.
    So, it appears that capicua means palindrome--the number reads the same backwards and forwards. Is that correct?
    There are ways of doing this without converting the 121 to a number, but I won't explain that unless you want.
    I think your problem is this line:
    if (num == inverted)
    You have changed "num" within your while loop. Therefore, num is no longer the original input 121.
    Try adding println statements like this to watch what happens:
    while(num > 0) {
      digit = num % 10;
      num = num /10;
      inverted = inverted * 10 + digit;
      System.out.println("digit = " + digit);
      System.out.println("num = " + num);
      System.out.println("inverted = " + inverted);
    }

  • Can somebody please help me with this? Security code issue; very small code

    Hi All, Iam a Unix admin and trying to learn Java/weblogic. I have a JSP and iam trying to run on my weblogic 81 Service Pack version 3.
    My following code failed to work and giving me some security exceptions. Then in my weblogic console i saw
    Domain Wide Security Settings > Anonymous Admin Lookup Enabled
    The above checkbox is disabled. When i enabled, it worked. I talked to my company "Security" folks and they do not allow this checkbox to be enabled. they are saying fix your code problem......
    if somebody can please let me know what a probable fix would, that be great and very helpful.
    try{
    Environment env = new Environment();   
    javax.naming.InitialContext ic = new InitialContext();
    MBeanHome home = (MBeanHome) ic.lookup(MBeanHome.LOCAL_JNDI_NAME);
    DomainMBean dom = home.getActiveDomain();
    Set s = home.getMBeansByType("ServerRuntime");
    ServerRuntimeMBean srmb = (ServerRuntimeMBean) s.iterator().next();
    WebLogicObjectName on = new WebLogicObjectName(home.getDomainName()+":Location="+srmb.getName()+",Name="+srmb.getName()+",Type=ServerConfig");
    //WebLogicObjectName on = new WebLogicObjectName(Name="+srmb.getName()+",Type="ServerConfig",Domain="+home.getDomainName()+",Location="+srmb.getName()+");
    ServerMBean server = (ServerMBean) home.getMBean(on);
    ClusterMBean cluster = null;
    if( server != null)
        cluster = server.getCluster();

    did i asked such a dumb question? ... :)Well, yes, sort of. The problem description "My following code failed to work and giving me some security exceptions" doesn't have nearly enough details. Such as, what exceptions, what is it supposed to do, what did it do instead, that sort of thing.

  • Help with small code

    Hi,
    The matnr exists in the table and it should pull something in, however, the following code is not pulling the matrn:
    SELECT SINGLE MATNR FROM MARC
      INTO LV_MATNR
    WHERE MATNR = XVBAP-MATNR
       AND WERKS = XVBAP-WERKS
       AND ZZLIFNR = LV_ZZLIFNR.
    LV_MATNR is type MARC-MATNR.
    The other variables exist and i checked in the table for a record, but it does pull it up.
    Thanks,
    John

    Just looking at ZZLIFNR i assume that it must be a 10 chracter field, to which you should pass a 10 character value(Padded with enouh 0s).
    on a side note, you do not need to restrict based on ZZLIFNR at all because, the key for mara is MATNR and WERKS only..
    select * from marc into lv_matnr where
    matnr = <material> and werks = <Plant>.
    if marc-zzlifnr <> <Value you want to compare>.
    do some thing.
    else.
    do something else.
    endif.

  • PLZ Help!! Im getting an error in a small code

    when i compile this i get an error saying
    "variable tax might not have been initialized" for the line that says system.out.printin...........
    PLZ HELP!!
    THANKS
    class A1Q2
    public static void main (String[] args)
    double income ;
    System.out.println ("Please enter yearly income: ");
    income = ITI1120.readDouble( );
    char tax;
    if (income <= 37885) {
    tax = 'A';
    } else if ( (income > 37885) && (income <= 75769) ) {
    tax = 'B';
    } else if ( (income > 75769) && (income <= 123184) ) {
    tax = 'C';
    } else if (income > 123184) {
    tax = 'D';
    System.out.println("Tax = " + tax);
    }

    Hello slvr99,
    Firstly, can you please use the CODE button to format your code when you post? It just makes it a lot easier for us to read.
    As for your error, it really is quite literal.
    variable tax might not have been initialized
    means that the variable you have called "tax" may not have been initialized, you just need to set it:
    char tax = '';

Maybe you are looking for