llemes4011 31 Posting Whiz in Training

Hello! Most Applets now extend the JApplet class now. (JApplet is part of the javax.swing package) So you should probably be extending that instead. also, all applets make a call to init(), start(), destroy(), and stop(). The paint() method is located in the Container class. anyways, that's just some background info for applets. You should add in the above methods to your code, because they're called by the browser to start the applet. hope this helps =)

llemes4011 31 Posting Whiz in Training

No, you do not have 100,000 panels on top of each other. But if the screen is still being filled with black, you might want to insert the line:

super.paintComponent(comp);

as the first line in your paintComponent() method, as VernonDozier. That removes the previously painted Graphics before painting the next String (I think that's what it does, if I'm wrong, please, somebody correct me, lol). As for the paintComponent method, it's called by the Window that holds the JPanel, in this case your JFrame. The JFrame class has a method paintComponents() inherited from the Container class. I believe this method is called from the JFrame's paint() method. Hope that helps!

freelancelote commented: Thank you lad. Great help. +2
llemes4011 31 Posting Whiz in Training

That's alright. you can still make a tray icon, in Java 1.6, there is a SystemTray class that can add an icon to the tray, and you don't have to mess with JNI (YAY!)

llemes4011 31 Posting Whiz in Training

If you're asking about how to bring UP a window or do something when a hotkey is pressed, it would involve making an invisible Window that's always on top of everything else, and adding a key listener to that. (I think that would work, I haven't tried it, but I want to XD)

llemes4011 31 Posting Whiz in Training

If I'm understanding your question, you want to know how to pass ArrayLists as arguments to methods, right? It's the same as any other arg.

public void func(ArrayList<Double> arrayList){}
llemes4011 31 Posting Whiz in Training

Hi. First off, please correctly use the code tags:
http://www.daniweb.com/forums/announcement9-3.html

Second, the syntax for drawString is: (Most likely used in the paint method)
<GraphicsObject>.drawString("Text/String", xLoc, yLoc);

Third, using pack() instead of setSize(int, int) is going to make your Window as small as possible, only constraining to the minimum sizes of the components in your window, which you don't have.

llemes4011 31 Posting Whiz in Training

A) If it works, mark the thread as solved.
B) If you have another question, unrelated to this thread, please start a new thread. StringBuffers have nothing to do with this thread.
C) A StringBuffer is irrelevant here. It is mainly used for adding onto the string, and I don't think you're foin that anywhere. If you really want to use one, look at the StringBuffer class in the Java API for how to use it.
D) You don't need to post all of your code every time. Post only the problem area, or write an example that demonstrates your problem. The above code seems to work fine as long as you enter a value into the JOptionPane.

llemes4011 31 Posting Whiz in Training

If you don't enter anything in the Textfield and press ok, or press cancel, it will give you that error.

This probably isn't what you're looking for, but read this article about JOptionPanes:
JOptionPanes

also, get rid of those lines that need the ), I posted those to show the syntax, not as actual code to use in the program.

llemes4011 31 Posting Whiz in Training

When you try to convert a String to an int, you have to be careful. If you don't put a value in, or type a letter by mistake, it can lead to strange results. Try defaulting the JOptionPane's value at first, so if the user accidently hits ok or cancel before typing anything, it doesn't throw an error. checking after they enter wouldn't be a half-bad idea either. You do that with the JOptionPane.showInputDialog(null, String message, String title, int messageType) ;

Hope that helps!

llemes4011 31 Posting Whiz in Training

yes, but after the foo.doSomething() line, put a "}" to close the method.

also, you don't want another main method inside class foo, call it something else, and it probably doesn't need the String[] args parameter either.

llemes4011 31 Posting Whiz in Training

you don't want to declare class foo inside your main method. close the method before coding the foo class

llemes4011 31 Posting Whiz in Training

No problem, don't forget to set the thread to solved =)

llemes4011 31 Posting Whiz in Training

O.o That's a lot a white space 0.0 In the future, try to write and post a simple example of what's wrong instead of posting your entire code.

public class Change {

    public static void main (String[]args){

    String m1, m2, m3, m4, m5, m6, m7, m8, asa, m0, naman, temp="";
    int x, a;
    String[] m9= new String[15];
    String[] m10= new String[15];
    public class foo{ // (here) illegal start of exp. and ';' expected

        public static void main (String[]args){

That's what you get when you format the code you posted correctly. It seems like you are trying to code a class inside a method, which isn't allowed in Java.

it should look something like this:

public class Change{
    // Classwide variables here can be accessed in class Foo
    public static void main(String[] args){
        Foo foo = new Foo(); //make an instance of the nested class
        foo.doSomething();  // Call a method like you normally would
    }
    static class Foo{ //note the lack of the "public" identifier here
        // The class has to be be static inorder to access it from a static method
        public void doSomething(){
            //do something
        }
    }
}

nested classes are tricky and should probably be avoided if you're new to java

llemes4011 31 Posting Whiz in Training

Oh, Ok, i think I see.
you need to do something like this:

class newuserListener implements ActionListener{
    public void actionPerformed(ActionEvent ev)
    {
        optionsGUI tx = new optionsGUI();
        tx.JTabbedPane.setSelectedIndex(1);
    }
}

replace JTabbedPane with variable name of method below:

you need to point to the GUIs TabbedPane. if it's private, set it to public or have method:
public static void getTabbedPane(){return "JTabbedPane_variable_name";}


i THINK that's it ;)

llemes4011 31 Posting Whiz in Training

Hi! Welcome to DaniWeb!

When Posting code please wrap the code in

tags so it's easier for people to read ^_^

As for your question, you can't declare a public class inside another class.  public means that the class can be accessed by any class.  Inner classes can not, they can only be accessed through the outer class.

Sun has a decent tutorial covering Nested Classes, and can explain better than I can:
http://java.sun.com/docs/books/tutorial/java/javaOO/nested.html

Also, all import statements must be declared before the Outer class
[CODE="Java"]
import java.awt.Graphics;
import java.util.Random;

public class foo{
    //ACK!! Error!, can't import classes within a class
    import javax.swing.JFrame; 
}

But you don't need to import javax.swing.* again. imported classes can be accessed within nested classes as well.

Hope that helped!

Happy coding!

llemes4011 31 Posting Whiz in Training

in the JTabbedPane class there is a method setSelectedIndex(int index). where 0 is the first tab, 1 is the second, ect. (I believe that is how it works, you can also select the tab with the method, setSelectedComponent(Component c). where c is the component that the tab represents. Hope this helps =)

llemes4011 31 Posting Whiz in Training

I suggest taking a look at the JFileViewer class.

llemes4011 31 Posting Whiz in Training

after you send the contents of the text area, set the contents to nothing (ie. JTextAreaObject.setText("");) Hope that clears some of it up

llemes4011 31 Posting Whiz in Training

I suggest taking a look at the InputEvent methods that are inherited by the KeyEvent class. One of them is "isControlDown()" look at that one. =)

llemes4011 31 Posting Whiz in Training

Arrays - Here

ArrayLists - Here

llemes4011 31 Posting Whiz in Training

What if when you resize the JFrame, you pass the JTabbedPane the width and height through the

resize(int width, int height)

method while resizing the JFrame?

llemes4011 31 Posting Whiz in Training

you could check the number of characters in the string, break it up into sections using a String ArrayList, and insert a \n after each string portion

llemes4011 31 Posting Whiz in Training

if you messed with it enough, the modulus would work... but... it's a hassle, and breaking the String apart using the Scanner class is easier, in my opinion. If you create a Scanner that reads the specific String, you can add a delimiter to the scanner, and go through each spot and store the numbers into an array, and then print the array spaces while putting a space between each one.

Everything you need is right here in the Scanner class. http://java.sun.com/j2se/1.5.0/docs/api/java/util/Scanner.html

Knowing how to use the API efficiently is one of the most important things to know, regardless of how much experience you have. =]