When Add Second Panel The Result Is All White

May 11, 2014

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.

View Replies


ADVERTISEMENT

Swing/AWT/SWT :: When Click On Button From Bottom Panel Top Panel Need To Be Redrawn

Apr 1, 2014

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);

[code]...

View Replies View Related

BufferedImage Has White Padding On Top?

Jul 27, 2014

What I am doing is loading a new image from resources in my project, so that I can get the size. Using this, I create a new BufferedImage with those dimensions. The following code is what I am using to take the original BufferedImage, and scale it.

Java Code:

public ImageIcon getBackImage(){
before = new BufferedImage((int)img.getWidth(null), (int)img.getHeight(null), BufferedImage.TYPE_INT_ARGB);
int w = before.getWidth();
int h = before.getHeight();
try{
URL url = getClass().getResource("/Blue_Back.png");
before = ImageIO.read(url);

[Code] ......

The scaling seems to be working fine, but what I have noticed is a line of approximately 10 pixels at the top of the image. I took the original image and blew it up to ensure that I wasn't just enlarging undesired portions and this wasn't the case. I then tried to fetch a subImage of the BufferedImage, and that also left the padding at the top. Is there something I am missing that is placing this undesired padding at the top of my bufferedImages ?

View Replies View Related

Deleting White Spaces In Java Code

Mar 1, 2014

My method below works fine to print a matrix but when it prints every row, it is printing extra 4 white spaces which is not required. How can I delete those extra spaces at the end? when I use

System.out.print((matrix[i][j] + " ").replaceAll("^s+", ""));

It trims every thing including the spaces I needed for my matrix. So where should I put replaceAll("^s+", "") ?

private static void printMatrix(int[][] matrix) {
System.out.println();
System.out.println("Matrix:");
for (int i = 0; i < matrix.length; i++) {
for (int j = 0; j < matrix[i].length; j++) {
System.out.print(matrix[i][j] + " ");
}
System.out.println();
}
}

View Replies View Related

Laptop Screen Shows White Lines

Apr 28, 2014

When I open applications specially high graphics applications, the screen flashes with whole black display with a number of horizontal white lines then after 2 or 3 flashes it opens the desired program. What is the cause, is it low graphics memory, physically damaged screen or ?

View Replies View Related

Generating Picture - Black And White Sketch

Nov 19, 2014

I'm stuck with a problem. The code below generates a coloured image.

//Setting the size of the graphics window
final int WINDOW_DIMENSION = 200;
final int SIZE_FACTOR = 3;
EasyGraphics generate = new EasyGraphics(WINDOW_DIMENSION*SIZE_FACTOR,WINDOW_DIMENSION*SIZE_FACTOR);
 
//Constructing the arrays
char[][] firstArray = new char[WINDOW_DIMENSION][WINDOW_DIMENSION];
char[] secondArray = scan.toCharArray();
 
[Code] ...

What I would like to do is generate a picture which is mostly white but the colour boundaries of the original picture are in black. I tried using the code below but it doesn't produce what I wanted.

for (int a = 1; a < WINDOW_DIMENSION; a++) {
for (int b = 1; b < WINDOW_DIMENSION; b++) {
generate.setColor(0,0,0);
if(firstArray[a][b]!=firstArray[a-1][b] || firstArray[a][b]!=firstArray[a][b-1])
generate.setColor(255,255,255);
generate.plot(a,b);
}
}

View Replies View Related

JavaFX 2.0 :: Blank White Screen While Starting App?

Jun 24, 2015

This screen appears for a second and after this, it shows up normal app screen. How I can solve this issue? When I open app: after this

View Replies View Related

How To Switch From One Panel To Another Panel

Apr 5, 2014

I have two(panel1 and panel2) panels in a jframe,all three of them are different classes .

In jframe there is a display panel on which the panel1 and panel2 are called and displayed.

now i have a button in panel1 .i want that when i will click on that button panel2 will be displayed or added to the dispalypanel of jframe.

View Replies View Related

Pass A Command Line Argument Value With White Space In Between?

Feb 3, 2014

for example, I want to pass 'Hello Word.docx' and 'Winston' (both without quotes) as a command line argument as I execute the main method

Is it possible to pass 'Hello World.docx' as a whole word?

View Replies View Related

Drawing Simple Yellow Rectangle In White Background?

Feb 1, 2014

Here is the code, I just wanted to draw a simple yellow rectangle in white background...

import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
public class NewEmpty extends Jframe {
Rectangle test = new Rectangle(100,100,100,100);
public NewEmpty()

[Code] .....

Errors in the compiler ( i think there's something wrong with that Jframe)

init:
deps-jar:
Compiling 1 source file to C:Users****Gametestbuildclasses
C:UsersMarcoGametestsrcgametestNewEmpty.java :6: error: cannot find symbol
public class NewEmpty extends Jframe {

[Code] .....

5 errors

BUILD FAILED (total time: 0 seconds)

View Replies View Related

Classing White Space As Invalid Name When Close Button Is Pressed

Oct 29, 2014

I have a filechooser that works how it should and if anyone enters anything with a dot that isnt .xml it shows an invalid file name message. However when I dont choose a file and press cancel it still says that because when my boolean hits false it's the first thing it hits in that section of code.

if(!writeSuccess)
{
//display output messages in JOptionPane
JOptionPane.showMessageDialog(null,"Error, file name invalid", "Error", JOptionPane.ERROR_MESSAGE);
} else {
JOptionPane.showMessageDialog(null,"Export successful", "Success", JOptionPane.INFORMATION_MESSAGE);
//close the form
me.dispose();
}

If I want it to just close down without it saying anything is there sort of if statement I could do that would prevent this? But if it is an invalid file name it will still show that message?

View Replies View Related

JavaFX 2.0 :: Progress Indicator In ListView Has Border And White Background?

Dec 1, 2014

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.

import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.scene.Scene;
import javafx.scene.control.ListCell;
import javafx.scene.control.ListView;
import javafx.scene.control.ProgressIndicator;

[Code] .....

View Replies View Related

Unable To Remove White Background Of PNG Image Added In Transparent JPanel

Sep 25, 2014

I am unable to clear disappear the background of .png image added in a translucent JPanel. I have tried it using JLabel but the image added is with white background. How can i get rid of this white background...

import javax.swing.*;
import java.util.*;
import java.awt.*;
public class HomePage
{
JFrame frame;
JPanel pnl1, pnl2, pnl3;
JLabel lbl;

[Code] .....

View Replies View Related

Make Shapes Besides Making Two Lines For X And Oval With White Smaller Oval Inside To Make O

May 8, 2014

We are making a tic tac toe game for my CS120 class and I am having trouble figuring out how to make our X's and O's. Is there a way to make shapes besides making two lines for an X and an oval with a white smaller oval inside to make an O? We have only learned the basics so far in class (i.e. events, inheritance, client-supplier, etc.)

These are our instructions:

Write a controller that controls the game. There is one human player (the X player) and the computer player (the O player). The name of the class must be TicTacToeController. In a sense, the controller is the game since the controller will 1) create a TicTacToeModel 2) create a TicTacToeView and 3) create a TicTacToeButton (you must write this class following the design pattern covered in class lectures), a label, and text field such that when the button is pushed, the player moves into the cell selected by the text field. After every player move, the computer moves into a randomly selected empty cell. When the game is over, a text message must be displayed somewhere on the screen the gives the status of the game. While you are free to change the appearance of the controller, the basic elements must be provided (a view of the game, a button, and a text field to enter the cell). A sample screenshot is displayed below.And this is the code i have thus far:

[import java.awt.*;
import javax.swing.JFrame;
public class TicTacToeView extends Rectangle
public TicTacToeView(int x, int y, int w, int h) {
super(50,60,w,h);
this.setBackground(Color.red);
JFrame win = new JFrame("Tic Tac Toe");
win.setBounds(10,10,w+100, h+100);
win.setLayout(null);
win.setVisible(true);
win.setBackground(Color.gray);

[code]....

View Replies View Related

Calculate (C) How Is The Result 3

Apr 3, 2013

public class NewClass4 {
public static void main(String[] args) {
int a = 1;
int b = 2;
int c = 3;
a += 5;
b *= 4;
c += a * b;
c %= 6;
System.out.println("a = " + a);
System.out.println("b = " + b);
System.out.println("c = " + c);

View Replies View Related

Returning A Result And Then Using It In Main

Jan 4, 2015

I've made a class called Car with a method which will tell me a category for the engine size regarding the actual size (which I've included in the main just so I could see if it works) but everytime I test it I get an error.

public class Car {
public String b;
public String c;
public double es;
public double cs; 
public String getCategory() {
if (es < 1.3)

[Code] ....

Figured it out. Was missing parenthesis on audiCar.getCategory();

View Replies View Related

Scrolling In Panel Won't Work

Oct 9, 2014

I've got a panel which an arbitrary number of text fields may be added to at run time. I've got it set up so that the window's height, and the height of the panel in which the fields appear will never exceed the height of the screen.What I don't have is a way to make the panel scroll to access the fields that are being visually truncated. I'm setting the autoscrolls on the panel to true, but when I run the program, the fields are simply truncated.

pnlDeclensions.setAutoscrolls(true);

View Replies View Related

Which Listener To Use On Video Panel

Jun 4, 2014

I have panel = window(new frame) and its used to render a video image on, i need to pickup a touchscreen press change of event but not sure which event listener to use and on which component. Is it a panel, window or frame event? and which listener would detect a focus change or a mouse press

I know mouse listener and focus listener and window listeners are available but not sure they would be able to detect the screen press on the video rendered image...

View Replies View Related

Using A Database Query Result

Nov 17, 2014

I have done 90% of the coding however i am stuck with producing the output, i just cant get the user fields to show.

I have attached a picture of the output that is required. The program consists of two classes i have attached the database class, and have inserted my coding below.

import java.sql.*;
import java.io.*;
import java.util.*;
public class QueryDB {
private Connection con = null;
String userID,

[Code] ...

Attached image(s)

View Replies View Related

Program Won't Go To Result After Input

Feb 19, 2014

I have to create a program that takes a list of student names and grades and then takes the 2 highest scores and reads them, but the result won't show. I'm pretty sure it's because I'm not sure about how to code the last part which should output the results. Here's my code.

import java.util.Scanner;
//Reads input and outputs 2 highest scores
//for loop. nested for.
public class HighestScores {
public static void main(String[] args) {
//create values
String studentName;

[Code] .....

View Replies View Related

Graphing Using Drawing Panel

May 1, 2014

import java.awt.*;
 public class Program5 {
 public static void main(String[] args) {
DrawingPanel panel = new DrawingPanel(300,500);
panel.setBackground(Color.white);
Graphics g = panel.getGraphics();
g.setFont(new Font("Helvetica", Font.PLAIN, 12));
double ball = 10;

[code]....

I'm fairly new to Java and am having a hard time with this particular assignment. The program runs and shows up on the drawing panel fine but I can't get the lines quite right.Capture.jpg

View Replies View Related

Fill A Panel With Seats

Jun 13, 2014

We get a database and some DAO classes. We had to fill a ShowPanel with different shows being given in a theatre, and then when you choose from this you get several dates. Then when you click a date, the seatings appear in the SeatPanel. I got the first part with the shows and dates. But Im stuck at getting the seatings.We have a controller class which calls the shows+dates (this happens in one method). But i always get a nullpointerexception for the seatings. (this happens in a different method). I think i just don't know how to link the chosen show+date with the seatings.For the moment i have

public ArrayList<Seats> getSeating() throws SeatingException{
Show s = shows.getName();
ArrayList<Showdate> showdate = s.getDates();
ArrayList<Place> seating = new ArrayList<Place>();
try{
for (Showdate sd : showdate ){

[code]...

The given class PlaceDao has a static getInstance() method and an ArrayList<model.Place> getSeating(model.Showdate showdate) method.In the next stage i have to try and fill the panel with the seatings, but first i need to be able to call them.

View Replies View Related

Button Not Showing On Panel?

Jan 27, 2014

I have three classes.. 1. panel class 2. frame class and 3. tester class...I am creating the objects like so but when I add button to panel then panel to frame I am not seeing the button. here is my code

import javax.swing.JButton;
import javax.swing.JPanel;
public class Panel extends JPanel{
private JPanel p;
private JButton b;

[code]....

View Replies View Related

Centering A Panel In JFrame

Nov 19, 2014

Okay so I have the codes all written but I didn't really look at that I had to color the center of the frame. I have base code for it but it just doesn't want t ocolor the cnter frame for me for some reason. I have been looking around and still am having problem with it only coloring the center of the frame.

Java Code:

import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
public class MenuColors {

[Code] ....

View Replies View Related

Using Database Query Result

Nov 20, 2014

I have to get my output to show as per the image attached i am very close but not there yet. I have also attached the database where i extract my information from

/*
Program Name: QueryDBDB.java
Purpose: to build an initial database for the stocktrakcer application
*/

import java.sql.*;
import java.io.*;
import java.util.*;
public class QueryDB
{
private Connection con = null;
String userID,firstName,lastName,name,symbol;
public QueryDB() throws Exception

[Code] .....

Attached image(s)

View Replies View Related

How To Get Object From Panel Back Across To GUI

Jul 6, 2014

I've been putting together an addressbook and try to work on some idea but I have hit a bit of a wal early on, and Im sure the problem is easy to resolve, I just can't get the old brain to do it.At present I have 5 classes

PersonDetailsAdressDetailsAddressBookAddressBookGUIEnterDetailsPanel

I have taken EnterDetailsPanel out of the main GUI code, as I plan, or had planned on using additional JPanels for the other options of the application until I got stuck. What I want the EnterDetails panel to do, which it does so far is to have the user enter all of their information and when the button is pressed it will then create a PersonDetails object and here is where my problem is. how to get the object from the panel back across to the GUI which initalises the AddressBook class in the constructor and add it to the List via an addDetails() method.

If I create a quick method in the AddressBookGUI class I can add the object to the List fine, I'm guessing this is because I have created a new instance of the AddressBook in here already via the constructor, however if I add an AddressBook reference in the EnterDetailsPanel I get a nullpointerexception for the opposite because it's not been created in there.These are what most of the classes do so far.

PersonDetails has a reference to the AddressDetails and holds all information for that person.AddressBook contains a List that accepts PersonDetails and has methods to add/remove the person.AddressBookGUI creates a new instance of the AddressBook class along with the general gui things. EnterDetailsPanel is added to JTabbedPane in the GUI class and allows the user to enter their details and submit those via a button which will then create a new PersonDetails object that I am trying to get added to the AddressBook class List

View Replies View Related







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