JComponents Remained On Side When Frame Size Was Increased?
Apr 29, 2014
Below is a picture of a frame which needs is formed/opens as result of the button-click event of a button. I am copying the code of the entire action listener as well. The problem is that the size of the frame set by setSize(x, y), but the components don't appear accordingly. The size of the frame has increased (by setSize(x, y), i had set a different size earlier which was smaller) and so the components appear at one side on the frame.
Java Code:
static class btninstr_Action implements ActionListener{
public void actionPerformed(ActionEvent arg0) {
JFrame frame2= new JFrame();
frame2.setVisible(true);
frame2.setSize(500,500);// add custom panel to get perfect work
[Code] ....
View Replies
ADVERTISEMENT
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
Jan 20, 2015
I am trying to display two JComboBoxes side by side. I can successfully display them as part of a BorderLayout if they are in the North and East, but when I try to display them side by side in the same area, eg North, only one of the combo boxes gets displayed.
package selectingshapes;
import java.awt.Graphics;
import java.awt.Color;
import javax.swing.JPanel;
import java.awt.Graphics2D;
import java.awt.FlowLayout;
import java.awt.event.ItemEvent;
[Code] .....
View Replies
View Related
Aug 16, 2014
I'm using SchedulerExecutorServices to Schedule a task. My Question is how can i schedule more than one task side by side:
Here is what I'm doing:
public class Scheduler {
public Scheduler(Runnable thread, int startAfter, int iterateAfter, TimeUnit timeUnit, int length) {
ScheduledExecutorService scheduler = Executors
.newSingleThreadScheduledExecutor();
final ScheduledFuture<?> timeHandle = scheduler.scheduleAtFixedRate(
[Code] ....
View Replies
View Related
May 12, 2015
I'm trying to use in the constructor inserts from keyboard and then check whether any of the constructors fields remained empty. Let say my constructor is:
public SomeClass(String a, String b, String c)throws SomeClassException{
if (a == null || b == null || c == null) {throw new SomeClassException("Some message"); // here is the empty test
} //...
Thus I prepared method: insertConstruct() as follows:
public static String insertConstruct(){
String lettering = null;
Scanner sc = new Scanner(System.in);
lettering= sc.nextLine();
return lettering;
}
And during creating the new object in some main method I call:
// ...
ClassName obj1;
obj1 = new ClassName(insertConstruct(),insertConstruct(),insertConstruct());
//...
The problem is not with inserting data but with leaving the field empty. When I pass any field just with keyboards Enter, the empty test doesnt return me any message about it. While it works if I build object with the constructor like:
// ...
className obj1;
obj1 = new ClassName("word a",null,"word c");
//...
What might case this failure?
View Replies
View Related
Jan 16, 2015
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
View Replies
View Related
Oct 23, 2014
I was making this program and I ran into an issue which is that I cant seem and understand how to get the numbers to go to the other side of the table
I had to make a program that converted 1-9 miles to kilometers and the other side 25-65 (increments of 5) kilometers to miles and thats the part I am having trouble with.
Here is what I have so far
import java.util.Scanner;
public class MilesAndKilos {
public static void main(String[] args) {
int miles;
double kilometers=1.60934;
[Code] ....
and this is how I want it to look
MilesKilometersKilometers Miles
1 1.609 | 25 12.430
2 3.219 | 30 15.538
3 4.828 | 35 # here
4 6.437 | 40 # here
5 8.047 | 45 # here
6 9.656 | 50 # here
7 11.265 | 55 # here
8 12.875 | 60 37.290
9 14.484 | 65 40.398
View Replies
View Related
Apr 6, 2014
I want to ask that, when a server listen to A port and it accepts a request from a client then the server accepts the request using accept method,but how does the server get the info about the client like wat is the port no and ip address of the client,I read a answer regarding this that Server never gets the port no of client only the ip address and it connects to client using a connection stream but as far I know from networking, a device must have the ip address and port no of the device it wants to connect to.
View Replies
View Related
Nov 25, 2014
in my web.xml the.STATE_SAVING_METHOD setting is server
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
for measurement of application security isn't not allow to change this parameter to client , so the problem when I access for application and I open a new page via linker for print for example and I would access for my initial page to make change or modify my initial page it s no possible to make any modification because I have a empty bean , but if the state saving is a client I haven't a problem because a tree map is stored in client browser, so my version of JSF is 1.1.1 ,
View Replies
View Related
Jan 18, 2014
I have been following a 2d side scroller tutorial in java and have got the basics working, I changed the code a bit to make it so that the tiles and background are always moving, this worked as i intended.Within the character class:
if (speedX < 0) {
centerX += speedX;
}
if (speedX == 0 || speedX < 0) {
bg1.setSpeedX(0);
bg2.setSpeedX(0);
[code]....
I wanted a way to make it so that if the character moves left, the tiles + background move slower. I am having issues with variable scope and setters/getters. Within the main game class, I have the code:
case
KeyEvent.VK_LEFT:
character.moveLeft();
character.setMovingLeft(true);
break;
How can i include an if statement within the tile class that reads whether the character is moving left (determined from a keyPressed event in the main game class) and adjusts the speed of the tiles accordingly?I want to write something to the effect of:
if (setMovingLeft = true){
speedX = bg.getSpeedX() * 3;
tileX = tileX + speedX - 1; << changed from - 4
View Replies
View Related
Sep 12, 2014
i am running unix scp command as below using Runtime.getRuntime.exec();
scp -P10022 -i /home/.ssh/id_ds 2937_filename.xls Username@hostname
following is the syntax in java:
final Runtime r=Runtime.getRuntime(0;
final String[] arg={ "/bin/sh","-c",command};
final Process process=r.exec(arg);
i am getting followin error java.io.IOException: cannot run program "/bin/sh: java.io.IOException: error=12, Cannot allocate memory
what i need to update to allocate memory in windows side.
View Replies
View Related
Apr 8, 2014
I want to know what is the best way for server side validation in servlets with JSP.
View Replies
View Related
Apr 3, 2015
I have a Registration Form in which I am registering user to perform some sort like Entering messages I want to perform some Server Side validation.
Like suppose a user has Enter an Id then as soon as he start entering the Id then I want that this Id should be checked in database that if this Id exists in database or not.
and similar types of validation I want to apply on other fields to.
How can I acheive this?
View Replies
View Related
Nov 27, 2014
I am calling a SOAP based webservice using JAX-WS and a client jar. I want to get a request and response somehow and save it for audit purposes. How I can do this?
When I google it, only Handlers come up, but, as far as I understand, it is not applicable on client side.
View Replies
View Related
Jan 18, 2012
I have some data in the database and values can be added on demand. so when ever the value added to the database i need to promt that message to all users which are accessing my website, so how can i acheive this....
View Replies
View Related
May 6, 2014
We have a weblogic based application, which runs Applet at the client side when the application is launced.
the application is getting freezed for a client.
how we can analyze the cause of this behavior,
1) As to how we can take thread dump or any other details to analyze the issue.
View Replies
View Related
Jan 6, 2015
I used tomahawk t:tree for showing my data in tree structure and displayed that very fine. But my problem is how can we find the node id in bean side when we select one node .Because i want to show some data based on that node.
View Replies
View Related
Jul 16, 2014
I need to write server side program(Servlet) which must be access by several requests at same time.how to handle this using java? Do i need to use queue or multiple instance of same class. Any example server method which returns the results based on ID
public String getResut(int id){
1)get db connection
2)get the result from db
3) retun the result
}
View Replies
View Related
Jun 8, 2014
In order to create an xhtml view:
1. All jsf tags like datatable, form, etc.. will generate UIComponents in server side, right?
2. All non JSF tags will not generate UIComponents in server side, right?
3. If you want something in a view that will be the same across users and requests, I mean, It will not change like a label tag, it doesn't make any sense to create it with a JSF tag in order to save memory in server side, right?
View Replies
View Related
Jan 25, 2013
I have to show more than one images on a jsp page which are frequently refreshed. I am getting images in stream from client end and i want to show them on jsp. How can show them on jsp and refresh them after getting new image from client side?
View Replies
View Related
Aug 16, 2013
I am very much new to jsp and servlet. I want to set global error page for every exception occured at server side. I am trying with following code , but something is going wrong and I am not able to c error page.
package com.web;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
[Code] ....
View Replies
View Related
Jun 3, 2012
I need to implement Oauth2 with facebook to get authencation. I tried to write a servlet with the method Service, and i got the code thah i have to use in a second request.
Now i need to send a request at this URL :
1) [URL] .....
and wait for a responce with an URL that have the access_token to use with facebook
2) [URL] ....
Is it Possible in a single Servlet after i receive the "code" to send a second request to the URL in 1 and get the response with URL in 2 to retrieve the access_token?? if yes....how??
View Replies
View Related
Aug 13, 2014
i have created a frame with a menu bar displaying contents..now i want to set a username and password to that flame through an applet how to add applet to the frame??
here is my code ..
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
class MenuFrame extends Frame{
String msg="";
int flag=0;
CheckboxMenuItem debug,test;
[Code]...
View Replies
View Related
Apr 13, 2014
I can't seem to add second component to frame what this class creates:
package TestVersion;
import java.awt.Color;
import java.awt.Component;
import javax.swing.JFrame;
import TestVersion.CKeyListener;
import TestVersion.GameWorld;
import TestVersion.MatWood;
public class MYCoreWorld {
[Code] .....
View Replies
View Related
Sep 20, 2014
I created a instance of a class AddItemView, inside StartUpMenuController. I then passed it into the class, the main method is below showing that as well. However when I do this:
else if(e.getSource()==menu.addBtn)
{
new addItem();
}
I get an error, little red line on the bottom of the text. I am testing the frame at the moment to make sure it is what I want before I move on to the Controller side of it. I just want to display it and go from there.
package mainMenu.Home.DataBase;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import addItemBtn.Home.DataBase.AddItemView;
public class StartUpMenuController
{
StartUpMenu menu;
AddItemView addItem;
[code]...
Not sure if this is the issue but the class I am making a new instance of is in a different package. I imported the package though.
View Replies
View Related
Mar 12, 2014
i have been struggling with 2 frames.the question here is, how can you let a frame disappear and let another one appear.im making a game and when i click on start it needs to show another frame.got the whole code here:
import java.awt.Color;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class RushhourStart
{
public static void main(String [] args)
{
JFrame frame = new JFrame();
frame.setSize(700, 700);
frame.setTitle("Rushhour");
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame. EXIT_ON_CLOSE);
frame.setVisible(true);
[code]...
View Replies
View Related