Part Of Panel Missing - No Code Error (tried Changing Size)

Apr 20, 2014

import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.text.*;

public class aaa extends JFrame
{
private JPanel combinationp, np, ap, dp, surgeryp, medicationp, infop; // input = name, address, days
private JLabel namelabel, addresslabel, dayslabel, infolabel;
private JTextField nametf, addresstf, daystf, selectedsurgerytf;
private JButton calcButton;

[Code] .....

View Replies


ADVERTISEMENT

Java Code - Changing Text Size In Windows Settings

Apr 14, 2014

I have a major problem. the text size is like 6 or 8 pt font and I can't read it. I'm trying to run a downloaded exe program which uses the jre7 which I had to download beforehand. the font size stays at 6 or 8 even if I try to change it in windows settings. it's a high res monitor on a lenovo yoga laptop. is there a way for me to edit the java code and manually change the font size?

View Replies View Related

Error In Code While Changing String To Int Array

Mar 7, 2015

import java.io.InputStreamReader;
import java.util.Scanner;
public class FinalCombinations {
public static void main(String[] args){
//Read number of values
System.out.println("Enter the no of values");

[Code] .....

I am getting output like this

Enter the no of values
4

Enter the values
1
2
3
4

Enter the number for combination
2
C(4,2)=6
1
1
2
1
1
3
1
1
4
2
2
3
2
2
4
3
3
4

where as I want output like this..wit one array
1
2
1
3
1
4
2
3
2
4
3
4

View Replies View Related

Changing Panel In Frame Using MouseListener On JLabel

Sep 5, 2014

My program has a MainFrame(extends JFrame)class and BasePanel(extends JPanel) class,and many other panels.I had used Images with JLabel in BasePanel.My current panel in MainFrame is BasePanel.I had used MouseListener so that when I click on any of the label it should show Other panel in same MainFrame and hide the BasePanel.But I am getting some problem with that.When I click on the Label,It hides the BasePanel but do not show the new Panel(Dictionary Panel in my code). In short when label is clicked I want to make DictionaryPanel visible and BasePanel invisible,both in MainFrame. I am using the following code on Label:

//constructor of BasePanel class
public BasePanel() {
dict=new Dictionary();
mf=new MainFrame();
dictLabel.addMouseListener(new MouseListener() {
public void mouseReleased(MouseEvent arg0) {

[Code] ....

View Replies View Related

How To Set Size For Panel With Graphics2D Object

Oct 1, 2014

I am writing a program to solve Sudoku puzzles. I create the user interface using AWT/Swing.One panel of the main window (JFrame object) contains a Graphics2D component only (a grid for the sudoku puzzle). The problem is that this panel is too small for its contents when it is created. I have tried many things to make it bigger (like the setSize method of the panel), but to no avail. Who can tell me how I can make the panel with a single Graphics2D object larger?

Below is the code for the main window, which is a JFrame object. I set its size to 400 x 400 to have ample room for all panels. I then create two panels: a sudoku panel that contains the sudoku grid and a button panel that contains two buttons. The button panel has a flow layout.

I then create the main panel. This has a vertical BoxLayout. Finally I add the sudoku panel and the button panel to the main panel and the main panel to the frame.

public class ViewController_Graphics extends JFrame {
JButton solveButton = new JButton("Solve");
JButton nakedSinglesButton = new JButton("Naked Singles");

public ViewController_Graphics(SudokuModel model) {
super("Sudoku");
setSize(400,400);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLookAndFeel();
// create sudoku panel

[code]....

When I run the program, the following Window shows up:the button panel is exactly in the middle (and it remains in the middle, no matter how I resize the window). And there is not enough room for the sudoku panel. How can I make enough room for the sudoku panel when the window is created?

View Replies View Related

Swing/AWT/SWT :: Changing Panel In Jframe On Click Of A Button

Jun 22, 2014

I want to switch panel on click of a button and code for switching panels is written in update method (Which gets called from notify observer of another class as part of Observer pattern.

unoGameController.playGame(playerFirst.getText(), playerSecond.getText());

playGame in Panel 1 of class 1 calls another class (class 2)and data comes in update method of class 1(Observer interface).

Now for switching panels code is in gameControllerDataProcessing . I am not able to switch the panels when this functionality runs.

However if i dont call the unoGameController.playGame(playerFirst.getText(), playerSecond.getText() and directly call the update method or directly write the switching panel code . then it works fine.

btnNewButton_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if((!(playerFirst.getText().equalsIgnoreCase("") ||playerSecond.getText().equalsIgnoreCase(""))&&(!playerFirst.getText().equalsIgnoreCase(playerSecond.getText())) ) ){
unoGameController.playGame(playerFirst.getText(), playerSecond.getText());

[Code] .....

View Replies View Related

Swing/AWT/SWT :: Mini Paint Program - Changing Size Of Shapes

Jun 4, 2014

I am currently writing a small drawing program and I am having trouble with changing the size of the shapes. To do this, I have to access the arraylist shapes, check whether pressedX/pressedY is on any of the shapes in the arraylist using the findShape() method and then when released, uses moveBy() in the Rectangle/Oval/Line class and moveShape() in the miniDraw class to move the shape and draw it in the newreleasedX/releasedY position.

So far I think I have pin pointed the problem to being the method in all the shapes classes, that checks whether the pressedX/pressedY which is the on() method, and the findShape() method in the miniDraw class.

This is the minidraw class

import ecs100.*;
import java.awt.Color;
import java.io.*;
import java.util.*;
import javax.swing.JColorChooser;

[Code] .....

View Replies View Related

Missing Symbol Error

Apr 19, 2014

When I put this code in throw new IllegalStateOperation("SortType is invalid"); it states that it can't find the symbol IllegalStateOperation. What should I do to initialize the symbol/variable IllegalStateOperation?

Here is the entire code: :

class HairSalon implements Comparable<HairSalon> {
static final int sortByService = 0, sortByPrice = 1, sortByTime = 2;
private String service;
private double price;
private int time;

[code]...

View Replies View Related

Recompiling Maven After Changing Code

Aug 9, 2014

I have a very basic question about the Maven. I compile 2 dependent projects on maven and they have a problem, then I change a code and I recompile the project.

After that in the jar file of this project, I see that the code is the same, the error also shows me that the file is the same ( from the error line i can understand that) ....

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

Size Of Frame In Gaming Code - Full Screen Mode

Feb 17, 2014

Basically the code is for a game which is displayed in a window. The statement if(false) //full screen mode is confusing me a little. How does this if work? it doesn't seem to be testing for anything so how does it ever get set to full screen mode? Is the if even needed? why not just code windowed mode?

public class Window extends JFrame{
private Window()
{
// Sets the title for this frame.
this.setTitle("My test");
// Sets size of the frame.
if(false) // Full screen mode

[Code] .....

View Replies View Related

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

JSP :: Eclipse Project Window Shows Error But Code Editor Shows No Error

May 22, 2014

For my jsp file, the code editor shows no error, but the projects window shows an error. I built my project again, cleaned the project, restart eclipse twice and summoned cthulhu. But my project still shows an error. How do I find the cause.

Eclipse project -

JSP file -

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="mine" uri="DiceFunctions"%>

[Code] ....

View Replies View Related

JSP :: Error Page Is Not Displaying Instead Error Status Code Is Displaying

Apr 5, 2014

I have written some error checking code

File name ErrorPage.jsp

<%@ page language="java" isErrorPage="true" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Error</title>
</head>

[code]...

I have put error.jsp and badpage.jsp file in public access folder that is web content in eclipsewhen I am running the code I am status code of 500 and not the errorpage.jsp message .

View Replies View Related

Add A Zero For Decimal Part

Apr 19, 2015

Add the following method to the BankAccount class: public String toString()Your method should return a string that contains the account's name and balance separated by a comma and space. For example, if an account object named benben has the name "Benson" and a balance of 17.25, the call of benben.toString() should return:

Benson, $17.25

There are some special cases you should handle. If the balance is negative, put the - sign before the dollar sign. Also, always display the cents as a two-digit number. For example, if the same object had a balance of -17.5, your method should return:

Benson, -$17.50

Here is my code:

public String toString() {
String result = name + ", ";
if (balance < 0) {
result += "-";
}
return result += "$" + Math.abs(balance);
}

My code only works in case there are full two numbers for the cents part, not for the case when there's only one number. So I wonder how I can add an extra zero when needed.I can get only the decimal part and add a zero if it's less than 10, but I don't know how I can extract just the decimal part from the number. (The balance is just a double and it doesn't have any separate field for dollars and cents).

View Replies View Related

Code Compiles But Gives Error When Run It

Feb 17, 2014

So I am finishing up a GUI that randomly rolls a dice and shows you the dice face from a file that I have on my computer. It compiles fine, but when I open the GUI and press the button "Roll" it gives me errors and does not display the images.

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import java.util.Random;

[code]....

View Replies View Related

Search Code Error

Jan 14, 2015

I am pretty new to Java and I am working on a sample Search code from my textbook. I can't figure out why I am getting the following error because I copied the sample exactly as it is in the book. The error is illegal start of expression on the second to last line.

public class Search {
public static final int NOT_FOUND = -1;
public static int binarySearch( int [] a, int x )
{
int low = 0;
int high = a.length - 1;
int mid;

[code]....

View Replies View Related

BlueJ Error Code

Apr 6, 2014

the system I am using is blue jay and java. my problem is that I have this error message pop up whenever I try to compile any of my 6 classes. Three of the classes are cities, 3 others are shops, and the final one is a inventory called Player. The following is the error code that appears when I try to compile class THshopB or class CityB.

method run in class CityB cannot be applied to given types;required: Player; found: no arguments; reason: actual and formal argument lists differ in length

A similar error occurs for the rest of my City and THshop classes,except it replaces the class CityB with CityA and occurs in class THshopA, replaces CityB with CityC when occurring in class THshopC.The public methods of CityB and THshopB are shown below, as I believe that something is wrong with the public method of one or the other. I have the code [CItyB.run();}] inside of class THshopB, and run is the part that gets the red highlight error described above.THshopB public method

[ public static void shop(Player inventory){
CityB.run();}]
CityB public method
[ public static void run(Player inventory){
THshopB.shop(inventory);]

All of my THshop classes are written in the same format, and all of my City classes are written in the same format,

View Replies View Related

Extracting Part Of A String?

Oct 13, 2014

Okay So I am creating an application but I'm not sure how to get certain parts of the string. I have read In a file as such:

*tp*|21394398437984|163600
*2*|AAA|1234567894561236|STOP|20140527|Success||Automated|DSPRN1234567
*2*|AAA|1234567894561237|STOP|20140527|Success||Automated|DPSRN1234568
*3*|2

I need to read the lines beggining with *2* so I done:

s = new Scanner(new BufferedReader(new FileReader("example.dat")));
while (s.hasNext()) {
String str1 = s.nextLine ();
if(str1.startsWith("*2*")){
System.out.print(str1);
}
}

So this will read the whole line I'm fine with that, Now my issue is I need to extract the 2nd line beggining with numbers the 4th with numbers the 5th with success and the 7th(DPSRN). I was thinking about using a String dilemeter with | how to extract them once i've used the dilemeter.

View Replies View Related

Syntax Error When Testing Code

Jun 4, 2014

My issue is that when I run the code if I enter anything but 1, 2, or 3 the code breaks. I have spent hours trying to find the error. here is my code

import java.util.Scanner;
public class Tester {
public static void main(String[] args) {
/**
* constructor
* pre: none
* post: inherit values of other classes
*/
Car Car = new Car(); //inherits the properties of the Car class
Truck Truck = new Truck(); //inherits the properties of the Truck class

[code]....

View Replies View Related

Error And Dead Code Warning

Mar 26, 2015

There are 2 methods and a main one. The first is a void that creates a 3x4 2d array and the second is to search for a value in the array, if found it will return the number of the row that contains that value. If not, it will return -1, but I am getting 1 error and 1 dead code warning.I will put comments at the lines that contain the problems

import java.util.Scanner;
class Question4{
public static void main(String[]args){
Scanner s = new Scanner(System.in);
int x,n;
System.out.println("Please input the value that will be used in the array");
x=s.nextInt();
System.out.println("What is the value you want to search for?");
n=s.nextInt();
createArray (x,n);

[code]....

View Replies View Related

Inventory Part 2 Portion And Getting Errors

Apr 30, 2014

for my assignment I am to only add the sort and total inventory methods in the inventory class. And not create an array in the inventory class at all. My inventory class should contain all the variables needed to use with the two new methods: sort and calculate total inventory.By not creating any array in the inventory class and not touching the variables at all.For the inventoryTest class, I only need to declare an array of the inventory class by making an instance of the inventory.

public class inventory
{

private int prodNumber; // product number
private String prodName; // product name
private int unitsTotal; // total units in stock
private double unitPrice; // price per unit
private double totalInventory; // amount of total inventory

[code]...

View Replies View Related

Swing/AWT/SWT :: Extend And Retract Part Of GUI

Jul 18, 2014

I have a GUI that I've been working on for a while now. What I am trying to figure out, is a way to have the user push a button, and when they do have the GUI extend out to the right with another table to use for Filter Data. Once They are done, I want them to push that button again, and the panel with the query data retracts and is hidden again, all without changing the size of the current GUI in question. I've tried a bunch of different things with setting preferred and Minimal values to my GUI, and I've played around with different Layouts (Border Layout.East, etc), but I can't seem to find a good working solution.

Ideally it would be slick if I could make my panel SLIDE out and SLIDE back in, which would look really cool, but I'd settle for something that just worked.

View Replies View Related

Access Restriction Error In Decryption Code

May 21, 2015

I am getting error message on Java code that was developed by someone else and is supposed to work.

public String decrypt(String password) {
try {
// create the key and parameter spec
KeySpec keySpec = new PBEKeySpec(password.toCharArray(), salt, interactions);
SecretKey key = SecretKeyFactory.getInstance(keyFormat).generateSecret(keySpec);
AlgorithmParameterSpec paramSpec = new PBEParameterSpec(salt, interactions);
// create the cipher

[code]...

the error message is as follows: Access restriction: The type 'BASE64Decoder" is not API (restriction on required library '/usr/lib64/jvm/java-1.8.0-openjdk-1.8.0/jre/lib/rd.jar')I am using eclipse.

View Replies View Related

Getting Error On Java Code Using Parallel Arrays

Dec 1, 2014

This is my code.

public class PA9 {

public static void main(String[] args) throws FileNotFoundException {
// create data file to read from
File inf = new File("cityPopulationData.txt");
//Create a file to write out to.
PrintWriter fileOut = new PrintWriter("output.txt");

[Code] .....

This is my error

Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(Scanner.java:909)
at java.util.Scanner.next(Scanner.java:1530)
at java.util.Scanner.nextInt(Scanner.java:2160)
at java.util.Scanner.nextInt(Scanner.java:2119)
at PA9.getData(PA9.java:35)
at PA9.main(PA9.java:22)

View Replies View Related

Getting Error With Java Code - Using Parallel Arrays

Dec 1, 2014

Write a Java program to read from the data file, find the city with the highest population based on the 2010 census data, the city with the highest population growth from 2010 to 2013, the city with the lowest population growth from 2010 to 2013, and the city with the highest density (number of persons per sq. mile).

import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Scanner;

[code]....

View Replies View Related







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