- Upvotes Received
- 0
- Posts with Upvotes
- 0
- Upvoting Members
- 0
- Downvotes Received
- 1
- Posts with Downvotes
- 1
- Downvoting Members
- 1
57 Posted Topics
Hmm I was lookin through a recursion program in this book i have here and the only thing I'm having trouble with is the modulus operator. I know that it returns the remainder of 2 numbers. But, suppose I have this: x % y If x > y then the … | |
Let me explain what I'm supposed to do first. My assignment is to take text from a dictionary entry and display it in my client area. This dictionary entry contains characters like \ " ' and text that's written in Greek. There is an image in the upper left hand … | |
Hi, In on of the lecture notes that was given to me by my prof, I was told that setting the ResizeRedraw value to true would allow whatever I drew on the form to be, well, resized. However, it does not seem to work. Here is my code: [CODE]using System; … | |
When I add buttons to a panel, the buttons seem to take a huge amount of space. How do I get rid of the space? For example: [CODE] import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Tester { public static void main(String[] args) { JButton dayButton = new JButton("Day"); JButton … | |
Ok, I looked in the API and was able to create the scroll bars. Problem is, I can't make them scroll, even though the parameters I passed in explicitly said to have the bars around. What I'm trying to do is to create a scrollpane around a JComponent object that … | |
Suppose I have a week that begins with Sunday and ends with Saturday (so UMTWThFS). How do I get the date for each day of the week if, lets say, we use this month and year? I looked in the API but I wasn't sure what to extract to make … | |
I'm having a little trouble trying to nest two component classes (both extend JComponent) together. When I create the frame in my tester file, instantiate each class, and try to add both of them to the frame, it doesn't come out correctly. For instance, I want my frame to display … | |
1) How do I tell if I have java 5 or java 6 installed? 2) I have my program commented using javadoc syntax. However, when I run javadoc from the command prompt and then open the html files, I do not see any documentation. What am I doing wrong? For … | |
I'm almost finished with this program but the problem I'm having is with freeing the memory I allocated. Particularly in the area where I have pointers to strings. [CODE]#include <stdio.h> #include <string.h> #include <stdlib.h> /////////////// user defined data ///////////////////// struct State { char * name; // state name int year; … | |
The problem is that I have an ArrayList which stores objects that contain a Shape (actually a Composite shape like a Car) and (x,y) coordinates. Suppose I'm supposed to retrieve each object and the coordinates for drawing. My question is, how do I draw an Shape on the screen at … | |
I'm trying to put all the buttons (and their icons) into a single class. However, when I try to draw just one button in a frame, it doesn't show up. I can get it to be displayed if I instantiate the button in the same class as the Frame, but … | |
I'm stuck trying to figure out how to update the text field after I click on the button in the GUI. The number of roaches is supposed to be updated each time I click, but I can't seem to find the right tool for the job in the APIs. RoachPopulation.java … | |
This is a relatively simple program but for some reason, I can't compile it. I'm pretty sure the code is correct and working. My compiler keeps saying that it cannot find a constructor matching a HourlyWorker constructor when I instantiate a HourlyWorker object. I've checked and rechecked the code (in … | |
I did a quick search on the forums and there was another problem similar to the one i'm trying to solve. I'm supposed to use the first word of a sentence as a search parameter and check the rest of the string for occurences of the word. If the word … | |
So we're supposed to modify this class, which implements Comparable, so that it accepts any type of object. The Comparable interface contains the method signature for compareTo, which I need to implement. What I'm uncertain of is how to implement this method. I know that compareTo is supposed to return … | |
So here's the problem [QUOTE]Write a program that asks the user to input a set of floating-point values. When the user enters a value that is not a number, give the user a second chance to enter the value. After two chances, quit reading input. Add all correctly specified values … | |
I'm supposed to design a method that takes in a double value and translates the value into the closest letter grade. 4,3,2,1,0 denote A, B,C,D,F, respectively. + increases a grade's numerical value by 0.3 and - decreases a grade's numerical value by 0.3. There is no F+ or F-. A+ … ![]() | |
Ok, so my goal is to draw a rectangular spiral in java. So far, I've created the Spiral Viewer class and the SpiralComponent but I'm not quite sure how I would implement the SpiralGenerator class. Here's what I have: SpiralViewer: [CODE]import javax.swing.JFrame; /** Test driver for Spiral class. */ public … | |
I'm trying to get this ISBN checker to work. I've used the formula from this [URL="http://mathworld.wolfram.com/ISBN.html"]site[/URL] and also this [URL="http://en.wikipedia.org/wiki/International_Standard_Book_Number"]site[/URL] and it seems to work fine [B]except[/B] for the ISBN of my Java book. When I compute my book's ISBN (0131496980), it is apparently invalid. I have tried the other … | |
I was a little confused by the brief explanation that my Assembly teacher gave on pipelining. I don't think I really understand the process that well... 1) In a 4-stage non-pipelined processor, how many clock cycles does it take to execute 3 instructions? Assume each stage takes 1 clock cycle. … | |
One of the things that's been confusing me so far is why we have to override the paintcomponent() function after extending it. For example, this program draws an ellipse: [CODE]import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.geom.Ellipse2D; import javax.swing.JComponent; public class DrawEllipseComponent extends JComponent { public void paintComponent(Graphics g) { … | |
Hi, I need help with drawing an ellipse that is bounded by the window it is drawn in. I have to use the Ellipse2D API. Maybe I'm overlooking something but I can't seem to get the circle to fit the window. This is what i have so far: [CODE]import java.awt.Color; … | |
If I do a public inheritance and the member data in the base class I'm deriving from is protected, is the only way to access the data in the base class via member/friend functions of the derived class? | |
Hi, I can't get the following code to work. I have my converting constructor (second line) to change an int type to a car type but my compiler says there's something wrong with the overloaded + operator. It says here in my book that if I want to do an … | |
How do i dereference a pointer to something in a class without having to write another function to dereference it for me? For instance in this code: [CODE]class Fraction { public: Fraction(int left = 0, int right = 1); Fraction(Fraction & obj); ~Fraction() { delete fl; } double getFraction() { … | |
The problem I'm having is with overloading the >> operator so that I could read data from a file directly into a class's member data. Everytime I run through the program, it just crashes. when I look through the debugger, it brings me to some page of crazy code. So … | |
I'm having a bit of a problem with function style cast with classes. When I exit the function I expect an instance of Database to be returned. This instance would then be copied into the db declared in main. I've writtien a copy constructor and it works fine (tested by … | |
This might seem like a silly question, but how do I read in a newline char, by itself, as input? For example, if I gave the user a choice to enter a string for a new filename, or let them just press ENTER for some other choice. forgot to add … | |
If I have a dynimcally allocated array of objects and each of these objects contains a pointer to a string, when I use the 'delete' function to return memory, do I have to go through each array element and free each string individually or does the 'delete' take care of … | |
So in my class we just finished covering the topic of constructors and destructors. Now, my teacher has given us a lab where we have to create these classes and each of them must have a ctor/dtor. The problem I'm running into is..well.. it would be easier to describe in … |
The End.