Swing/AWT/SWT :: Buttons Not Showing On JFrame

Aug 30, 2014

This is right from a book I'm reading but it doesn't work. The problem is to write an application that lets you determine the integer value returned by the InputEvent method getModifiers() when you click your left, right, or middle mouse button on a JFrame.

This is the code copied directly from the book. What is missing:

import java.awt.event.InputEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JFrame;
public class JLeftOrRight {

[Code] ......

View Replies


ADVERTISEMENT

JPanel Buttons Not Showing Up?

Feb 21, 2015

In my if statement on line 46 & 47 im trying to add the buttons to the screen if the player has lost and the "game over" screen have popped up. But the buttons aren't showing... what am i doing wrong?

import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;

[code]...

View Replies View Related

JSP :: Selectively Showing And Hiding Buttons?

Sep 26, 2014

I am thinking of creating a quiz application and facing one problem.

On first question I don`t have to show previous button and on last question I don`t have to show next button.And for in between question I have to show both the buttons.
.
How can I do that in a JSP page.

View Replies View Related

Rectangle Isn't Showing Up In JFrame

Nov 14, 2014

MyGraphics worked before I added a background but, even now when I take the background away it isn't showing up.

package com.snow.game;
import javax.swing.*;
import java.awt.*;
class MyGraphics extends JComponent { //creating a class for graphics
public void draw(Graphics g){
//calling Graphics making a new graphics (g) now you can use it to make objects
g.drawRect(10, 10, 50, 50); //Draws a rectangle

[Code] ......

View Replies View Related

JPanel Not Showing Up In JFrame

Apr 5, 2014

I'm attempting to add a Jpanel in a JFrame but it isn't working out.

import javax.swing.JFrame;
import javax.swing.JPanel;
public class stepone {
public static void main (String[]args){
JFrame frame = new JFrame("CSC LAB 12");
JPanel colorJPanel = new JPanel();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

[code]....

View Replies View Related

Why JFrame Not Showing Components Such As JComboBoxes

Sep 4, 2014

my JFrame is not showing anything, (Perhaps test it in your own IDE on your own PCs/laptop)

// Project: RestaurantBillCalculator.java Calculates a table's bill.
 
// Import statements for different classes
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JComboBox;

[code]....

View Replies View Related

JFrame That Contain 2 Buttons And A Graphic

Apr 25, 2014

I want a java program

Program must be jframe that contain 2 buttons and a graphic.

Graphic is any thing car or human or any thing and by changing x-axis of of the graphic it will be as if it walk from place to another.

We must use the function timer that change the x-axis after defined time.

The two buttons are one for stop walking and another for resume.

View Replies View Related

Swing/AWT/SWT :: Showing Dotted Line

Jul 7, 2014

Is it possible for a rectangle with dotted side be shown when dragging the mouse on a component?Just something like the one in the attachments, usually occurs in some graphics/pictures software.

View Replies View Related

Swing/AWT/SWT :: DeckPanel Are Not Showing Up When Run Program

Mar 25, 2014

My deckPanel's etc. are not showing up when I run my program. What am I missing in my orderCalc class or maybe from my deckPanel class?

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class OrderCalc extends JFrame

[code]...

View Replies View Related

Swing/AWT/SWT :: New Set Of Buttons

May 22, 2014

So I have a Jframe that has a set of functions that act on a node. What I want to do is allow the user to expand the gui by creating new sets (copies) of these functions when they have more nodes.I thought of hiding extra sets and making it appear they are adding them by making them visible.

View Replies View Related

Swing/AWT/SWT :: Java Frame Is Showing Blank?

Jul 5, 2014

i have problem with the following two java classes, driver class Reservations and Room class. When i run, it just show blank frame, tell me where i gone wrong.

import javax.swing.JOptionPane;
import java.awt.*;
import java.awt.event.*;
public class Reservations extends Frame implements ActionListener {
Color lightRed=new Color(255,90,90);
Color lightGreen=new Color(140,215,40);
Rooms room=new Rooms(5,3);

[code]...

View Replies View Related

Swing/AWT/SWT :: Panel Not Showing Added Components

Apr 27, 2014

My panel named panelIncomeInfo are not showing the components that I have added.

public class PayrollGUI {
private JPanel panelIncomeInfo = new JPanel ();
private JPanel panel = new JPanel ();
private JPanel panelPayCheckInfo = new JPanel ();
private JButton close = new JButton ("Close");

[Code] .....

View Replies View Related

Swing - Adding Second Row Of Buttons

Nov 27, 2014

I am new to swing and I wanted to know how to be able to make a second row of buttons. Right now I have a text pane at the top and at the bottom one row of buttons. But I need to add another row or two of buttons. I've only been coding in Java.

public class TextPane {
public static void main(String[] args) throws IOException
{
/////////////
//I/O FILES//
/////////////
//Create the input file
FileWriter inputFile = new FileWriter("userInputStory.txt");//story user creates with the <nouns>, <verbs>, etc
PrintWriter inputFileWriter = new PrintWriter(inputFile);

[Code] .....

View Replies View Related

Swing/AWT/SWT :: JCheckBox Background Color Not Showing Up In Nimbus

Jul 17, 2014

I'm displaying a table with several read-only pieces of data, and a checkbox field that toggles the row color. The background color for the checkbox is not toggling correctly. I put together a SSCCE:

import java.awt.Color;
import java.awt.Component;
import java.util.ArrayList;
import java.util.List;

[code]....

If I comment out the Nimbus look and feel, it works as expected. I googled this problem and found one possible solution on Stack Overflow. Their suggestion is:It's a bug in the synth-installed renderer, quick hack is to force the rendering checkbox opacity to true: ((JComponent) table. get Default Renderer(Boolean.class)).setOpaque(true);

I tried using this line and setting the opacity to true, but it renders the background white. I'm using Java 1.7.0_25.

View Replies View Related

Swing - Binary Game With Six Buttons

Jun 13, 2014

I am trying to build a binary game. I have six buttons. What I need to do is when I click on each button, the number needs to be changed from 0 to 1 and from 1 to 0 back again. However, I cannot do it wiht the below code. In addition, I would like to buttons on the GUI to be laid horizontally as well.

public class BinaryGame extends JFrame implements ActionListener
{
private JFrame binaryGameFrame;
private JLabel StartLabel;
private JPanel controlPanel;
private JFrame guiBinaryGameFrame;
private Object firstButton;
private int numClicks=0;

[Code] ....

View Replies View Related

Swing/AWT/SWT :: Test Orders Not Showing Up In JTextArea Instead Printing To Console

Jan 8, 2015

I have small problem in GUI. I have a text area which has to display my test orders now what is happening instead of the text showing up in the JtextArea its still printing to the console so this order code (yes i did not use proper code standers) runs though my order class fine but its not loading the text in the JtextArea

Order code

public static String testCase1(){
orders ords = new orders();
System.out.println("Test Case 1: " + "
" + ords.getOrderDetails());
return " ";

My jbutton code :

txtContent.setText(new orderTester().testCase1());
txtContent.setText(new orderTester().testCase2());
txtContent.setText(new orderTester().testCase3());

I have 10 test case to load in the jTextArea

View Replies View Related

Swing/AWT/SWT :: Add Radio Buttons To ButtonGroup Dynamically?

Dec 5, 2014

I am using a HashMap to store names (keys) and IDs (values). I have set it up so that the radio buttons are added to the JPanel dynamically. That is, each time a name/id is added, a new radio button is automatically generated and added to the panel. Here is a snippet of the code I have thus far:

private void employeeButtons() {
buttonPanel = new JPanel();
buttonPanel.setLayout(new GridLayout(5,2,5,5));
empMap.put("Kyle", "1090");
empMap.put("Alex", "6490");
empMap.put("Mark", "9090");
empMap.put("Anne", "4390");

[code]...

The above code adds all of the radio buttons to the panel just fine. However, I need the buttons to be mutually exclusive. I would like to be able to not only add the buttons dynamically, but I need the buttons to be added to a ButtonGroup dynamically as well. That is, when I add a new hashmap entry the a new radio button is generated and added to the radiobutton group.

View Replies View Related

Swing/AWT/SWT :: Buttons Not Displaying Till Mouseover Them?

Jan 19, 2012

I set out to make a Tic-tac-toe (Cross and Noughts) game to test my learning so far. While things have gone pretty well so far, I am absolutely stumped by my current issue. When I compile and run the code, the Grid of buttons that I generate do not appear. However, if I mouse over the window, they seem to then get refreshed/repainted. I cannot for the life of me figure out why this is happening. From Googling the issue, it seems this is either an issue with the layout manager or related to a thread conflict with the GUI? [URL] ....

I'm listing out the code for the game class and the button class.

import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
import java.util.*;
public class CrossNoughtsGame {
private JFrame frame;
private JPanel mainPanel;
private ArrayList<CNButton> buttonList = new ArrayList<CNButton>();
private boolean isX = true;

[Code] ....

View Replies View Related

Swing/AWT/SWT :: Option Buttons Goes Into SelectionValues Argument

Dec 12, 2014

public static void main(String[] args) {
String[] images = new String[5];
images[0] = "B.png";
images[1] = "M.png";
images[2] = "H.png";
images[3] = "D.png";
images[4] = "S.png";

[code]....

There is my code so far, on the line JOptionPane.showInputDialog(null, "Give us a word starting with "+text[i]+":", "tut", 2, image, ?, null);, eclipse gave me 2 extra arguments following the icon and I'm not sure what exactly goes into the 2nd to last, the "selectionValues" argument.

After checking the Java docs, it was apparent that the option buttons goes into the selectionValues argument, but is there a way to work past that if I would only like the default (OK, Cancel) buttons on my window? The school haven't taught us the method to create custom buttons and I doubt I would've been set something that was not taught.

View Replies View Related

Get Background Image Showing Other Two Are Not Showing On Screen

Jan 20, 2015

public void paint(Graphics g) {
g.drawImage(Background, bg1.getbX(), bg1.getbY(), this);
for(int i=0;i==400;i+=10){
g.drawImage(block1,fg1.getBlockX(),fg1.getBlockY(),this);
g.drawImage(block2,fg1.getBlockX(),fg1.getBlockY()+10,this);
}
}

This is what im dealing with right now. When i click run i only get the background image showing the other two are not showing on the screen.

View Replies View Related

Swing/AWT/SWT :: Add Buttons Dynamically In A New Jpanel On Click Of A Button

Jun 20, 2014

Am trying to add buttons dynamically in a new Jpanel on click of a button. i am getting new Jpanel but not able to see the buttons.

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());
CardLayout cardLayout=(CardLayout)(frmUno.getContentPane().getLayout());

[Code]...

prepareHandsForGuiCode is

public UNODeckMain prepareHandsForGui(UNODeckMain unoDeckMain){
JButton[] btnArr =new JButton[50];
for(int i=0;i<50;i++){
btnArr[i]=new JButton("hi");
panel_player1.add(btnArr[i]);
}return unoDeckMain; }

Am i skipping something ?

View Replies View Related

Swing/AWT/SWT :: Select 2 Buttons In A Radio Button Group?

Mar 16, 2014

How do you make it so that you can select 2 buttons in a radio button group? for example: If I have 7 radio buttons, and I want to be able to select 2 of the 7 instead of 1.

View Replies View Related

Swing/AWT/SWT :: JSpinner - Adding Listener To Arrow Buttons

Jan 25, 2007

I need to change the value only when I press one of the arrows in a JSpinner component.How can I add a listener to the arrow buttons. I tried ChangeListener but it was not what I needed

View Replies View Related

Swing/AWT/SWT :: Providing Focus To Keyboard Buttons On JInternalFrame

Dec 5, 2014

I'm having issues with providing focus to keyboard buttons when a JInternalFrame with keyboard buttons is called in my program. So for example when the program is started the attachment called signinscn.png is called.

This screen is a JDesktopPane which calls JPanel for its components.

From here a JInternalFrame containing the buttons ESC and F1 to F4 as seen in the attachment called signinscn.png is called.

I would like the buttons in my JInternalFrame to have focus such that when a user engages the equivalent keyboard button i.e. ESC or F1 to F4 WITHOUT clicking on the JInternalFrame the respective button's action listener kicks in. At the moment only after the user clicks on the JInternalFrame do the equivalent keyboard buttons respond.

Here's the constructor of my JInternalFrame and you can see how I handle the ESC keyboard button in the constructor of the JInternalFrame (but as I mentioned only after the user has engaged the JInternalFrame):

//!<
public AdminHomeJIFrame() {
super(null, false, // Resizable
false, // Closable
false, // Maximizable
false); // Iconifiable

BasicInternalFrameTitlePane titlePane =
(BasicInternalFrameTitlePane)((BasicInternalFrameUI)this.getUI()).getNorthPane();

[Code] ....

View Replies View Related

Swing/AWT/SWT :: Add A Rectangle To JFrame?

Apr 13, 2014

Is there a way to simply slap a rectangle into a JPanel (make it appear) with out creating an inner Class or helper Method, all within "Main"? And if not, why?

Making a JFrame is easy.

Adding a JPanel is a snap.

import java.awt.Color;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class TheJFrame {
public static void main(String[] args) {
// TODO Auto-generated method stub

[code]....

View Replies View Related

Swing/AWT/SWT :: JPanel Inside A Jframe?

Apr 9, 2014

I have a Jframe and i want to add inside 4 different jpanel.This is easy.

what is difficult is how can i change them dynamically with 4 other new jpanels and 4 other new jpanels?

I have try with BorderLayout but not working.

It's a wizard like but not the same.

I have a jpanel with jbuttons jpanel with a jtable jpanel with textarea and jpanel with jlabels. All this have to change with other 4 jpanels, where to look?

View Replies View Related







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