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


ADVERTISEMENT

JFrame Not Responding To Dispose Function

Jun 13, 2014

I am trying to code a program which pops up a file chooser window or dialog box to select a file first, if the user clicks 'cancel' or closes the window then the parent JFrame would not show up.

Java Code:

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFileChooser;
import javax.swing.UnsupportedLookAndFeelException;
public final class base extends javax.swing.JFrame {

[Code] .....

The problem is that the JFrame shows up even if I click cancel in the file chooser. I am using Netbeans.

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

Drawing A Square In Quadrant I Grid - Axis Not Display Properly

Feb 3, 2015

Currently, I am trying to create a program that draws a square anywhere in a 15x15 Quadrant I (Coordinate plane) grid. I am stuck on trying to get the axes displaying correctly. This is the code I have thus far:

import java.util.Scanner;
public class Question2square {
public static void main(String[] args) {
// Axis variables
int yAxismin = 0;
int yAxismax = 15;

[Code] ....

Unfortunately, instead of drawing the 'L' shaped axes I desire, it displays an 'r' shape instead. I'm trying to figure out how to display the axis properly. I tried flipping the for loops but that didn't work. I don't see what else could be inhibiting this.

View Replies View Related

Rectangle Won't Display In JFrame

Jan 30, 2014

So I've been getting back into Java and downloaded eclipse back onto my laptop. However when I go to make a simple rectangle into a JFrame, the frame will pop up but no rectangle will be shown. Here is my main class, which sets up the JFrame...

mport javax.swing.JFrame;
public class Frame{
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.setTitle("I hope this fucking works");
frame.setSize(400,400);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

[code]....

View Replies View Related

How To Get Image To Display On JFrame

Nov 13, 2014

I have been trying to make a game lately, but I can't seem to work out how to get an image to display on my JFrame. I have tried everything, copied different codes of the internet, but nothing works. Here is my code of the GUI:

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class GUI extends JFrame implements Runnable, ActionListener {
JButton start = new JButton("Start nieuw spel");
JButton instellingen = new JButton("Instellingen");
public GUI() {

[Code]...

View Replies View Related

Swing - Display Image On JFrame?

Jan 16, 2014

How to display an image on a JFrame. If you can, pany example code.

View Replies View Related

Integer Values To Display In JFrame - RegEx Not Being Recognized

Jan 27, 2014

I have a program in which I am prompting users for integer values to display in a JFrame. I call the method below to load an array with their input:

Java Code:

public String inputAssembly(){
if (!jtfInput.getText().matches("d")){
JOptionPane.showMessageDialog(null, "Input must be of integer value.");
} if (jrbFar.isSelected()){
return jtfInput.getText() + jrbFar.getText();

[Code] ....

Regardless of the input, both messages display (invalid input / got it). I've tried debugging so I know that the values are getting entered and read correct, at least to my knowledge. It is a very simple regular expression, only checking to be sure an integer was entered.

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

How To Dispose Off Native Components

Jan 7, 2014

Currently I get errors when trying to exit my JFrame without playing the youtube video I have set it to load.

My Code:

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;
import chrriis.dj.nativeswing.swtimpl.NativeInterface;

[Code] ....

If it's relevant the error:
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at java.io.BufferedInputStream.fill(Unknown Source)

[Code] .....

View Replies View Related

Possible To Dispose Internal Frame

Nov 20, 2014

Is it possible to dispose(); an internal frame and keep my main JFrame open.

View Replies View Related

Swing/AWT/SWT :: How To Release / Dispose A Form

Apr 9, 2014

I have this code:

RegistraFolios dg = new RegistraFolios();
dg.dispose();
dg.setUndecorated(true);
dg.setLocationRelativeTo(null);
dg.setVisible(true);
JOptionPane.showInputDialog(dg);

in last line i show the form in modal mode.

how to free? i try this:

private void btnCloseActionPerformed(java.awt.event.ActionEvent evt) {
this.dispose();
}

but not work.

View Replies View Related

Dispose Of Containers Ifs And Elses Using Polymorphism

May 31, 2014

I would eliminate the ifs and elses using polymorphisms that solves this lot of ifs? How could I solve this?

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

How To Attach External Files To Executable Jar Or Exe Files

Apr 13, 2015

In a program I created, I'm using a text file that contains some texts needed for the program. The method relevant to this is something like the following.

private String wordgen(){
try {
BufferedReader reader = new BufferedReader(new FileReader("src/Resources/adjectives.txt"));
Random rand = new Random();
int low = rand.nextInt(400);
String fil="";
int i=0;
while(i!=low){

[Code]...

The program runs fine in netbeans project but once the jar is created it does not corporate with the text file. ("null" is returned) How can I attach text files to jar and exe?

View Replies View Related

Swing/AWT/SWT :: Have JDialog Dispose When Focus Is Lost?

Jan 21, 2014

This code will not dismiss the MemoryDateDialog when it loses focus, while it is what it is intended to do.

btnMemoryReason.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
List<MemoryDates> lMemoryDates = db.getMemoryDates(custID);
final MemoryDateDialog mdd = new MemoryDateDialog(lMemoryDates);

[URL] .....

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

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

Constructor Jframe In Class Jframe Not Be Applied To Types

Jun 22, 2014

So I have this line of code...

ioexception11.addChoosableFileFilter(new Jframe());

And when I compile it gives me...

error: constructor Jframe in class Jframe cannot be applied to given types;
ioexception11.addChoosableFileFilter(new Jframe());

View Replies View Related

Interface Not Updating Properly

Mar 20, 2015

The program runs well , it adds the applet but it dosn't update the interface unless I press "_"(Minimize) . To be more clear , the object paints a spring wich goes through 4 stages , it is added to the JFrame but it dosn't uptade until I minimize the frame , that is when it goes to the next stage .

The main class which calls the spring to be added to the frame :

public class principal implements ActionListener ,Runnable{
JTextField field;
JFrame frame;
private class Action implements ActionListener {
public void actionPerformed(ActionEvent event) {
  frame.repaint();

[Code] .....

View Replies View Related

Swing UI Not Responding Properly?

Nov 27, 2014

Here's the code to my UI and it runs but output doesnot shows properly..

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;
import java.util.*;
import java.io.*;
public class LoginPage extends JFrame{
JLabel lblLoginAs;

[code]....

and when I hover over the Login Button its border gets distorted..

View Replies View Related

Images Not Displaying Properly

Nov 16, 2014

My code:

import javax.imageio.ImageIO;
import javax.swing.*;
import java.io.*;
import java.awt.*;
import java.lang.*;
import java.awt.image.*;
import java.net.URLDecoder;

[Code] .....

I my images (including the one I created) are all 32x32. I'm trying to get a player Icon and have them be on a field of grass. Currently, I just get:

(see Attached)

I don't know where my Images are rendering.

B = blank
. = grass
p = player

.
.
.
.
. p
.
.
b

View Replies View Related

OnItemLongClickListener Not Working Properly

Apr 19, 2014

I created a dialog file:

Java Code:

package com.example.classorganizer;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

[code]...

When I long click item in the list nothing happens. I get no errors at all and I believe that either I put the code in the wrong place or I missed something else that stops Dialog from starting.

View Replies View Related

Using HasNext Properly In Program

Apr 16, 2015

Why do I get an error on the hasNext line when I try to compile this?

public static void main(String args[]) throws Exception
{
BufferedReader infile = new BufferedReader(new FileReader( "woodchuck.txt" ));
HashMap<String, Integer> histoMap = new HashMap<String,Integer>();
String word;
while((infile.hasNext()) !=null) {
if(histoMap.get(word)==null)
histoMap.put(word,1);
else
histoMap.put(word, histoMap.get(word)+1);
}
infile.close();
System.out.print(histoMap);

View Replies View Related

Array Will Not Fill Properly

Dec 8, 2014

my validAccounts array will not fill properly and has a null value in it.I added a print statement that prints the contents of the array and it is filling correctly but the very last value is null. I am supposed to be asking the user for a account number and password and it is not printing out correctly due to the fact that the array is not filled correctly.

import java.util.*;
import java.io.*;
public class ATM2 {
public static Scanner kbd;
public static final int MAXSIZE = 50002;

[code]....

View Replies View Related







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