Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
R

rareseu

@rareseu
About
Posts
24
Topics
6
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • JScrollPane child dimesniosn not updating
    R rareseu

    I see now :) thank you for explaining !

    Java graphics help java question

  • JScrollPane child dimesniosn not updating
    R rareseu

    I don't understand :| , do you mean the last item in the scrollpane ? there is only the viewport in there, can you please explain ?

    Java graphics help java question

  • JScrollPane child dimesniosn not updating
    R rareseu

    Hy guys ! i'm running into a bit of trouble with a JScrollPane, the pane itself has to stay the same size but the viewport inside the pane has to get longer as i add stuff to it( right now i'm just drawing circles downwards) the problem is that when the viewport gets big enough to require scrolling my drawing dissapears my globals :

    //global variables :
    //params for the circle i draw :
    public int positionY=10;
    public int positionX=20;
    public int width=30;
    public int height=30;

    //used to set dimension of the viewport :
    private Dimension dim=new Dimension();
    
    //the viewport in which i draw, it extends JViewport
    private MyJViewport drawHere=new MyJViewport();
    
    private JScrollPane displayResult;
    
    private JButton jButton1;
    

    the MyJViewport class :

    class MyJViewport extends JViewport {

        @Override
        public void paint(Graphics g) {
            g.setColor(Color.BLUE);
            g.fillOval(positionX, positionY, width, height);
    
        }//paint
        
    }//MyJViewport
    

    in the constructor i instance the scrollpane :

    displayResult = new javax.swing.JScrollPane(drawHere);
    displayResult.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    displayResult.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

    the event handler for the button press:

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    //the new circle will be positioned under the previous
    positionY+=height;

        // if the point where the circle gets drawn exceeds the bounds of the viewport
        // resize the viewport
        if (positionY > drawHere.getHeight()) {
                dim.height = drawHere.getHeight() + height;
                dim.width = drawHere.getWidth();
                drawHere.setPreferredSize(dim);
                drawHere.revalidate();
                
            }//if
    
        drawHere.repaint();
    }
    

    can anyone help with this ?

    Java graphics help java question

  • Getting an applet's components returns null
    R rareseu

    tried that :| , even inside the paint method , nothing works :| btw thanks for all your time fly904 :)

    Java data-structures question

  • Getting an applet's components returns null
    R rareseu

    i really don't have a choice aside from working with netbeans sice my deadline is close and it could never be done in time if i learned how to do it by hand the call is like this :

    public void init() {
    try {
    initComponents();// added by netbeans, uneditbale(have to trick it into adding code here)
    initMyComponents();//added by me, but didn't work
    } catch (Exception ex) {
    ex.printStackTrace();
    }
    }//init

    is there any other way to tell when the initialization is over, or when initComponenets is done executing?

    Java data-structures question

  • Getting an applet's components returns null
    R rareseu

    I suspected that was it, i made my gui using netbeans IDE and it generates an initComponents method , and even tho i used getComponents inside this method afetr it instances the componenets i still get null :|

    Java data-structures question

  • Getting an applet's components returns null
    R rareseu

    Hy guys ! i'm trying to make an array with the components of my applet like this : instancing :

    public Component\[\] componente=new Component\[100\];
    /\*\* Initializes the applet tester \*/
    @Override
    public void init() {
        try {
            componente=this.getComponents();
            ...
    }//init
    

    and displaying in a textArea :

        for (int i=0;i
    

    the result i get is :

    componente :
    0 null

    my applet however has plenty of componenets, does anybody know why this might happen ?

    Java data-structures question

  • Drawing in a canvas
    R rareseu

    Thank you soo much, you're a life saver :D

    Java graphics java tutorial

  • Drawing in a canvas
    R rareseu

    Aaah i see now , but if i don't implement the class with threading(which i'm trying to avoid just because it would add more complexity ), what would be a good mechanism to call the repaint method ? btw thanks for your patience, and sorry for all the noobie questions but my deadline is closing in fast and i haven't even gone into the difficult part of the project

    Java graphics java tutorial

  • Drawing in a canvas
    R rareseu

    [quote]What I normally do is to override the default paint method in the Canvas class. Have a look at this[^]. The SweepCanvas class is the basic principle, just remove the threading obviously. [/quote] good tip :) thank you, what i don't understand is where the run method gets invoked ( and as a consequence the repaint method), If anyone could explain this i think i could get the hang of how this class works. I see that the trick to making this work is calling the paint method using repaint() which saves you from making a Graphics instance( not the most obvious solution but i cant afford to be picky right now).

    Java graphics java tutorial

  • Drawing in a canvas
    R rareseu

    That's an awesome tip Jimmanuel thanks :)

    Java graphics java tutorial

  • Drawing in a canvas
    R rareseu

    [quote]If the IDE has defined a new class for you that extends from it then shouldn't it be as simple as overriding it's paint method? [/quote] the IDE creates an instance of the class Canvas, the class that extends Canvas part was in the sun example

    Java graphics java tutorial

  • Drawing in a canvas
    R rareseu

    i hear what you're saying, but i can't instace it like

    g=new Graphics();

    because it's abstract, the null thing is automated correction from netbeans, it's the only way it will let me use g the problem i have with sun's exmaple is that i see no point in defining an object that inherits the Canvas to do nothing different that what canvas is supossed to do, it would also render my canvas objects useless and the ability to drag and drop canvas stuff from the IDE pointless

    Java graphics java tutorial

  • Drawing in a canvas
    R rareseu

    Hy guys ! i've been using netbeans to make a GUI, and i'm having rpoblems figuring out how to draw stuff using the canvas object, i've created a canvas object but it needs a graphics object in order to draw stuff, and that's where my problems start, for the life of me i can not understand how to use one of these this is what i've tried so far :

    Graphics g=null;
    g.setColor(new Color(255,0,0));
    canvas1.paint(g);

    when i run this java flares up with null pointer exceptions altho the canvas itself has been instantiated i've looked on the sun homepage for guidance but there is no hint on how to use an instance of a canvas object, they way they show is by creating a class that inherits Canvas and overwriting it's paint method, but that's no use to me

    Java graphics java tutorial

  • label in java
    R rareseu

    [quote]i want if b not equal to 12 then "a final is" is print. and b increase and also a is but it not?[/quote] have you tried my code ? that's basically what it does

    Java help c++ java question

  • label in java
    R rareseu

    why not just make test into a function or method and invoke it, im not sure what your code is supossed to do, but if it's supossed to continue executing untill b is 12, i've written an example :

    class jumping{
    public static void main(String[] args){
    int b,c;
    float a;
    b = 8;
    c = 2;
    test(a,b,c);
    }//main

    public void test(float a, int b, int c)
    {
    for( ; ; ){
    a = b/c;
    System.out.println("a first is "+a);
    while(a<=10){
    b++;
    System.out.println("b in continue is "+b);
    if (b==12)
    {
    System.out.println("a final is "+a);
    return;
    }

    }//while
    

    }//for

    }//test

    }//jumping

    ps : ident your code, it's very difficult to read otherwise, and use the code block ps2 : someone should disbale smileys in the code block

    Java help c++ java question

  • tcp server applet
    R rareseu

    [quote]You might have something else on port 80? This is the main port used by HTTP, so if you've got another web-service it may well be in use. Try running it up pointing to a DIFFERENT port and see what happens. [/quote] allready tried , it locks up at the ServerSocket instantiation, and starting today it lock up on 80 too, i have absolutelly no clue what i'm doing wrong

    Java java wpf wcf sysadmin help

  • tcp server applet
    R rareseu

    i'm uploading the server class and test web page if it will help sort this out here it is : [url]http://uploading.com/files/XQ0TGHPT/server.rar.html\[/url\]

    Java java wpf wcf sysadmin help

  • tcp server applet
    R rareseu

    Hy guys ! i'm having a problem getting my tcp server applet on it's feet, the problem is that it doesn't get past instantiating a socket, if i instatiate it with port nr 80 it throws an exception ( Address already in use: JVM_Bind ), with other ports it just locks up at the "binding port" part

        ServerSocket server;
        int port= Integer.parseInt(portNumber.getText());//port number's a text field
        status.setText("Starting server..\\n");//status is a text area
    
        try {
            status.append("Binding to port " + port + ", please wait  ...\\n");
            server = new ServerSocket(port);
        } catch (IOException ioe) {
            status.append("EROARE la creearea socketului\\nEXCEPTIE:
    

    "+ioe.getMessage()+"\n");
    return;
    }

    does anybody have a clue why this happens?

    Java java wpf wcf sysadmin help

  • managing multiple socket connections !?
    R rareseu

    Thanks for taking the time to explain Ravadre :), i really appreciate it, i'm gonna need some research time to understand the classes and methods you're using. I guess the reason i'm being a little vague with my questions is because i'm not quite sure what i need to make this work, this is the first time i'm working with sockets under c# ( done it once before in c under linux )

    C# sysadmin tutorial question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups