Swing/AWT/SWT :: Why Negative Offset Of Y Coordinate Required In Program

Feb 3, 2015

import java.awt.*;
import java.awt.image.*;
import java.awt.event.*;
import javax.swing.*;
import java.net.*;
/**
An applet that shows a rotating globe.

[Code] ....

View Replies


ADVERTISEMENT

Program Deals With Variation Of Geographic Coordinate System

Aug 22, 2014

This program deals with a variation of the geographic coordinate system with Greenwich at 51° 28' 38" N. The program will be adding the three values of one coordinate to the three values of the second coordinate. Though the maximum value for seconds and minutes is 59, the user can enter values greater than that number when prompted. The maximum degree is 360 for this assignment though the user can enter values greater than that number.

View Replies View Related

Swing/AWT/SWT :: Can't Get Gridbag Layout Components To Display As Required

May 4, 2014

I have quite a specific view for how I want my components layed out. No matter what I try I can get them to display how I want! I'm using three JPanels. There's a main panel that goes inside the tabbed pane. This main panel contains two other panels. The First panel is a gridbaglayout panel, with labels on the left column, and components on the right column. The second panel is underneath the second, and contains a label, and a button beneath it. THis uses a basic box layout, with one component per line. The label doesn't always appear (depends if a component is changed). With everything showing, this is how it looks so far:

However, I want the Labels on the left of the pane. The right hand column should be aligned horizontally and have more space from the labels. Ideally I'd like a gap between the last label/checkbox and the Note label.

This is my current code for the panel/s inside the tabbed pane window.

videoPanel = new JPanel();
applyVidBtn = new JButton("Apply Settings");
applyVidBtn.setVisible(false);
warningLbl = new JLabel("Note. Applying these settings causes a program restart.");
warningLbl.setVisible(false);

[Code] .....

View Replies View Related

Simple Program Giving Negative Result For Amount Of Calculations Done

Mar 5, 2014

Why this extremely simple program seems to be giving me a negative value for amount of calculations done within one minute ( Just using it as a bit of fun to see how different computers in the office perform).

Java Code:

class Benchmark {
public static void main(String[] args) {
long endTime = System.currentTimeMillis() + 60000;
int count = 0;
for (int i = 0; System.currentTimeMillis() < endTime; i++) {
double x = Math.sqrt(System.currentTimeMillis());
count = i;
}
System.out.print(count + " calculations per minute");
}
} mh_sh_highlight_all('java');

I am getting results between -2.1billion and -3.4billion which to me would make sense since they are not the best computers in the world but I would be expecting a positive value?

View Replies View Related

Averaging Grades Program Throwing Exception With Negative Numbers

Nov 17, 2014

So I have re-written the code but it is still not running correctly. Any number i type in it throws an exception, also i need the program to add the totals that i type in and then once i type -1 into the prompt button list all the number i typed in and give me the average.

import java.awt.*;
import java.awt.event.*;
import javax.swing .*;
import javax.swing.text.*;
public class Averages extends JFrame
{
//construct components
JLabel sortPrompt = new JLabel("Sort By:");

[Code] .....

View Replies View Related

Averaging Grades Program - System Crashes On Negative Number Input

Sep 30, 2014

I do now have the problem where i have to insert the numbers 1 to 100 individually in order to allow the program to accept a grade as high as 100%.

Also as soon as i type in a negative number the system crashes and shows me a error as attached.

/*
Averaging grades
To use the Java Swing interface to calculate the average of up to 50 grades.Average is calculated once -1 is entered as a value. The grades are then sorted from lowest to highest and displayed in a content pane which also displays the average.
*/

import java.awt.*;
import java.awt.event.*;
import javax.swing .*;
import javax.swing.text.*;
public class Averages extends JFrame {
//construct components
JLabel sortPrompt = new JLabel("Sort By:");

[Code] ....

View Replies View Related

Averaging Grades Program - Take Input From User Until They Enter Negative Number

Feb 2, 2015

Ok so I have my program working for the most part. In this program I am supposed to take input from the user until they enter a negative number and that works, the problem is that it doesn't work if I enter a negative number on the first prompt. For example if I enter a 100 it would prompt me again and if I enter a negative number it would quit and give me the average, but if I enter a negative number the first time I am prompted the program just gives me an error. How do I fix that?

import java.util.List;
import java.util.ArrayList;
import java.util.Scanner;
public class Application {
public static void main(String [] args){
Scanner input = new Scanner(System.in);
List<Integer> grades;

[Code] ....

View Replies View Related

Exception Thrown If User Enters Negative Number - Program Gets Suspended

Oct 19, 2014

In my cs class, we have to write a program that throws an exception if the user enters a negative number, the program should prompt the user to enter only positive numbers and then let them retype the number. But everytime I throw an exception, my program gets suspended.

What am I doing wrong, or is there no way to continue a program if an exception is thrown? Does the program automatically get suspended when an exception is thrown?

try{
do
{
N = kb.nextDouble();
if(N<0) {
throw new NegativeArraySizeException();
}
else
j++;
}
while(j==0);
fill.size(N);
}
catch(NegativeArraySizeException e) {
System.out.println("The number you entered must be positive. Please try again.");
}

View Replies View Related

How To Use Coordinate In Second Code

Apr 16, 2014

how I can use this class:

Java Code:

public class Coordinate{
public int x;
public int y;
publ Coordinate(int x, int y){
this.x = x;
this.y = y;

[code]....

How would I use Coordinate in the second code?

View Replies View Related

All Permutations Of 2 Coordinate Int Array

Apr 12, 2014

I have a set of 2D arrays, structured as so: int[][] cage = new int[someLength][4]. Each array has a set column length of 4; the first two columns are all that concern us with this problem. They are used to define the row and height respectively of a point (e.g. 2,4).

What I need is to generate all possible permutations of the points using both row and column coordinates from the 2D array. I found a working method to generate all permutations for 1D array of ints here: [URL] ..... , under update 2 of the first answer.

Here is an example of a possible input and corresponding output desired:

In: (1,0)
(1,1)
 
Out:(1,0),(1,1)
(1,1),(1,0)

Ideally the result will be stored in a 2D array of ints.

View Replies View Related

All Permutations Of 2 Coordinate Int Array?

Apr 12, 2014

I have a set of 2D arrays, structured as so: int[][] cage = new int[someLength][4]. Each array has a set column length of 4; the first two columns are all that concern us with this problem. They are used to define the row and height respectively of a point (e.g. 2,4).

What I need is to generate all possible permutations of the points using both row and column coordinates from the 2D array. I found a working method to generate all permutations for 1D array of ints here: My link, under update 2 of the first answer.

Here is an example of a possible input and corresponding output desired:

In: (1,0)
(1,1)
Out:(1,0),(1,1)
(1,1),(1,0)

the result will be stored in a 2D array of ints.

View Replies View Related

Number Of Paths Coordinate System

Oct 18, 2014

I've been pondering about this algorithm for about a week but I'm still not able to write a "fast" working method/algorithm to solve the Number-of-paths-exercise we were given in my class />

So here's the task:
Write an efficient java program "Paths" which solves the following task:

- Read input n ∈ N and give output a(n) which is the number of paths from (0,0) to (n,0)
it is not allowed to go over the diagonal (m,m) and also not below the x-axis (m,0)

Here are the allowed steps:
u = (1,1), U = (1,4), d = (1,−1), D = (1,−4) and H = (1,0)
steps are performed in a two-dimensional-coordinate-system!

View Replies View Related

Coordinate Conversion Project - Rectangular To Polar

Mar 6, 2014

Ok Im trying to create a code right now that will take a table of rectangular coordinates and convert them to Polar coordinates in the constructor. I will eventually calculate the total distance between all points in the calculateDistancePolar method but for now I am using it to test.

It doesnt like line 29 and 31 of the class Polar and I cannot figure out why.

public class Test {
public static void main(String[] args) {
double[][] coords = {{86.92, 2.47},{70.93, 27.81},{97.74, 34.36},{30.90, 35.14},{51.66, 31.70},{0.830, 21.77},{55.91, 66.62},{32.92, 75.23},{65.26, 72.53},{83.90, 4.710}};
System.out.println("X,Y Coordinates are:");
outputArray(coords);
Polar myTest = new Polar(coords);

[Code] .....

View Replies View Related

Coordinates Are Inside Of A Right Triangle On Imaginary Coordinate Plane

May 24, 2014

I'm having a random x and y coordinate generate and I need to check if the coordinates are inside of a right triangle on this imaginary coordinate plane.

View Replies View Related

Code Required In Form Of Key Values

May 20, 2014

Suppose I have the file in a particular directory with the below conntent starts with the below line -

5/15/2014 2:07:36 PM : 10 - 10 : *** Loading XML file DSH_000001_pos.xml ***

After that the content is shown below.

5/15/2014 2:07:36 PM : 10 - 30 : Loading positions for PERIOD DSH - TRDBOOK +NSCCL :INR - HOUS - (INR).
5/15/2014 2:07:36 PM : 10 - 30 : Loading positions for Exchange Complex NSCCL PERIOD Exchange Complex (INR).
5/15/2014 2:07:36 PM : 10 - 30 : Loading positions for Combined Commodity ANDHRABANK - ANDHRABANK PERIOD Combined Commodity (INR).
5/15/2014 2:07:36 PM : 10 - 30 : Loading positions for PERIOD DSH - CFDTRADING +ASXCC :GBP - HOUS - (GBP).
5/15/2014 2:07:36 PM : 20 - 30 : For <ecPort> ASXCC can't find required associated object <clearingOrg>

[code]....

View Replies View Related

Changing The Required Pixels Color?

Nov 15, 2014

I would like to draw a rectangle around a certain part of an image.

So I wrote this:

Pixel[] pixels = scene.getPixels();
for( Pixel pixel : pixels)
{
if(pixel >= point.getX() && pixel <= (point.getX()+p2.getWidth())
{
pixel.setGreen(150);
}
}

But the error is giving me incompatible types. I would like to set all the pixels at a certain point up to the dimensions of my rectangle and so on. How would I do that?

View Replies View Related

SOAP Output Required In XML Format

Mar 21, 2014

Using the concept of web service (SOAP), I need to have a web service running. The client page will pass an ID to the web service and in return the service will return some values retrieved from the database based on the ID passed, as output. The output so fetched has to be in XML format.

View Replies View Related

Unexpected Type - A Returned Variable Required

Apr 2, 2014

I'm making a Hangman program for Java, here's my code:

import java.util.Scanner;
public class Hangman {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
String answerWord = WordList.getWord();

[Code] .....

The Compiler gives me this only error:

Hangman.java:39: error: unexpected type
displayWord.charAt(i)=userInput.charAt(0);
^
required: variable
found: value

I understand that charAt returns i as a value and not a variable. What do I use to return a variable as I intended?

View Replies View Related

Use Switch Or If / Else Statement To Filter Out Data Not Required For App

Feb 21, 2015

I'm using jsoup to parse a calendar page.

I want to use a switch or if/else statement to filter out the data I don't need for the app. This is by no means anything more than a draft because java is easier to work with than android.

Element table = doc.getElementById("launch_calendar");
Iterator<Element> iterate = table.select("td").iterator();
if(iterate.hasNext()){
for(iterate.hasNext();;){
counter++;

[Code] ....

View Replies View Related

Servlets :: Submitting Images - Restful API Required?

Mar 8, 2014

I am working on an android application that submits images to a servlet, is there any need for me to use restful api ??

View Replies View Related

Java Web Start - Deploy Application Including Required Folders And Files

May 30, 2014

I developed an application that is accessing some property files. The condition was that the user should be able to modify the content or parameters of those property file.How can I distribute the application using Java web start that also includes those property file in the client side?

View Replies View Related

Error - Could Not Find Required Version Of Java(TM) 2 Runtime Environment In (null)

Jun 30, 2014

I have installed and tested j2se jdk8 u5 on my Windows 7 64 bit laptop and successfully tested in Eclipse with a quick Hello World.

JAVA_HOME = C:Program FilesJavajdk1.6.0_25

When I try to install j2ee jdk7 sdk7 I get

Error: Could not find the required version of the Java(TM) 2 Runtime Environment in '(null)'

View Replies View Related

Add Integers To ArrayList And Prompt User To Delete Specific Numbers Not Required

Jan 21, 2015

This program simply adds integers to an ArrayList and then prompt the user if they would like to delete specific numbers that they don't want.

The output that I get when I want to delete numbers like 2 and 4 from 1 2 3 4 5 is 1 2 3 4 5 instead of 1 3 5.

Java Code:

import java.util.ArrayList;
import java.util.Scanner;
public class AL
{
// A regular array like int arr[] has to have its size declare before run-time and it's not dynamic which mean it can not grow or expand on its own.
static Scanner input = new Scanner(System.in);
// You have to use reference types(Integer, Double, Float); not primitive types(int).

[Code] .....

View Replies View Related

JDBC :: Options Required For DB Schema Password Encryption - Connecting To Backend Database

Jul 9, 2015

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.

View Replies View Related

Clicking On TextField Will Show Some Required Text Under Text Field

Mar 15, 2015

I am trying to run a simple program in which on clicking on the TextField will show some required text under the Text Field .Here is my code:
 
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
 class Awt
{
public static void main(String...s)

[Code] ....

I am expecting the on clicking anywhere inside the text field should show me the Text : "Mouse Clicked" . But i am getting this error:

Awt.java:77: error: cannot find symbol
tf.f.setText("Mouse Clicked");}
^
symbol: variable f
location: variable tf of type Awt
1 error

View Replies View Related

Can't Get Negative Values Working

Nov 11, 2014

when i input a positive integer it works but when i input a negative number it doesn't work

my pseudo code:

READ input
WHILE( NOT CORRECT INPUT)
READ INPUT AGAIN;
ENDWHILE
DECLARE array arr[input]
FOR(i=0 to input-1)
arr[i]= Random number from 0 to 100;
ENDFOR
DISPLAY ARRAY

error message when i input -5 : Exception in thread "main" java.lang.NegativeArraySizeException atPosNeg.main<PosNeg.java:36>
 
import java.util.*;
class PosNeg{
 public static void main(String args[]) {
  Random generator = new Random();
Scanner scan = new Scanner(System.in);

[code]....

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved