So, I have a game. I would like to make a game where you press "start" and THEN it starts. Also, I want to have collision with triangles, not just squares. The way I handle collision right now is with if statements, if the object is within the other, game over.How would I do collision with triangles? Lastly, how do I set a high score? how to change fonts and font size in swing?
I have an applet which I want to embed into HTML. In applet viewer in Eclipse IDE the view is this(see pict01), and when I access my index.php on local server I get this view(see pict02). I don't know what I am doing wrong. I checked it with Firefox, IE and chrome. No changes. Here is source code:
import java.util.*; import java.io.*; import javax.swing.*; import java.awt.*; import java.applet.*; import java.net.URL; public class WCURL extends JApplet {
//static final int WIDTH = 8; //static final int HEIGHT = 12;
[Code] ......
I have these files in my local servers folder where I am trying to access it from(see pict03).
When i click on the button from bottom panel, top panel need to be redrawn. But redrawing is not happening. It happens only when resizing the applet.
public class Graphics_Chart(){ public init(){ JScrollPane topPane = new JScrollPane(new ImagePanel2()); topPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); topPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
I was wondering, for both a web based application and a normal Java program, should I just open up an I/O every time I need certain data, or am I better off just loading all the information into my program at start up?
In the code that I am currently trying to do, I want to make it so that the program loops until the randomly generated number is 1, to a maximum of 4 loops.I have figured out how to make it stop at a randomly generated 1, but I can't quite figure out how to make it stop at four loops if it doesn't reach the 1 before the maximum number of loops.
No problem setting background color for layouts, e.g. bdrPn.setBackground(new Background((new BackgroundFill(Color.BLACK, CornerRadii.EMPTY, Insets.EMPTY))));
But neither of the following are working for me, running JavaFX 8 on latest OS-X
scene = new Scene(bdrPn, winW, winH, Color.BLACK); scene.setFill(Color.BLACK); scene.setFill() worked fine for previous versions of JavaFX.
My primary question is about which method is the best for having an applet of mine communication with a backend database of mine. In other words, I don't want to try learning a technology that is out of date or not a good fit for my goal. I purchased the O'Reilly title "Java Servlet Programming", but it seems to be very old and out of date (referencing Netscape 4, etc.) and I see a Java RMI O'Reilly title on Amazon, but it was written in 2001.
My basic goal is to allow my applet to have access to a back-end database for reading and writing. I understand that direct Applet to DB (via JDBC) access is a bad idea so my thought is to create a servlet (much like web service for lack of a better term) or an actual web service (RESTful would be my first guess) to broker the requests. I already have a very basic servlet running that has access to my database server so now I want to focus on the best method for making calls from the applet to the servlet but having said that I don't want to go down this road too far if a servlet is not the right tool for the job.
My reading has been leading me to RMI, but as I said, I don't want to focus on that if there is a better option. In a non-Java environment, I'd use a web service (REST, SOAP, etc.) and perhaps that's what I should do here as well and not even bother with a servlet per se and just go with a web service.I know there can be some subjectivity with regard to these choices and I don't need to know what the "best" one is.I don't want to use RMI if it's dead or has been surpassed by something else, for example.
Should I use a servlet? Should I use a web service? My needs are rather modest; query the database, send updates to the database, etc. Nothing too crazy.
I've just started working on a program and i'm already having difficulties with the program. I can't get the background color to change from the basic gray color. Maybe you can tell me what i'm doing wrong.
import javax.swing.JFrame; import javax.swing.WindowConstants; import java.awt.*; import java.lang.Object; import java.awt.Color; public class FrameDemo{ public static void main(String args[]){ Toolkit toolkit = Toolkit.getDefaultToolkit ();
[Code]...
also if theres any way to shorten up what I have there, that would be great.
If I want to read from file the word "red" And then the following is not the right way like in the code ,, How to set the Color name
File inputFile = new File ("C:\input.txt"); Scanner scan = new Scanner (inputFile); String RedColor=scan.nextLine(); Color backColor = new Color(redColor);
We currently have an application which uses JDBC to connect to the backend database (DB version - 11.2.0.3 ). The application uses a properties file in which the password for the db schema is hardcoded in plain text format. Due to security restrictions we have been asked to make sure the password is encrypted in the file and no direct access is made to the schema using the plain text password. Best options we can use to make this password encrypted both at Oracle DB side and Java side.
I want to write simple game. Why if I press button UP and RIGHT it not move diogonally, may be it have special code. And how I need to write correctly border and gravity?
public class Main { public static void main(String args[]) { JFrame frame = new JFrame("Stickman"); Ground ground = new Ground(); frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE); frame.setSize(710, 480);
I tried a few things and I was unsuccessful at removing the border around my image button. It seemed simple enough when reading on StackOverflow but I'm still getting errors : s
ImageIcon cardIcon_1_1 = new ImageIcon("../images/empty.png"); JLabel cardImg_1_1 = new JLabel(cardIcon_1_1); cardImg_1_1.setBorder(BorderFactory.createEmptyBorder()); cardImg_1_1.setContentAreaFilled(false);
Errors:
Multiple markers at this line - Syntax error on token ";", @ expected - Syntax error on token ".", @ expected after this token
Multiple markers at this line - Syntax error, insert "Identifier (" to complete MethodHeaderName - Syntax error, insert "SimpleName" to complete QualifiedName - Syntax error, insert ")" to complete MethodDeclaration
I'm using an applet it had to be in the initialize part of my program...
I'm trying to use netbeans GUI creator to create a chessprogram. However, the default "freeflow" layout is very difficult to work with. However, when I switch the layout to gridbag or border layout, I can't figure out really how to do anything. I don't know how to resize or position elements. Any good set of tutorials for using netbeans GUI creator with non standard layouts?
(I originally used absolute layout, which I can easily add and position elements in, but which I abandoned because i want the chessboard squares to resize when the window changes size).
I am working on a project (assignment) and i want to be able to click on jlabel and the select border will show (as shown in the image attached) and i used it to resize the jlabel. I tried
@Override public void componentResized(ComponentEvent e) { super.componentResized(e); setPreferredSize(getSize()); } });`
yet is not working. I tried some other code that are not working.
I have a problem with a shape generator. It randoms the shapes just fine, I just do not know how to make all the shapes fully stay within the frames border.
RandomShapeMaker.java
import java.awt.Color; import java.awt.Graphics; import javax.swing.JPanel; import java.util.Random; public class RandomShapeMaker extends JPanel{ private static final Random randomShape = new Random(); public void paintComponent( Graphics g ){ super.paintComponent( g );
I am struggling to make a double border which has rounded corners. The border should be 2 parallel lines.
I made something which looks almost good, but if you look closer there are a few wrong things.To achieve this, I made 2 paths, then painted them in 2 different colours.
The main problem is painting with AA, because the colours overlap and are affected.
I think it would be smoother to paint a single path using 2 colours.
For the first problem, I think some kind of a stroke would be enough. But, if I build a stroke, it's almost same thing like drawing the path twice, like I did before. Anyway i think that would fix AA problem. But still, maybe I can achieve a smoother effect for the corners.
Question:Maybe something with a 2x1 Texture ? It's possible to achieve this ? I know I tried this before and when a curve was encountered the direction of the texture was wrong and looked messy.
PS: Ignore the blueish thing, it's a dragged component to activate the highlight border.
If I "embed" a ProgressIndicator inside a ListView it has an ugly border and a white background. It looks like there's a TextField below the ProgressIndicator.
Why does it behave like that and how to solve it so that the progress indicator is transparent.
I am trying to align the core/middle side color of a cube, index 4, with the bottom middle color of the same side, index 7. (Each side has values 0-8 where 0 - is the top left corner, 1 is the top mid corner, 2 is the top right corner, 3 is the middle left corner, etc).
In addition to lining up those two colors, I am also making sure that the neighbor color of index 7(the color that it is attached), in this case the bottom color, matches with the top core/middle color. I will attach some pictures and a print out to show what I am talking about...
However, in my code when I am trying to align all of these up together, it does not go into the while loop. Each of the loops essentially is trying to get a match of same color with index 4 and 7, as well as making sure that index 7's neighbor color (the bottom color, in this case) matches with the top color.
Here is what I have tried:
private void alignSideColor(){//make the bottom colors neighbor match with a middle side value and rotate it to the top, for the top cross
if(cube.bottom.square[1].charAt(0) == topColor){ while(cube.front.square[7].charAt(0) != frontColor && cube.bottom.square[1].charAt(0) != topColor){ rotateBottomClockwise(1); System.out.println("Trying to align side color...");
[Code] .....
The print out of the ELSE IF is: alignment is: W-G and tops: R-R NOW ITS ALIGNED even though the sides, index 4 and 7, are NOT aligned with each other
I have also tried the same thing but with out the 2nd condition in each while loop, and although is DOES enter the while loop, it does not perform correctly -- index 4 and 7 WILL have matches colors, but it does not check to see if index 7's neighbor matches with the top color.
Here is how it prints out ** ** ** G7 B6 Y1 ** ** **//this portion is the back of the cube ** ** ** R6 W5 O4 ** ** ** ** ** ** R3 W2 O1 ** ** ** B3 G4 Y9 W9 O8 Y7 W3 B4 G9//this portion is the left, top, and right of the cube B2 G5 R8 W4 R5 Y6 O2 B5 G8 O7 W8 R9 B7 B8 B9 R1 R4 R7 ** ** ** O3 O6 O9 ** ** **//this portion is the front of the cube ** ** ** Y2 Y5 Y8 ** ** ** ** ** ** B1 G6 W7 ** ** ** ** ** ** Y3 Y4 G1 ** ** **//this portion is the bottom the cube ** ** ** R2 O5 G2 ** ** ** ** ** ** W1 W6 G3 ** ** **
Here is the cube showing the top, left and front side
Here is the left and bottom side. As you can see index 4, G5 -- yes that is a 5 lol -- does not have the same color as index 7, W8.
I need to rotate the bottom until W8 is aligned with a middle white value. An examples of a neighbor is: W8-R2
import javax.swing.*; import java.awt.*; public class PRJ04 extends JFrame { public static void main (String [] args) { PRJ04 frmApp = new PRJ04(); PanelChart pnlChart = new PanelChart();
[Code] .....
When I comment out the adding and setting of the pnlChart on my main driver, the pnlPopulationInputs shows up fine, and it runs ok. When I add the pnlChart I get errors like crazy and a white screen. My errors:
Exception in thread "AWT-EventQueue-0" java.lang.ArithmeticException: / by zero at PanelChart.drawChart(PanelChart.java:45) at PanelChart.paintComponent(PanelChart.java:24) at javax.swing.JComponent.paint(JComponent.java:1054)
[Code] ....
Once more with this one, I refer back to our in class example. Our programs are set up the same, yet he has no issues with the "/ by zero" exception.