Sniffy Posted March 15, 2007 Share Posted March 15, 2007 Check out my latest creation.... do you like it?Instructions:Install SDK: http://java.sun.comCreate new file: ExampleJFrame.javaInsert Code: import javax.swing.*;import java.awt.*;import java.awt.event.*;public class ExampleJFrame{ public static void main(String[] args) { JButton press = new JButton("Show"); JButton press2 = new JButton("Hide"); JButton press3 = new JButton("Clear"); final JFrame frame = new JFrame("Example"); JFrame frame2 = new JFrame("Menu"); frame.setSize(200, 200); frame.setResizable(false); frame.getContentPane().setLayout(new FlowLayout()); frame.show(); frame2.setLocation(200, 0); frame2.setResizable(false); frame2.addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e) { System.exit(0); } }); frame2.setSize(200, 200); frame2.getContentPane().setLayout(new FlowLayout()); frame2.getContentPane().add(press); frame2.getContentPane().add(press2); frame2.getContentPane().add(press3); frame2.show(); press.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { frame.setVisible(true); } }); press2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { frame.setVisible(false); frame.getContentPane().add(new JLabel("" + frame.getLocation())); } }); press3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { frame.setVisible(false); frame.getContentPane().removeAll(); frame.setVisible(true); } }); } } Command Prompt: OpenType commands:javac ExampleJFrame.javajava ExampleJFrame.javaWhat do you think?What it does:Use the "Menu" frame to either "Show", "Hide", or "Clear" the JFrame "frame2" of content. Content is added each time "frame2" is shown. It displays its current location (x,y) on the screen with the java.awt.Point class.somethings wrong with my PC so i can't supply a preview at the moment Link to comment Share on other sites More sharing options...
Nakor Posted March 15, 2007 Share Posted March 15, 2007 Good job. I really believe that Java is going to become very big soon. It's my personal favorite programming language. I remember just starting out on JFrames. You will be getting into some very interesting things soon I'm sure. Link to comment Share on other sites More sharing options...
aspnetguy Posted March 16, 2007 Share Posted March 16, 2007 Good job. I really believe that Java is going to become very big soon. It's my personal favorite programming language. I remember just starting out on JFrames. You will be getting into some very interesting things soon I'm sure.Java is already a popular language in fact some suggest it is the most popular http://www.tiobe.com/tpci.htm Link to comment Share on other sites More sharing options...
Nakor Posted March 16, 2007 Share Posted March 16, 2007 Yes, but so much of the programming community seems to be stuck on the C languages. I have noticed that more people are moving to Java and it is a good thing. I just felt as if it would have already completely taken the place of C++ or C. Link to comment Share on other sites More sharing options...
aspnetguy Posted March 16, 2007 Share Posted March 16, 2007 Java is a great language but I don't think it could ever replace C/C++. OS's are still written in C/C++, games need the low level processing speed to mange memory and graphics efficiently.Maybe I am wrong but can Java really compete in these areas? Link to comment Share on other sites More sharing options...
jesh Posted March 16, 2007 Share Posted March 16, 2007 I gave up on Java 6 years ago. Is it really as popular now as you are saying it is? I don't see too many sites with .jsp or .jhtml file extensions these days. And Flash seems to be much more widely used than Java Applets. Link to comment Share on other sites More sharing options...
aspnetguy Posted March 16, 2007 Share Posted March 16, 2007 Java is used for far more than web applications/applets. While I couldn't name any real world products that use Java (not because there aren't any but because I don't know of any) there must be some.I don;t know how accurate those stats are , I was a little surprised to see Java as #1 Link to comment Share on other sites More sharing options...
jesh Posted March 16, 2007 Share Posted March 16, 2007 Java is used for far more than web applications/applets. While I couldn't name any real world products that use Java (not because there aren't any but because I don't know of any) there must be some.Ah, yes. Link to comment Share on other sites More sharing options...
Nakor Posted March 16, 2007 Share Posted March 16, 2007 Java will probably never be able to compete with C/C++ in the OS field but it does have the capabilities to do graphics processing. In my trials with C++ and Java comparatively I found that Java was not only more efficient at executing graphics commands, but it did it faster. Of course the advantage of C/C++ is that it doesn't require a RTE like so many Java applets do. When I first started into JSP I felt that it wasn't being used much, however I think that a large amount large scale web applications use Java or JSP. I feel that Java is strong in being seamless, and if done server side, entirely invisible to the user. Of course it will probably be that Java and C/C++ will end up 'merging' in a non-conventional sense. Link to comment Share on other sites More sharing options...
Sniffy Posted March 16, 2007 Author Share Posted March 16, 2007 Does anyone have a tutorial on nested classes, I've been meaning to look into it. Link to comment Share on other sites More sharing options...
Sniffy Posted March 16, 2007 Author Share Posted March 16, 2007 Also, here is another one of my past creations:aApplet.java import javax.swing.*;import java.awt.*;public class aApplet extends JApplet{ Container con = getContentPane(); String speech = " Duis nec lectus. Etiam aliquet, nulla non elementum"; String speech2 = "aliquam,libero urna rhoncus eros, vel luctus"; String speech3 = "tellus urna at mauris. Sed tincidunt consequat"; String speech4 = "erat. Nulla facilisi. Cras varius. Suspendisse"; String speech5 = "posuere turpis ac sem. Phasellus vulputate"; String speech6 = "commodo lacus.\n Sed auctor. Aliquam venenatis"; String speech7 = "tellus eget dolor. Sed risus."; public void start(){ repaint(); } public void paint(Graphics gr){ gr.drawRoundRect(9, 9, 301, 151, 20, 20); gr.setColor(Color.CYAN); gr.fillRoundRect(10, 10, 300, 150, 20, 20); gr.setColor(Color.BLACK); gr.drawString(speech, 20, 25); gr.drawString(speech2, 20, 40); gr.drawString(speech3, 20, 55); gr.drawString(speech4, 20, 70); gr.drawString(speech5, 20, 85); gr.drawString(speech6, 20, 100); gr.drawString(speech7, 20, 115); gr.fillRect(40, 140, 200, 10); }} Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now