GUI Bars - Increment Height By About 10 Pixels

Nov 12, 2014

So I'm trying to make a bar graph, each bar will increment the height by about 10 pixels. To do this, I'm making an array of bars. For some reason, using fillrect I cannot not increase the size more than 10 by 10, if I do, it will only show the 10 by 10. I want the bars to increase in height by 10 each time.

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
public class AssortedAssortmentsOfSorts extends JFrame

[Code] .....

View Replies


ADVERTISEMENT

Creating Program That Will Estimate Child Height Based On Height Of Parents

Jun 19, 2014

I am trying to create a program that will estimate a child height based on the height of the parents. It should ask the user to enter a String representing the gender, so m or M for a male and f or F for a female. The program must handle both upper or lower case gender entries. I need it to ask the user for the height of both parents in two parts:

1. for Feet and store in an int variable.
2. for inches and store and int variable.

So for example if the father is 6' 2'', the user would enter 6 when asked for feet and 2 when asked for inches. Convert the height of the each parent to inches. hint 12" in one foot.

Apply the following formulas based on gender (must use an if statement(s)):

Hmale_child = ((Hmother * 13/12) + Hfather)/2
Hfemale_child = ((Hfather * 13/12) + Hmother)/2

I cannot figure out what is missing from my code

<import java.util.Scanner;
public class ChildHeight
{
public static void main(String[] args) {
Scanner scannerObject = new Scanner(System.in);
String gender;
String male;
String female;

[Code] ....

View Replies View Related

How To Activate Scroll Bars On JScrollPane

Apr 21, 2015

I got an application with JScrollPanes; they seem to work fine, but fresh after the start, their scrollbars seem dead:I only begin to see their components after resizing the application window with the mouse.Clicking the scroll bars or their buttons (in Metal Look&Feel) does nothing.And there is no 'knob' visible.Dragging the side or bottom of the application window suddenly shows all and makes them operational.My ComponentListener on the window that contains the scrollpanes only does a repaint on the components inside the scrollpanes.Adding such to the code has no effect, neither does a repaint on the scrollpanes themselves.

View Replies View Related

Progress Bars (can't Start And Won't Count Down)

May 5, 2014

I'm trying to get a timer to work to decrease the value of a stats bar (like Hunger Level, Energy Level), but it won't paint the bars in the first place, it won't let me start the timer (the start after t.start() is underlined) and now I'm getting an error that won't let me run it at all without putting public static void main (String [] args), even though adding it anywhere is causing other errors

public void hungerTimer () {
int delay = 300;
int period = 300;
interval = 100;
hungerBar.setValue(100);
hungerBar.repaint();
timer = new Timer();

[Code] .....

View Replies View Related

Missing Horizontal Scroll Bars

Dec 24, 2014

I am building a java app and i am wanting to color the 6th 8th and 10th columns differently to make them stand out.

// It creates and displays the table
tableEng = new JTable(buildTableModel(rs));

for(int i=0;i < tableEng.getColumnCount();i++){
packColumn(tableEng,i,5);

[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

Image Processing - Array Of Pixels

Feb 13, 2015

I am trying to process an array of pixels, checking each within a 5*5 mask. Ive declared my mask as a 2d array and get the pixel values within a nested for loop. Im getting an ArrayIndexOutOfBoundsException at the line:

mask[0][4] = dsIm.red[i-1][j+3];

Have I declared my mask wrong for a 5*5 mask. Is my logic wrong?

I won't give all the code, but basically Im trying to check all 25 pixel values within the mask:

int [][] mask = new int[5][5];
System.out.println("We are in the method just written");
//loop one loop
for(int i = 1; i <= h-2; i++)
{
for(int j = 1; j<=w-2; j++)

[Code] .....

View Replies View Related

2 Dimensional Array That Represents Color Pixels

Nov 25, 2014

I have this 2 dimensional array that represents color pixels

RGBColor[][] rgbArray1 = new RGBColor[rows][columns] - so each elemnt in this array is a pixel - (red, green, blue)

I wrote a class named RGBImage. represents an image. the constructor of this class takes RGBColor[][] rgbArray1 as an argument and print the image.

My problem is when i try to rotate the image 90 degrees. because the dimentions are changeing. i'm getting ArrayIndexOutOfBounce Exception.

I know i can to this by create a bigger 2 dimensional array and copy the original , but for this assignment i cant do this .

I must use the original one . now i will show the main method that will get things clearer if i didnt explained well enough.

System.out.println("Constructor with RGBColor[][] Array Parameter:");
RGBColor[][] rgbArray1 = new RGBColor[3][4];
for (int i=0; i<rgbArray1.length;i++)
for (int j=0; j<rgbArray1[0].length;j++)
rgbArray1[i][j] = new RGBColor(i,i,i);

[Code] ....

output:

(0,0,0) (0,0,0) (0,0,0) (0,0,0)
(1,1,1) (1,1,1) (1,1,1) (1,1,1)
(2,2,2) (2,2,2) (2,2,2) (2,2,2)

(2,2,2) (1,1,1) (0,0,0)
(2,2,2) (1,1,1) (0,0,0)
(2,2,2) (1,1,1) (0,0,0)
(2,2,2) (1,1,1) (0,0,0)

This outputs are what i need to accomplish.

View Replies View Related

Rendering Images Of Type BufferedImage - Pixels Are Not Consistent In Size

Jun 26, 2014

As implied by the title, when I am rendering images of the type "BufferedImage" unto a Swing application, the images' pixels are not consistent in size. Some might be larger than other, and some might be smaller than other.

Here is a screenshot of what I am talking about (you might need to zoom in a bit because the image is so small): [URL] ....

And here is also some code for you. The images are actually from a sprite sheet, which I first load in its entirety and then split up in an array.

Java Code:

public static BufferedImage sprites[];
...
public void loadSprites(){
try{
BufferedImage bigImage = ImageIO.read(new File("SOURCE/BLA/BLA/THIS/IS/ACTUALLY/NOT/THE/REAL/SOURCE/IN/CASE/YOU'RE/WONDERING/I/JUST/DON'T/WANT/YOU/TO/FIND/ME/AND/RAPE/ME"));
sprites = new BufferedImage[16 * 16];

[Code] ....

So, how do I make the pixels equally small?

View Replies View Related

Swing/AWT/SWT :: Double Drawing Pixels When Manipulating DataBuffer Of BufferedImage

Feb 9, 2014

I've been working my way through a tutorial to build a simple 2D tile-based engine that also allows the code to manipulate the colour of pixels on the screen based on a monochrome map read from a file. I've got the code right line for line, but I seem to have a bug when it comes to draw to the screen! At regular intervals, despite what is held in the pixel array of ints (which I have confirmed to be correct when debugging), I get the same row of pixels being draw twice in a row. I figured there was some loop issue somewhere, but after attempting to debug this for some time, I haven't come up with the answer.

Original tilesheet:As rendered:

Game.java:
package igg.engine.game;
import igg.engine.game.gfx.Screen;
import igg.engine.game.gfx.SpriteSheet;
import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Color;

[Code] ....

View Replies View Related

JTable Height Should Fit To The Contents

Jul 24, 2014

I have a jTable with one or 40 rows in it.

The problem is, also when I have only one row in my jTable, the size of the jTable is a little more bigger than 40 rows.

How can I say the jTable, that she should scale to the size of the content?

I don`t want that the jTable is bigger than the content. For example the picture below:

View Replies View Related

Error When Trying To Set Changing Height Value From JFrame

Jun 24, 2014

import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.event.KeyEvent;
public class Racquet {
private static final int WIDTH = 60;
private static final int HEIGHT = 20;

[code]....

The problem arises at the portion of the code that says

private int Y = game.getHeight() - 70;

I am not actually getting any compiler errors, but when I try to run the program, the command prompt pops up with this message:

Exception in thread "main" java.lang.NullPointerException
at Racquet.<init>(Racquet.java:19)
at Game.<init>(Game.java:10)
at Game.main(game.java:58)

What I want to do is make it so a GUI object that I created moves with the screen when I change the height. If I change it to private int Y = 330; the program works just fine.

View Replies View Related

Java Computing Height Of Stack

Jun 2, 2015

Compute the height of a stack. Then determine whether that value is found in the stack element .

View Replies View Related

Store Pixels Values Currently On Screen And Compare Them To Values On The First Frame?

Aug 29, 2014

I need a way to store the pixels values currently on the screen and compare them to the values on the first frame. Right now I'm using glreadpixels as follows:

currentBuffer= BufferTools.reserveByteData(mapSize);
glReadPixels(mapStartX, mapStartY, mapWidth, mapHeight, GL_BLUE, GL_UNSIGNED_BYTE, currentBuffer);
for (int i = 0; i < mapSize; i++) {
if (currentBuffer.get(i) != baseBuffer.get(i)) {
//Do nothing
continue;
}
//Do something
}

This works perfectly fine but turns out to be a real bottleneck, dropping the fps to a third of what it was. Is there any quicker way? All I'm after is speed, I don't even need to show it on the screen if the comparison is made "behind the scene".

View Replies View Related

Finding Height Of Binary Search Tree?

Nov 13, 2014

So for an assignment I have to write a method that finds that height of this BST. I wrote this:

public int height(Node node)
{
if (node == null)
{
return 0;
}
else
{
return 1 +
Math.max(height(node.left),
height(node.right));
}
}

Which makes sense in my head. However, I added a couple of nodes in and realized I'm not sure how to call this method.

public static void main(String[] args) {
Tree<String, String> tree = new Tree<String, String>();
tree.add("A", "1");//some added stuff
tree.add("B", "2");
tree.add("C", "3");
tree.add("D", "4");
tree.add("E", "5");
tree.add("F", "6");
tree.add("G", "7");
tree.add("H", "8");
System.out.println(tree);
System.out.println(tree.height());

What exactly do I put in the parenthesis after tree.height? If you need to see more of my code I can do that but it is quite lengthy.

View Replies View Related

BorderLayout - How To Decrease The Height Of CENTER Position

May 5, 2014

Normally, the height of the CENTER component (or position) is greater than that of the NORTH and SOUTH components in a BorderLayout.

Is it possible to increase the size of the SOUTH component and decrease the size of the CENTER position because the jcomponents I want to add in the SOUTH component are bigger? or shall I have to change the layout and use some other layout?

View Replies View Related

Check If Height Is A Letter Between A To J - If Statement Always False

Jun 22, 2014

Why isn't heig ever equal to heightShipArray[count] no matter what letter I type in

String[] heightShipArray = {"A", "a", "B", "b", "C", "c", "D", "d", "E",
"e", "F", "f", "G", "g", "H", "h", "I", "i", "J", "j"};
boolean trueHeight = true; // checks if height is a letter between a-j/A-J
do {
Terminal.printLine("Input height with letters A to J");

[Code] ...

View Replies View Related

JavaFX 2.0 :: How To Dynamically Set Height Of Text Area

Jul 9, 2014

I have a requirement where in the content of the text area is dynamically populated from the database. I am able to successfully retrieve and display the data on the text area.
 
However when the content is too large, I am not able to dynamically set the height of the text area. When I try to display the same as a label, the display is flawless, dynamically sets the height as per the content. So, I tried to create a label, with same content and dynamically bind the height to the preferred height as below, but it doesn't work.
 
               // Generate User Note Description
                TextArea textArea = new TextArea();
                Label text = new Label();
             
               // SETTING THE TEXT TO A LABEL TO RETRIEVE THE HEIGHT
               text.setText(usrNotes.getNote().trim());
               
[Code] ....

View Replies View Related

JavaFX 2.0 :: How To Bind rows Height Of Two Tableview

Jan 20, 2015

I want to use to tableview one beside the other  so that they appear as a single table.  but I do not find how to bound the height rows of the two tableview.

View Replies View Related

Increment Counter By Recursion

Mar 22, 2015

I have a question related to the code below, that I do not understand. The aim is to count all files and subdirectories in an ArrayList full of files and subdirectories. So I have to count every file and every subdirectory.

The code concerning counting files is clear to me - every time d is of the type file I have to increment n by one. However I thought that I have to do the same thing in case d is a directory, so I would have written the same code for directories.

So what does "n += ((Directory) d).countAllFiles();" mean? In my understanding the method countAllFiles() is applied again on the object Directory ( as Directory is the class that contains this method), but how is n incremented by this? I thought n should be incremented by one as we did with files.

public int countAllFiles() {
int n = 0;
for(SystemFile d : content) {
if(d instanceof File) {
n++;

[Code] ....

View Replies View Related

Increment Array Values

Jul 5, 2014

I'm attempting to increment the values by 1 in an array of objects but I'm not able to increment with the increment operator.

for(int i=1;i<a.length;i++){
a[i].getHour(); hour = hour++;
a[i].getMin(); miinute = minute++;
a[i].getSec(); sec = sec++;
}

It just loops the value of hour without incrementing.

View Replies View Related

For Loop To Display And Increment?

Mar 1, 2015

I'm trying to display an columns and rows. The first column has integers and the rest are doubles. The initial calculations are correct, but I cannot figure out how to total last column, which is interest paid, and then start the iteration over.

int paymentNumber;
//print out the colum labels
System.out.printf("%7s %9s %10s %8s %15s %n", "Payment", "Interest"
, "Principal", "Balance", "Interest Paid");
System.out.print(" "); //put three blank spaces first
//Test For Loop Output:
for ( paymentNumber = 1; paymentNumber <= period*12; paymentNumber++) {

[Code] .....

Here's the output: It displays the payment number correctly. Am I supposed to write a for loop for each column?

run:
Please enter the amount of the loan:
1000
Please enter the interest rate:
1
Please enter the loan period in years.
1
Your Monthly Payment is:$83.79

[Code] ....

View Replies View Related

How To Call Increment Method

May 26, 2015

I have the following:

public class HistoricalMoment{

private String eventName;
private ClockDisplay timeOfEvent;
public static final int MIDNIGHT_HOUR = 00;
public static final int MINUTE_ZERO = 00;
}

How can I create a method called public void addMinuteToTimeOfEvent() which calls the timeOfEvent's increment() method to add one minute to the timeOfEvent?

View Replies View Related

How Does Post Increment Work

Mar 5, 2014

I have a code issue and I have a below question for the same.Assuming data[] is of type byte[], is the below statement in java -

while((data[p++] & 0x80) == 0x80);

same as -

while ( (data[p] & 0x80) == 0x80 ) { p++; }

I tried with do { p++; } while ( (data[p] & 0x80) == 0x80 ); That also doesn't seem to be the same thing. I am not putting code around this but essentially if I make this change for not using data[p++] code stops working!

View Replies View Related

Increment / Decrement Buttons

Nov 17, 2014

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

import javax.swing.*;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.*;
public class IncrementDecrementPanel extends JPanel {

[Code] ....

View Replies View Related

How To Increment URLs In String

Apr 13, 2013

I need open a url every time I want to refresh system with an update. Each update has a number so my urls are url1, url2, url3, ... I know how to put it in a loop to increment the urls in a String. I do not know how to make it open and close the url in a browser.

public class Test {
public static void main( String args[]) {  
for (int i = 201; i < 300; i++){
System.out.println("http://url=" + i);

[Code]....

View Replies View Related







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