Displaying JTextField In Fullscreen Exclusive Mode Without Flickering
Mar 2, 2014
I have been stuck on this now for almost a week, the problem is that the textfield keeps flickering. I have read that swing does not work well with fullscreen exclusive mode, but I'm not sure what else to do other than create my own class similar to a textfield and detect every single key press which doesn't seem the right thing to do.
- If this line is uncommented "TextFieldTest.this.tfChatField.paint(g);" then it will display the textfield at the top of the screen, and a flickering textfield at the bottom(which is where it's meant to be)
Java Code:
package textfieldtest;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.DisplayMode;
import java.awt.Graphics;
import java.awt.Graphics2D;
[Code] ....
View Replies
ADVERTISEMENT
Oct 21, 2014
I'm trying to get data from a GUI input window into an ArrayList and back out via a JTable. I can get the array lists to print to the console within the input class, but I need to wire it to a data container and out through a different class. Here is code from one input class, and its corresponding output class:
Input:
public class AddClassroom extends JFrame implements java.awt.event.ActionListener {
// UI components
// are declared here...
[code]....
View Replies
View Related
Dec 15, 2014
I am trying to create a JFrame where I have two radio buttons (choose one room or two rooms), but they need to be mutually exclusive. I know there is a lot missing from my code, but I'm trying to work through one issue at a time
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class JCottageFrame extends JFrame //implements ActionListener
{
final int ONE_ROOM = 600;
final int TWO_ROOMS = 850;
final int ROWBOAT = 60;
int price;
[code]....
I believe the errors are because I am trying to add the radio buttons to the button group and making them mutually exclusive, but I'm struggling to follow the textbook on how to properly do this. When I remove the two lines of code that are causing the errors, my code compiles and the JFrame shows correctly. The only issue is that it is allowing me to select "One room" and "Two rooms" at the same time.
View Replies
View Related
Mar 17, 2015
Have this game which is 1280 by 720 and i want it to be fullscreen.....but i dont just want the size of the frame to change i also want everything inside it to "stretch"..... So for example if i had a 100 by 100 frame with a 10 by 10 image in it, and i tried to stretch the frame to the users screen which is 200 by 200, the image inside the frame would also stretch to 20 by 20... How do i do that?.........
View Replies
View Related
Apr 12, 2015
I got this code with mode methods. The results is not exactly what I want.
Code:
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.*;
public class ProcessMarks {
private static final int NMARKS = 125;
[Code] ...
Result (it's repeat number):
*Mode is = 53
*Mode is = 53
*Mode is = 53
*Mode is = 53
*Mode is = 53
*Mode is = 62
*Mode is = 62
*Mode is = 62
*Mode is = 62
*Mode is = 62
*Mode is = 67
*Mode is = 67
*Mode is = 67
*Mode is = 67
*Mode is = 67
*Mode is = 77
*Mode is = 77
*Mode is = 77
*Mode is = 77
*Mode is = 77
*Mode is = 78
*Mode is = 78
*Mode is = 78
*Mode is = 78
*Mode is = 78
*Mode is = 85
*Mode is = 85
*Mode is = 85
*Mode is = 85
*Mode is = 85
Result that i want it to be (number appear only once):
*Mode = 53, 62, 67, 77, 78, 85
or
*Mode is = 53
*Mode is = 62
*Mode is = 67
*Mode is = 77
*Mode is = 78
*Mode is = 85
View Replies
View Related
Feb 2, 2014
I attempted to make my square move in the screen and i set up collision with another object, however the graphics are flickering, really flickering, here's the code:
Java Code:
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
public class NewEmpty extends JFrame {
double p1speed =5, p2speed =5;
[code]....
View Replies
View Related
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
Jun 12, 2014
The following code uses a column constraint to specify that a column of labels should extend horizontally in their cell but they don't as you can see by looking at their border. My mistake or a bug?
import javafx.application.Application;
import javafx.geometry.HPos;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.ColumnConstraints;
import javafx.scene.layout.GridPane;
[Code] ....
View Replies
View Related
Jan 12, 2011
I need to create a program that draws a graph, but for now, all I have done is two lines: the X and Y axis. The program is designed in a way as to automatically resize the graph when the window is resized.
Is this code in some way extremely inefficient? I get TERRIBLE flickering when I resize the window. Is there something that will at least reduce the flickering?
mainApp.java:
import java.awt.*;
import javax.swing.*;
public class mainApp {
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.setSize(300,300);
frame.setVisible(true);
[Code] ....
I have added a screenshot that shows the window flickering.
View Replies
View Related
Jul 28, 2014
I am trying to call another swing frame from my current frame. And after calling second frame i dispose the current frame.
But while second frame coming on the screen, current frame gets dispose and second frame takes some seconds to appear on screen.
So its creating a bad flickering effect on screen and its not suitable for my application.
I want that first frame will call sencond frame and it will not look like second frame is called. I just want to cancel flickering effect.
Here is my source code.
1st Frame:
public class Welcome extends JFrame {
JFrame f;
JTextArea nameField,nameField1;
JLabel lable;
[Code] .....
View Replies
View Related
Mar 12, 2014
i'm currently doing my system now and my problem is about inserting an image to my jframe form with thread because if i insert image and when i run it it blinks too slow comparing if i use simple oval it doesnt blink.
why is it that if i wrote the code like this.
public void DrawSnake(Graphics g) throws IOException {
Image image = ImageIO.read(this.getClass().getResource("body1.jpg"));
Image image1 = ImageIO.read(this.getClass().getResource("body.jpg"));
Image headr = ImageIO.read(this.getClass().getResource("headr.jpg"));
Image headl = ImageIO.read(this.getClass().getResource("headl.jpg"));
[Code] .....
View Replies
View Related
Aug 29, 2014
I'm trying to set up a splash screen where a native splash screen is shown initially and then replaced with the stage from my preloader. This is fairly simple to do. I use the below code to get everything lined up properly.
private void alignStage(Stage stage) {
SplashScreen splashScreen = SplashScreen.getSplashScreen();
if (splashScreen != null) {
// Align the stage based on the current splash location
Rectangle bounds = splashScreen.getBounds();
stage.setX(bounds.getX());
stage.setY(bounds.getY());
[Code] ....
The problem I'm having is that my Stage isn't actually shown by the time the commented event gets fired. The API for onShown says:
Called just after the Window is shown.
My guess is the window has transitioned to being shown, but there's a slight delay until it gets rendered on screen. If that's a decent assumption, is there a reliable way I can make sure my preloader stage is visible on screen before I hide the native splash?
The best option I can think of so far is to delay hiding the native splash until the preloader gets the BEFORE_START notification. This works (no flicker), but, since both splash screens are actually visible for a while, using a transparent splash doesn't work very well (which actually isn't too big of a deal).
View Replies
View Related
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
Mar 25, 2015
I have a supermarket checkout line where i have a list of available products on the left and then a basket on the right with the products in. The products are listed in an array, here is the product class
public class Product {
private String name;
private double weight;
private double price;
[Code] ....
with getters and setters excluded, and the list these are put into
public class productList extends DefaultListModel {
public productList (){
super();
}
public void addProduct (String name, double weight, double price, int code){
super.addElement(new Product(name, weight, price, code));
i have the price for each product to be displayed in a text field with the following code
addBasketItem = new JButton();
getContentPane().add(addBasketItem);
addBasketItem.setText("Add >");
[Code] ....
defaultCheckoutList contains my available items and defaultMainList is the basket, with mainTillPrice being the jtextfield.
This works to get the price however it just replaces each time i make a new entry with the price for the next item, i want a total of the price of all the items i have added, but not sure how.
View Replies
View Related
Apr 6, 2015
I enter a value in the text box in one class and want to pass that value to another class in order to compare it and color the cell in a table. In the first class I have
package cege.ui;
import cege.controller.HtmlController;
import cege.controller.ScreenCaptureController;
...
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
[Code] .....
How to pass the threshhold from the first to the second class?
View Replies
View Related
Feb 4, 2014
Will I'm tying in my code to set a default number for the JTextField that when the user decide not to put any numbers. Like let say that I want the textfield set to 0 , so then the user do not file it it won't make any problem to the program because its already has a default number.
if (stringGQ != null && stringGW != null && stringGP != null){
stringGQ = gMQ.getText();
stringGW = gMW.getText();
stringGP = gMP.getText();
weightPrice_1M = Double.parseDouble(stringGW) * Double.parseDouble(stringGP);
[Code] .....
Note: This is a small part of my code. when I leave it empty it take the 0 as a value, However, when I write in text field it also take the value of a 0 and the finalTotal is also = to 0.what I'm doing wrong.
View Replies
View Related
Jan 22, 2015
I am creating a slot machine using eclipse. I am trying to get the "winnings" JTextField to be updated in a way so that when the random images have been selected it adds to the number that is already displayed in the JTextField as opposed to what it is doing at the minute which is just displaying how much was won on that particular spin. I am also struggling to set a code for when noting is won, nothing is added. My code is below.
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import java.util.*;
import javax.swing.Timer;
[Code] ....
View Replies
View Related
Mar 4, 2015
how build a Google toolbar to search on web with java? I have this code but something is wrong...
View Replies
View Related
Jan 18, 2015
I currently building a hotel reservation system, and I'm having issues with retrieving and setting other values from a JTextField.
What I'm trying to do is to retrieve the value that was inputted into a textfield, and then setting that value to a string in another class.
In here, I'm trying to retrieve values from the JTextField:
@Override
public void actionPerformed(ActionEvent event) {
GuestInfo gi = new GuestInfo();
if (event.getSource()==roomView)
{
roomViewFrame.setVisible(true);
roomViewFrame.setSize(1000, 600);
[Code] .....
View Replies
View Related
Apr 26, 2014
designing a program which allows you to buy stuff from the jframe with 10x items each with different pricing, so once you click the image button the cost of that is displayed in the textfield, ive been trying to set the jtextfield to a decimal point but have not been able to so far,
if (source == jBSofa) {
System.out.println("Sofa");
{
dTotal = dTotal + 599.99;
jTotal.setText(Double.toString(dTotal));
DecimalFormat myFormatter = new DecimalFormat("#####.#");
String output = myFormatter.format(dTotal);
a visual aspect of it.
View Replies
View Related
Jun 29, 2014
How would I display certain output text if the text entered equaled "text".
So lets say you enter a question into a JTextField. You press a button that submits the text. The output displayed depends on what the question you asked was.
Think about it as "If question = What color is the sky? On submit, display text "Blue". How to implement this.
View Replies
View Related
Jan 6, 2015
i am new to GUI.i create a JTextField and a Button("ok").and i want to get the String of the text after i push the button.what did i do wrong?
JTextField theText=new JTextField("Type a new question here",40);
JButton addButton=new JButton("Add");
mainPanel.setLayout(new FlowLayout());
mainPanel.add(theText);
mainPanel.add(addButton);
mainPanel.add(showAllQuestionsLabel);
mainPanel.add(showAllQuestionsButton);
[code]....
View Replies
View Related
Apr 2, 2014
I have been reading several suggested solutions for implementing autocomplete for a JTextField. However, the documentation is a bit confusing to me. It seems like they mostly require switching to a JComboBox. Can I or can I not continue to use a JTextField and implement an autocomplete feature? I also saw what I thought was a built-in autocomplete "decorator" for swing objects (although it was not clear if it can be used for JTextField) but most of the implementations seem to start from scratch. Any simplest way to implement this (assuming those 2 conditions are not mutually exclusive)?
View Replies
View Related
Mar 9, 2014
I'm writing a java program in eclipse of a tic-tac-toe game. I have to create it using JTextField's only I'm having trouble where the JTextField will only accept one letter and will only accept X and O is there any particular way to do this I started off with this piece of code
String text=tf1.getText();
if(text.length()>1) {
System.out.println("this is not allowed");
tf1.setText("");
But it doesn't work so is there something I'm missing....
View Replies
View Related
Jun 20, 2014
I am trying to get the data entered in a JTextField into a JTable but not clear on how. The LeftPanel is where the button is located and the RightPanel is where the JTable is. I want the actionPerformed to update the row of the JTable but I can't figure out how. There is another class that controls the GUI but did not think it was necessary to include. Also, I am aware that I am getting an error at the addRow line, can't seem to alleviate it.
public class LeftPanel extends JPanel {
private static final long serialVersionUID = -2311952438693382407L;
private RightPanel rPanel;
public LeftPanel(){
Dimension size = getPreferredSize();
size.width = 250;
setPreferredSize(size);
[code]....
View Replies
View Related
Sep 13, 2014
I need to get users input from jtextfield and set it to JTable. This is my code:
public class Projektni extends JFrame {
public final JTextField ime = new JTextField(10);
public final JTextField prezime = new JTextField(10);
public final JTextField index = new JTextField(10);
public DefaultListModel podaci = new DefaultListModel();
JButton imeB=new JButton("Upisi u tabelu");
[Code] ....
View Replies
View Related