Swing/AWT/SWT :: How To Turn On Light Through ActionPerformed With OpenGL Java

Apr 29, 2015

I'm writing a java program with opengl and I'm trying to get it where the user would select something like lighting on in a JMenu and then it would turn the lighting on in the house/barn... I have a method called LightOn that I put gl.glEnable(gl.GL_LIGHT0); but it just doesn't seem to turn on when I call it from the action performed... Is there something I'm missing from my code that I'm supposed to use instead since I have tried it with a boolean.. So the boolean starts off as false and when the JMenuItem is clicked the actionPerformed will turn the boolean to true and call the method LightOn. In the display method I have what the light is supposed to be

Snippet of code in display method for lighting:

float [] whiteLight = {1.0f, 1.0f, 1.0f, 1.0f};
float [] ambientLight = {0.1f, 0.1f, 0.1f, 1.0f}; //default
gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_DIFFUSE, whiteLight,0);
gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_SPECULAR, whiteLight,0);
gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_AMBIENT, ambientLight,0);
float [] lightPosition = {25, 25, 25, 1};

[Code] ....

View Replies


ADVERTISEMENT

Why Does Traffic Light Jumps Over Red Light State

Nov 27, 2014

I have a TrafficLightsManager Thread class that create one new CarTrafficLight object, and manage him by synchronized semaphore.

Unfortunetly the line sleep(5000); after the traffic1.WaitToRed(); never happenned, and the class jumps very quickly over the Red State.

I added the Message "!!!" before moving out from the Red State to the orange to check if the red exists at all and the result was positive - the red status entered and then I got the "!!!" message,but at the second that I accepting the message the red state turns into the orange state......

I don't get it!!!

package MyTzomet;
import java.awt.Point;
import javax.swing.JOptionPane;
public class TrafficLightsManager extends Thread {
CarTrafficLight traffic1;
ViewFrame frm;

[Code] .....

View Replies View Related

Swing/AWT/SWT :: ActionPerformed And ActionListener On Netbeans Are Same?

Mar 3, 2014

ActionPerformed and ActionListener on Netbeans...If I create a ComboBox on Netbeans using GUI design, then I right click over the Combobox I can find Events - Action - ActionPerformed... but I can't find ActionListener...

Are ActionPerformed and ActionListener the same?

or...

where is ActionListener on GUI Netbeans? Do I need to manualy write the ActionListener part?

View Replies View Related

Swing/AWT/SWT :: Background Color Of JTabbedPane Is Light Blue?

Feb 18, 2014

No matter what I did, and searching for every piece of setBackground, The background color of the JTabbedPane is light blue.

public final class MainFrame extends javax.swing.JFrame implements Runnable, WindowListener,
WindowFocusListener,
WindowStateListener {
Container mainPanel;
JPanel bluePanel = new JPanel();
CloseButtonTabbedPane tabbedPane;

[Code] ....

View Replies View Related

Swing/AWT/SWT :: How To Rotate 2D Square Using Maths Equations Through OpenGL

Feb 23, 2015

So I need to create a square and make it rotate when the letter R is pressed and then make it stop when the letter R is pressed again. I need make it rotate using a maths equation that I can't figure it out myself right this moment.

Code for square:

package lab2;
public class Square {
public double [][] vertices = new double[4][2]; //not good to make this public
public Square(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) {
vertices[0][0]=x1;
vertices[0][1]=y1;
vertices[1][0]=x2;

[Code] ....

In the Square code there is a method to write an equation to rotate it but I can't figure that part out ....

View Replies View Related

Textures And OpenGL With Java

Mar 7, 2014

I was trying to understand Textures and OpenGL with Java. but the tutorials I find cover such a horribly broad area X_x.Basically I can get a window up, initialize openGL, and draw many repeating blocks on my screen.

I dont specifically care about minecraft. but I would like to learn how to get Many many blocks on the screenand how to apply more than one texture to a block. I cant seem to load two textures at a time without errors. I have a dumb while loop that includes a few For loops that repeat the blocks.I guess I should learn how to use Arrays to automate the block process ? Im not sure. I started reading about object buffers, but im not sure.

public static void initDisplay()
{
try {
Display.setFullscreen(true);
Display.setVSyncEnabled(true); // Drastically effects updates per second, Camera movement lowers by 98%

[code]....

View Replies View Related

Traffic Light Simulation Using Multithreading

Feb 2, 2015

I am writing a simple program to simulate a traffic light. What I want is to make them glow after each 1 second, one by one. For example: Firstly Red, then after 10 seconds, red will be put to off and yellow will start glowing and then accordingly green. This process shall continue incessantly (Just for experimental purpose). I have some arrangement done but could not figure out how to put them together in run() method of Runnable interface. I know how interthread communication works. But could not find any logic in this case when three threads will run together.

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class TrafficLight extends JFrame implements Runnable
{
JButton red, green, yellow ;
TrafficLight()

[Code] .....

View Replies View Related

ActionPerformed Method For JTextField Not Working

Feb 8, 2015

I made a program to see how JTextField works. However,the contents inside the actionPerformed method of class FieldListener do not get executed when I press enter.

import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
public class Checker
{
public static boolean check;
public static JFrame imgframe;

[code]....

View Replies View Related

How To Remove Object From Jframe As Part Of ActionPerformed

Mar 11, 2014

I currently have a program written that outputs a canvas object and adds a picture of 5 taxis to it.I have now added a jtextfield so that a user can add an interger. Ideally if the user was to enter the number 8, there would be 8 taxis added to the canvas.I am having trouble with the final part i mentioned. how to delete the old canvas and output a new one with the amount that the user wrote in the jtextfield.

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Random;
import javax.swing.*;

[code]....

View Replies View Related

How To Start Algorithm For EnterAction ActionPerformed Button

Nov 23, 2014

I've written my program and don't know the algorithm for a postfix notation and how to make one correctly?how to start my algorithm for my enterAction actionPerformed button?

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

[code]....

View Replies View Related

Unexpected OpenGL Simple Movement

May 28, 2014

I am new to DreamInCode! I was creating a game using OpenGL (and slick for textures).

Using Vector3f, I make coordinates to where my camera is camera'ing (and rotation).

It was working... until I modified something. I only added shaders. When I took the shaders off I think I might of accidentally deleted something. Nonetheless the code looks perfect to me.

On the method "input()" everything runs. No errors are thrown anywhere. I have syso'd the hell outa my code. It shows no signs of breaks. I can, however, move elements I put into my program. I am 100% sure that no other class is breaking my game (soon to be).

What you should look out for: I am not really sure about the glLoadIdentity()'s and glMatrixMode(). I am, knowing a good part of, thinking it could be gluViewPort....

My problem: Can't move my camera even tho it was working before.

package com.Hydroque.OpenGlTest;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.util.glu.GLU.gluPerspective;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;

[Code] ....

View Replies View Related

JavaFX 2.0 :: Multiple Display Using OpenGL-ES2

Jul 15, 2014

I would like to know whether multiple displays are supported under (Windows/Linux/mac) when we use opengl-es2 pipeline?

View Replies View Related

JavaFX 2.0 :: Force Prism To Use OpenGL Version 4.1

Jun 25, 2014

Setting VM argument prism.verbose=true gives some insight of what happens.

There i see an old openGL version is used on OSX 10.9:
 
Graphics Vendor: ATI Technologies Inc.
Renderer: AMD Radeon HD 6630M OpenGL Engine
Version: 2.1 ATI-1.22.28
 
How do i force prism to a newer openGL version?

View Replies View Related

JavaFX 2.0 :: Turn Off ListView Selection

Jul 21, 2014

I have a ListView with ListCells that are complicated things containing other nodes. I want to turn of ListView selection behavior (so not allow selections) without turning of events to the ListCell nodes in the ListView.

View Replies View Related

How To Attach OpenGL Display To JFrame And Dispose Off It Properly

Nov 12, 2014

How can i attach the OpenGl display to a JFrame and so that when i close the JFrame is destroys the display? Here is my code so far:

package test.core;
import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Component;
import java.awt.event.WindowAdapter;

[Code] .....

I had the opengl display attach to the JFrame before i did the runnable. But after adding the runnable the display now shows up the same size as my screen size. I have tried rearranging the

canvas.setSize();
and the
frame.setSize();

but nothing changes the opengl display is still the same size and when i try to close the JFrame first rather then close the display first i get this error:

Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: From thread Thread[AWT-EventQueue-0,6,main]: Thread[main,5,main] already has the context current

which points me to my

Display.destroy();

which im guessing is telling me that i am not properly disposing the display? How to attach the opengl display to the JFrame and fix the error above?

View Replies View Related

How To Get Input Strings To Print Out After Turn Them Into Tokens

Jun 23, 2014

how do i get the inputed strings to print out after i turn them into tokens ? I need it to ask for a number and then multiple lines of strings, turn them into tokens, then print them out.
 
import java.util.*;
public class TokenDriver{
public static void main(String [] args){
// TokenStore words = new TokenStore();
String[] tokens = new String[300];
 
[code].....

also as a follow up how would use an array in an other class (TokenStore) to save the typed line information

View Replies View Related

Can't Do Table Score Which Updates New Scores After Each Turn

Dec 20, 2014

i am a french student in France and i am studying informatics . For validating my term at the beginning of January i have a projet in JAVA to do called YAHTZEE. It's a game which i have to code WITHOUT USING AN OBJECTS. I already started the coding, i did all the beginning stuff ( to call the number and the names of players, to roll the 5 dices, i made the code for all the scoring points too(rules) ) but i can't do the table score which updates the new scores after each turn ( 3 turns in total) .

View Replies View Related

JSP / JSTL :: How And Where To Turn Off Auto-reloading Of Servlets

Apr 26, 2013

I am using Jboss as application server and tomcat as web server.

How to turn off auto-reloading of servlets and jsps.

View Replies View Related

Create A Simple User Database That Could Eventually Turn Into A Login System

Jun 6, 2014

So I'm trying to create a simple user database that I could eventually turn into a login system. I created a simple table on MySQL with a name and address for the sake of simplicity. I tried to create simple statement inside my main method that would connect to my MySQL server and when I run my program I get a ClassNotFoundException from "org.gjt.mm.mysql.Driver"..Here is what I have in my main method thus far:

public static void main(String args[]) {
try {
Class.forName("org.gjt.mm.mysql.Driver"); //Load the driver
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/data", "root", ""); //Connect
/*
conn.createStatement().execute("CREATE TABLE people (" + "id int(64) NOT NULL AUTO_INCREMENT," + "name varchar(255) NOT NULL," + "address varchar(255) NOT NULL," + "UNIQUE (id)," + "FULLTEXT(name, address))");

[code]....

I downloaded Connector/J in the the binary .zip form and extracted it to my C: drive and put the .jar file into my java directories lib folder. I also added the directory of the .jar file into my CLASSPATH and I still get the exception.

View Replies View Related

How To Turn If Statement Into A Case / Switch Statement

Jun 19, 2014

So from what iv learnt in Java and programming in general is that using a case statement is far more efficient that using multiple IF statements. I have an multiple IF statements contained within a method of my program, and would like to instead use a case statement.

public String checkPasswordStrength(String passw) {
int strengthCount=0;
String strengthWord = "";
String[] partialRegexChecks = { ".*[a-z]+.*", // lower
".*[A-Z]+.*", // upper
".*[d]+.*", // digits
".*[@#$%!]+.*" // symbols

[code].....

View Replies View Related

How To Turn Image Into Tiled Image

Nov 21, 2014

I'm trying to make a method that takes an image and turns it into a tile image. So if the original image looks like this:

[URL] ....

then the output image should look like this:

[URL] ....

Here's a method that's supposed to do that but for some reason the output image looks the same as the original:

public static int[][] tile(int[][] arr){
int[][] tile = new int[arr.length][arr[0].length];
for (int i = 0; i < arr.length; i++) {
 tile[i]=arr[i];
}
return tile;
}

I recently changed the method and the error message I'm getting is "bad operand types for binary operator '+'. Here's the method:

public static int[][] tile(int[][] arr){
int[][] tile = new int[arr.length][arr[0].length];
for (int i = 0; i < arr.length; i++) {
for(int j=0; j<arr[i].length;j++){
tile[j]=(tile[j])+(arr[i]);
}
}
return tile;
}

View Replies View Related

Swing/AWT/SWT :: Java GUI With Thumbnails

Feb 2, 2014

I am programming a project where i am supposed to make addition, subtraction, division and multiplication which i can do. I need making a GUI with pictures and thumbnails of other pictures below.

View Replies View Related

Emulator Using Java Swing

Apr 22, 2014

I desired to produce a GUI in Java swing which should be look like mobile phone, as rendered under. test.jpg...So now the user should press the buttons and he can see the operation on the given phone screen, like if user press button "1" then it should display on the screen.

public class SimulatorPanel extends JPanel
{
public static BufferedImage image;
public SimulatorPanel ()
{
super();
try

[code]....

Basically, I wanted to develop a mobile simulator, but I having problem with GUI only. Or any open source simulator in Java?

View Replies View Related

Swing/AWT/SWT :: Simple Java GUI

Feb 4, 2015

I'm just starting to learn Java GUI. I'm trying to make a simple GUI that will update dynamically but having trouble ending the loop correctly.The Currently I've got the GUI updating and stopping, but the Test class method loop does not terminate correctly, it continues to count.

import java.awt.*; // Using AWT container and component classes
import java.awt.event.*; // Using AWT event classes and listener interfaces
import java.util.Timer;
import java.util.TimerTask;

[code]....

View Replies View Related

Java Swing AddMouseListener

Jan 23, 2015

I am trying to get my MouseListener to change the foreground and background on hovering over and once the menu is clicked, unfortunately only mouseEntered & mouseExit works but once I click on the menu I loose the selected colours so I am trying to use mousePressed but it does not have any affect.

mnuFile.addMouseListener(new MouseAdapter() {
public void mouseEntered(MouseEvent evt) {
mnuFile.setForeground(Properties.ORANGE);
mnuFile.setBackground(Properties.BLACK);
}
public void mouseExited(MouseEvent evt) {
mnuFile.setForeground(Properties.WHITE);
mnuFile.setBackground(Properties.BLACK);

[code]....

View Replies View Related

Java Swing GUI Button

Sep 19, 2014

How to save in array or arraylist when i click the jbutton

View Replies View Related







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