I guess you could start here: http://download.oracle.com/javase/tutorial/networking/index.html
Anything more specific would require a more specific question.
I guess you could start here: http://download.oracle.com/javase/tutorial/networking/index.html
Anything more specific would require a more specific question.
No, that is not what he was asking - two years ago by the way.
Are you running this on a 64-bit machine with 32-bit MS Access installed?
Calculate the center point (appW/2, appH/2) and then use those to figure where to place your upper left corner of the rect.
Do you have a DSN entry called "CBIRS"?
Use dispose if you explicitly obtained the graphics reference with a createGraphics() or getGraphics() call. You don't need dispose() on a reference that you are passed via paint() or paintComponent().
Just a couple of minor things. The main trouble is that you don't reset y to zero, so it quickly goes right off the screen after the first call to paint.
Here's your painting method revised. You should normally override paintComponent() instead of paint() unless you need to change other things that paint() is doing. paintComponent() is the more specific method that is called to render the panel itself.
public void paintComponent(Graphics g) {
super.paintComponent( g );
Graphics2D g2 = (Graphics2D) g;
// Reset your starting y value here
y = 0;
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 3; j++) {
g2.drawString(twoDCells[i][j], x, y);
y += 30;
}
}
// You don't really need these here.
// Toolkit.getDefaultToolkit().sync();
// g.dispose();
}
Your class is somewhat incomplete right now. A League is a collection of Teams. You will want to sort a List of Team objects by their point value, which is just an int. You current class structure does not reflect this.
You can sort by whatever comparison you like if you pass it a Comparator or implement the Comparable interface. Your Team class currently doesn't have any natural ordering. Java has no idea how you would want to sort a collection of such things. It does know the natural ordering for things like numbers and strings, but you have created this data type yourself, so you need to specify how it is to be compared with other instances of this type.
Take a quick read through the tutorial on Object Ordering and perhaps it will help.
Those will only return the min or max value of a collection, whereas you need to sort your collection based upon their points. You could create a Comparator and use Collections.sort() if your assignment allows the use of those methods.
With a text editor, I imagine.
Do you have a more specific question perhaps? Have any code as a starting point?
You should start by figuring out how it works. Then you can figure out how to adapt it.
So far you have only copied and pasted someone else's program here and demonstrated no effort whatsoever of your own.
Take the variable types out of your super() calls
super(int accountNumber, String accountOwner);
You just pass the variables themselves.
super(accountNumber, accountOwner);
He still has yet to get it working for his requirements, so perhaps there is some learning left to be had. Let's see if any effort is forthcoming.
You need to add an ActionListener, just like you would for a JButton, or you can use Actions.
Here is the Sun tutorial on menus: http://download.oracle.com/javase/tutorial/uiswing/components/menu.html
You will need to decide upon a target minimum resolution and develop towards that.
GridBagLayout and appropriate use of scroll panes, tabbed panes, etc. will get you the rest of the way towards supporting various resolutions. GridBagLayout offers a lot of flexibility through anchoring, filling, and setting component weights to control how screen space is allocated to the components and where the components prefer to reside.
Subdivide your UI as needed into multiple sub-panels to help manage the complexity of smaller groups of related components. You can nest as many panels within panels as you need, so don't think you have to manage a whole lot of components with a single massive layout.
>> OK, well done, that looks like a decent start.
It's a decent start copying this program: http://www.engineeringserver.com/forum/java+paint+application-t2342.0.html
Not much of a start showing any effort though. Perhaps the OP will post some more specific questions indicating that he understands the code he posted and what difficulties he is having in converting it to meed his needs.
Yes, a for loop is appropriate. Post what you have so far and ask specific questions about the troubles you are having.
Who? --> The Rolling Stones
Add e.printStackTrace();
in your catch blocks to show the detailed stack trace for your exceptions.
You can report such PMs as a violation of the forum rules:
Keep It Organized
Do not ask anyone (member or moderator) for help by email or PM
Here you are checking pieces [a][b]
for null, but calling print on pieces [9-a][b]
if(pieces [a][b]!=null){
array[a][b]=pieces [9-a][b].print();
}
>how could i try and change it?
As already stated, make sure that the reference is not null before you operate on it.
You've used an invalid identifier to get the column. I used the column name in the code above, since the identifier defaults to the header value.
That is just an annotation added by the IDE.
In that specific case, it's actually just an anonymous implementation of the ActionListener interface.
edit: nt, server double posted my reply
The error occurs on line 212, which we can't determine when only portions of the file are shown here, but I would be suspicious of this part
pieces [9-a][b].print()
potentially executing against a null reference.
This could also be problematic if you are using a sparsely populated array
for (int b = 0; b < pieces[a].length; b++){
Here is a good place to start: JDBC Basics
Don't use the JdbcOdbc driver when a pure JDBC driver is available.
Here are some examples specifically for MySQL: http://dev.mysql.com/doc/refman/5.1/en/connector-j-examples.html
Personally I would choose an embedded file-based database such as H2 or Derby instead of MySQL if you just want to run it locally. You don't really need a database running in a separate process.
Here is another good article by Brian Goetz on handling interruption:
http://www.ibm.com/developerworks/java/library/j-jtp05236.html
You stack trace will indicate the exact line that the error is occurring on.
In Netbeans, you can open the project properties and look at the "Run" category. There is an entry for Main Class there. Be sure that is set to the class you are wanting to run and then clean and build your project.
If you're using Tomcat, try putting the jar in $CATALINA_HOME/common/lib
See this for more info: http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html#MySQL_DBCP_Example
Another option is the Desktop.open() method. You have more control with the Process the NormR1 mentioned, but it is OS-specific. The choice depends on your particular needs.
This forum is a customized version of vBulletin, which is not an open source system.
He was creating a new array every time he read a line. He needed to pre-size the array large enough to hold all of the entries before he began filling it or use an unbounded collection like ArrayList.
Didn't you read his post? He explains what is wrong.
You could add a TableColumnModelListener something like this to resize your filter fields
tableDetails.getColumnModel().addColumnModelListener(new TableColumnModelListener() {
public void columnMarginChanged(ChangeEvent e) {
txtRegNum.setPreferredSize(new Dimension(tableDetails.getColumn("A").getWidth(),txtRegNum.getPreferredSize().height));
txtFirstName.setPreferredSize(new Dimension(tableDetails.getColumn("B").getWidth(),txtFirstName.getPreferredSize().height));
txtLastName.setPreferredSize(new Dimension(tableDetails.getColumn("C").getWidth(),txtLastName.getPreferredSize().height));
panfortable.revalidate();
}
public void columnAdded(TableColumnModelEvent e) {}
public void columnRemoved(TableColumnModelEvent e) {}
public void columnMoved(TableColumnModelEvent e) {}
public void columnSelectionChanged(ListSelectionEvent e) {}
});
You'll have to set your weightx=0 for those text components you want to size yourself like that, or they won't respect your preferred size setting.
Using a Map or List to associate your text fields to their respective columns would alleviate a lot of redundant code as well.
You don't actually. 'request' doesn't really apply in your desktop application. You need to get the text from your text fields.
Looks to me like someone is due to fail a test. Interesting, given the link in his signature.
Read the documentation for Eclipse.
You can use a small panel that displays an image as a container for your controls. Something like this
class ImagePanel extends JPanel {
Image img;
public ImagePanel(){
super();
img = loadImage("whatever.file");
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
if(img != null) {
g.drawImage(img, 0, 0, this);
}
}
public Image loadImage(File f) {
Image image = getToolkit().getImage(f.getPath());
return image;
}
}
Add your text field to that panel.
You can probably use BorderLayout for that with your tree in the center and buttons at south.
There are plenty of other layout options if you want to gain more control over positioning. Just take a look at the contents listing at the left side of that tutorial link.
You can count them recursively the same way you determined the total size. I assume you don't want to include directories in that count.
Since nextGuassian() will give you a double with mean 0 and std dev of 1.0, perhaps you can use a std deviation of 1/3 of half of your range: rand.nextGaussian()*0.33*halfRange
to get 99.7% of your values between [-halfRange,halfRange] and add that to your midpoint?
Random rand = new Random();
int x0 = 10;
int x1 = 50;
int xRange = x1 - x0;
int halfRange = xRange/2;
int midPoint = x0+halfRange;
for (int i=0; i<50; i++){
System.out.println(Math.round(midPoint+(rand.nextGaussian()*0.33*halfRange)));
}
You cannot absolutely guarantee that you won't get an invalid value, but it should be outside of the 3 std dev range or around 0.3%. You can just discard those values.
As akill10 mentioned above, you have not initialized the request
variable. You have only declared it.
>open=fun.java // my program name
You cannot run ".java" files. You can run classes or jars.
No, instead, you please start a new thread if you have a more specific question to ask.
Adding a few more observations:
- Those "wink" smilies are showing due to ;)
, which is invalid syntax in those if() statements.
- No parameter type in the process() method declaration.
- Multiple return statements in the display() method - code beyond the first is unreachable. And the method declaration itself doesn't have a return type stated, so it's an invalid declaration.
It shouldn't piss him off if you merely said something like, "I'm curious, what are the issues with printf, so I can avoid problems in my future programs?" (Unless he really doesn't know and is just blowing smoke - then he might be pissed off)
Fixing incorrect format strings is definitely more trouble than using println with concatenation, so maybe he just wants to avoid a lot of the hassle with it.
"Issues" is a rather broadly generic word, so he could be referring to any number of things. I'm curious what they might be.
Edit: I do agree though that you should just do it the way the prof wants it done. He's the gatekeeper you have to pass for that 'A'.