Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
PuTTY riot
Nov 16, 2002
OK, I know homework questions are frowned upon here, but I just want to make sure I'm on the right track. We are supposed to create a real-world entity, then make a subclass that is a specialized form of that entity. I've got both of those done. (CellPhone and SmartPhone, smart phone having data minutes in addition to regular minutes and all the other stuff cell phone has via super();).

The final part is where I'm getting a little confused. it says 'Illustrate composition by developing a third class that is used by one or both of the first classes[in my case cell/smartphone]'. I'm planning on creating a customer class that 'has-a' cell phone or smart phone. Is this what y'all think he's trying to get us to do? If i create a constructor with a cellphone argument, can I put a smartphone in there?


edit: Okay, I threw the customer class together and I could use either one. I'm pretty sure I'm on the right track, but I'd still greatly appreciate any advice.

PuTTY riot fucked around with this message at 21:41 on Mar 15, 2008

Adbot
ADBOT LOVES YOU

PuTTY riot
Nov 16, 2002
See, this is why I came in here for a second opinion. I had the right idea but I misread what he wanted us to do. Went ahead and used the phone number idea, it took some more work than the customer class, but I need an A in this class so I don't really care. Thanks for the help.

PuTTY riot
Nov 16, 2002

shodanjr_gr posted:

I am writing some SWING code for a UI and i have an issue.

I am using a custom container, which is basically a JPanel viewed through a JScrollPane (this class extends JScrollPane). On this JPanel i add another custom component (which extends JComponent and is a combination of JPanels and JTextPanes) multiple times.

My issue is the following.

Lets assume that the container has a heigth of X, and the component a height of X/4. If i add less than 4 components in the container, then, instead of leaving the rest of the viewport empty, the components somehow "stretch" to fill the viewport (which screws up their appearance big-time). If i add 4 or more, everything is fine and dandy...

Ive tried various layouts for the container, and it doesnt seem to be helping...

Any ideas fellow Java-goons?

If anyone needs code snippets let me know and ill post it.

The code would probably help. Have you tried something like setLayout(new GridLayout 0,4)? If your component's size is not fixed that could have something to do with it too.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply