You can't print the ArrayList with a single println() call, as you are trying in main().
Your 'hele' method would print the first element in the collection, but you aren't calling that method anywhere anyway.
You can't print the ArrayList with a single println() call, as you are trying in main().
Your 'hele' method would print the first element in the collection, but you aren't calling that method anywhere anyway.
Have verified your query is returning results? Have you set the list model on the JList?
You are probably creating multiple ArrayLists but without seeing the code no one could really say.
>How would I grab the information located on the jPanel that I want to display on the second monitor? (is there a quick easy way to duplicate the panel)
I've put together a small example of how you might do that below. Perhaps it will give you a starting point.
>Would I encounter issues with the fonts? (Seeing as the second monitor will be much larger than the original one)
Yes, if you're using an enlarged image you will have pixellation effects.
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class PanelCopyTest extends javax.swing.JFrame {
/** Mirror image panel - see class def below */
ImagePanel imgPanel;
public PanelCopyTest() {
initComponents();
}
/** blah blah, ui setup */
private void initComponents() {
panMain = new javax.swing.JPanel();
txt = new javax.swing.JTextField();
btnCopy = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
panMain.setLayout(new java.awt.BorderLayout());
txt.setText("Stuff");
panMain.add(txt, java.awt.BorderLayout.CENTER);
btnCopy.setText("Copy");
btnCopy.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnCopyActionPerformed(evt);
}
});
panMain.add(btnCopy, java.awt.BorderLayout.SOUTH);
getContentPane().add(panMain, java.awt.BorderLayout.CENTER);
pack();
}// </editor-fold>
/** This is where the relevant stuff occurs */
private void btnCopyActionPerformed(java.awt.event.ActionEvent evt) {
if (imgPanel==null){
// first time set up the mirror panel
imgPanel = new ImagePanel();
JFrame f = new JFrame();
f.add(imgPanel);
f.setBounds(0,0,getWidth(), getHeight());
f.setVisible(true);
}
// create a buffered image to draw the source panel onto
BufferedImage imgCopy = new BufferedImage(panMain.getWidth(),
panMain.getHeight(), BufferedImage.TYPE_INT_RGB);
// paint the source panel onto the image
panMain.paintComponents(imgCopy.getGraphics());
// push it to the mirroring panel
imgPanel.setImage(imgCopy);
imgPanel.repaint();
}
/** Simple panel that displays an image */
class ImagePanel …
Yes, I was trying to steer him towards figuring that out for himself... :icon_rolleyes:
Your "Step 6" will do a little more than what you noted. See if you can spot it.
So there is the problem. What did you try to fix it?
Put e.printStackTrace()
into those empty catch blocks and find out if your connection attempt is failing.
It depends somewhat on how your video card(s) are representing the screen devices to the system. You can get the bounds of a GraphicsConfiguration to determine where it is in your graphics space. If your monitors are returned as separate devices, you can figure out where the bounds of each are and where you need to put your components.
On my current system with three monitors, getScreenDevices() returns a single device with bounds that span the total area of all three - so to position something on the third one all I can really do is figure x0=2*width/3. Your system may be different and return each monitor as a separate device, each with it's own bounds.
It will likely take you a bit of experimentation and examination of what info your system is returning to nail down exactly how to isolate your target area.
Take a look at the GraphicsEnvironment API. You can get the available screen devices with the following
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] screens = ge.getScreenDevices();
The GraphicsDevice class has a multi-screen example in the class documentation.
I'm guessing your connection "con" is null. It probably failed to get the connection and you would never know it because you've discarded the exception information
catch(ClassNotFoundException e){}
catch(SQLException e){}
That's why empty catch blocks are a bad idea.
You could easily subclass that to contain a Shape instance instead of an Image and override those three methods to use the Shape instead. I don't really see how it would simplify anything in the program though.
You didn't post the AddressComboBoxItem class, so no one can see what that does.
I can tell you that the combo box is going to display whatever your item's toString() method returns, unless you have created a custom renderer for it.
He could do that or he could subclass Sprite and override the methods that render it to draw the simple shape instead of an image. I don't know what other functionality the Sprite class provides, so that might affect which way you'd want to go.
This is the method that is drawing the graphic, which is an instance of a Sprite class
/**
* Draw this entity to the graphics context provided
*
* @param g The graphics context on which to draw
*/
public void draw(Graphics g) {
sprite.draw(g,(int) x,(int) y);
}
That method could be changed to draw a simple shape instead of drawing the Sprite. However, it probably would be better to create a Sprite that to represent that simple shape so that other portions of the program that utilize the Sprite reference continue to work correctly.
You need to alter the Entity class to change how it renders. The ShipEntity is passing the path of the image file along to a parent constructor and I don't see any painting code in ShipEntity.
This is a question for Google - not a Java forum.
This is a design discussion forum - not Code On Request.
Perhaps you can search Google for some software you can buy for your needs.
That is what transactions are for :)
No, you can store the player objects in a dynamic collection, like an ArrayList or the HashMap that I mentioned above. You don't have to have a unique variable name for every object in your code - that is what arrays and collections are for.
Well, that's plenty of time - provided you have actually learned anything in your class so far.
Get to work or fail the project. It's all up to you. No one is going to just give you a copy of this.
The code above will still not print the actual original list if it contains 10s because you are never adding the 10s to the array at all.
You need to add every number to the array. Then loop and print it.
Then count your 10s and print the count.
Then print the list, skipping the entries that are 10 - your instructions don't say that you actually have to remove the values, just don't print them. If you do want to remove the 10s, set the element to 0 or -1 or something.
Keep a reference to the original PrintStream before you reassign it. Then you can just swap it back
PrintStream defaultOutstream = System.out;
System.setOut(myPrintStream);
System.out.println("hello world"); // doesn't print to screen cuz it's sent to printstream
System.setOut(defaultOutstream);
Yeah, college can get stressful like that. If you don't keep up, you'll fail.
Good luck with your program. If you have some specific questions or errors in your code, post them and perhaps someone can help.
No one is going to write the program for you though.
And what is your question? Where's your code?
Surely you don't expect someone here to write this for you.
Well, your second JFrame probably has a call to setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE)
somewhere in its setup code. You need to change that to use DISPOSE_ON_CLOSE
or something else. Those are not commands. They are constants you use to specify the parameter value.
Yeah, stack traces from the event queue can be quite long and messy like that. Somewhere in all of that will be a line that tells the actual exception.
Anyway, one thing that I did notice is that you're calling setComponentZOrder() on the Card class, when it is the container holding the Card that you need to make the call on. Also, I'm not sure what the value of "TOP" is, but you want that index to be zero if you want that component on top of everything else in the container.
I'm sure the stack trace says more than "something about an unknown source". It contains the exact error, the method that generated it, and the line number. It would help if you posted that here as well - at least the first couple of lines.
Just trace through and figure out how str.substring(index2,index2+length2) would end up with a position beyond the length of 'str'.
You need to keep the reference 'g' at class level or pass it to methods that need to act on it.
No, just use the constant itself when you call the method
gridBagControl(comp, p, in, 1, 1, x, GridBagConstraints.NONE, GridBagConstraints.CENTER)
That's because the entire expression GridBagConstraints.CENTER
is the int constant value. Use the parameter directly
gridBagConstraints.anchor = c;
What issues did you encounter? Yes, they are just ints and you should be able to pass them just like you have in the method signature you posted.
I think the user name should be "baloney", which is exactly what the claim that he's tried this is.
That depends on what database you are using. Generally there is a function that you can call to check the current value of a sequence. The next insert ID will be one higher - unless another transaction gets it first.
Unless there is a reason you can't, perhaps you should insert the row and get the ID prior to creating the folder.
i m doing project in controlling pc via mobile .so pls tell some ideas & give documents to my id ImSoLazy @ gmail.com pls..........
Why? It's your project. You're supposed to be learning something and showing some initiative with it - not hijacking someone else's thread to ask others to do your work for you.
Try searching around on your own and if you need some help post specific questions in the appropriate forums.
File > Project Properties > Libraries
Add the folder/jar/etc in the Compile tab.
If you just want the int to show, you don't even need the TypeValue class. Just put Integer objects in the combo box model and cast them back to Integer when you getSelectedItem().
The only reason to make a small custom class and override toString() is if you want to display some specific label to your users, but store some other data from their selection.
Why do you need to write tests that don't adhere to the access scope of the inner class? If it's not a static inner class, you should have an instance of the enclosing class to work from. If that's not the case, then perhaps your inner class should actually be a public top-level class?
Check all of your braces. You are missing one (or more).
edit: hehe, cross-post. What he said ^^
The combo box will display whatever value your toString() method returns, so just alter that method to return any representation you want.
The only purpose in making the TypeEntry structure at all was to associate some ID (or other) value with the label you want to present to the user.
Iron Maiden - "The Trooper"
Have you set the build.dir
property in your build file?
I agree with jwenting that a map is great for this. He already gave precise instructions on how to process the list. The rest is simply a matter of looking at the Map api for the details on the required methods. The actual code to do it is only a couple of lines longer than his description.
Each of those has detailed documentation on installation and configuration. If you don't want to use a single install package like WAMP or XAMPP, you should be willing to take the time to read the install docs for each of them.
And some additional reading: http://www.daniweb.com/forums/faq.php?faq=daniweb_policies#faq_keep_it_clean
The returned object will be a TypeEntry object. You have to cast to that and use its getValue() method.
TypeEntry selectedType = (TypeEntry)combo.getSelectedItem();
int typeValue = selectedType.getValue();