Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

java homework

Name: Anonymous 2007-01-23 6:01

"Write an application that displays a frame containing two panels. Each panel should contain two images (use four unique images - your choice). Fix the size of the first panel so that both of its images remain side by side. Allow the other panel to change size as needed. Experiment with the size of the window to see the images change orientation. Make sure you understand why the application behaves as it does."

This is what I have, but the book doesn't say how to tell a panel to change its size or allow its labels to rearrange as needed, it only showed that will happen to the primary panel and its components in a frame. Apologies for being a noob.

import java.awt.*;
import javax.swing.*;

public class Faces
{
   public static void main (String[] args)
   {
      JFrame frame = new JFrame ("Sum Faces!!");
      frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);

      ImageIcon face1 = new ImageIcon ("face1.jpg");
      ImageIcon face2 = new ImageIcon ("face2.jpg");
      ImageIcon face3 = new ImageIcon ("face3.jpg");
      ImageIcon face4 = new ImageIcon ("face4.jpg");

      JLabel label1 = new JLabel (face1);
      JLabel label2 = new JLabel (face2);
      JLabel label3 = new JLabel (face3);
      JLabel label4 = new JLabel (face4);

      JPanel subpanel1 = new JPanel();
      subpanel1.setBackground (Color.white);
      subpanel1.setPreferredSize (new Dimension(650, 220));
      subpanel1.add (label1);
      subpanel1.add (label2);

      JPanel subpanel2 = new JPanel();
      subpanel2.setBackground (Color.yellow);
      subpanel2.add (label3);
      subpanel2.add (label4);

      JPanel primary = new JPanel();
      primary.setBackground (Color.black);
      primary.add (subpanel1);
      primary.add (subpanel2);

      frame.getContentPane().add(primary);
      frame.pack();
      frame.setVisible(true);
   }
}

Name: Anonymous 2007-01-23 6:10

I guess I should inaugurate this thread:

Java sucks

Name: Anonymous 2007-01-23 7:32 (sage)

Thread over

Name: Anonymous 2007-01-23 22:12

Thanks, that was helpful.

Name: Anonymous 2007-01-23 22:23

Stop being a tool, and go look at java API's

Name: Anonymous 2007-01-23 23:12

HMMM WHATS THE POINT OF HOMEWORK? OH YEA!!! TO DO IT AND FUCKING LEARN SOMETHING!!!  EARN YOUR OWN GRADES FUCKTARD

Name: Anonymous 2007-01-24 4:10

>>6
You are missing one thing, this guy is going to become a Java programmers, for Java programmers there is no requirement of actually knowing the language.

Name: Anonymous 2007-01-24 6:10

>>5
How do I do that?

Name: Anonymous 2007-01-24 6:49

>>1

No-one here actually knows how to solve your problem, so they deride Java instead.

Name: Anonymous 2007-01-24 8:14

>>9
Truth.

>>6
This is a way of learning. And finishing the homework. It is also painfully obvious that you are unable to help him. Fucktard.

Name: Anonymous 2007-01-24 9:42

We never did something interesting like this in my java class ;)

it was all console junk and a few applets that were only able to run if you used the IDE :P

Check Sun's documentation. They have some pretty in-depth lists of the methods you can use with each object.

Name: Anonymous 2007-01-24 10:23

>>7
I've seen these people work, for real. All they do is Google snippets and copypasta them over and over. They have to do something that deals with running an external command? They Google it. Connecting to a web service? They Google it. Then they see how they can adapt the code (if at all) and copypasta it. (They usually copypasta first, fail, then adpat.)

>>9
I would know, but I want to forget... Writing Java was the least fun stuff I had to do at work at one point. Java sucks as a language and as an API. Just Google for Sun Java stuff and you'll see what Java is about: optimizing cash flows to creaete synergies between your enterprise departments that increase your profits and reduce TCO.

You know something sucks when it has anything to do with businessmen and managerspeak.

Name: Anonymous 2007-01-24 15:46

Well screw it then, it's a really really really small part of my grade. And I don't really want to learn Java, I just need a programming course.

Name: Anonymous 2007-01-24 16:04

>>9
No-one here actually knows how to solve your problem
It's not that I don't know, it's just that I don't give a flying fuck about it. I could write it in a thousand languages, but not Java, it sucks you know? I could write this using Qt, it would be prettier, easier, faster to write and execute, extensible and more cross-platform than a thousand Java virtual machines. I deride Java because it sucks.

Name: Anonymous 2007-01-24 17:28

>>14

I bet you've never even used it, fag

Name: Anonymous 2007-01-24 22:07

>>10

Wrong. I am very well able to assist, but why give out freebies? I earned my own grades through something called personal effort. bite me.

Name: Anonymous 2007-01-25 0:15

Why reinvent the wheel?

Name: Anonymous 2007-01-25 15:39

>>15
I've used Qt 10 times more than Java for a reason: it is useful and usable. But it was just an example, I could tell you about STL, Boost or QuantLib but you're too stupid to know about these libraries that kick the crap out of Java.

Name: Anonymous 2007-01-25 21:10

http://java.sun.com/javase/6/docs/api/ is the api, they're fairly noob friendly

I suggest trying

subpanel1.pack();

If you really need help, I could figure it out for you, so ask

Name: Anonymous 2007-01-26 15:51

>>17

To better understand how a wheel works

Name: Anonymous 2009-01-14 13:47

WHBTE

Name: Anonymous 2009-03-06 9:34


The bus itself followed   by the loud   booming cry of   HAVE YOU READ   Your SICP today   which felt as   if it was   totally fucking obvious   Trolling is a   very profound experience   It can be   accessed using the   command line behaved   the same way   others do In   a few weeks   Nothing wrong with   Haskell and Parsec!

Name: Anonymous 2009-03-06 12:53


Programmers is there any good tutorial for   using EVP functions   and blowfish symmtetrical.

Name: Anonymous 2010-12-25 6:22

Name: Anonymous 2011-12-30 3:34

ENTERPRISE BUMP

Name: Sgt.Kabukimanꐢ♓ 2012-05-28 21:55

Bringing /prog/ back to its people
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy

Don't change these.
Name: Email:
Entire Thread Thread List