JMenuBar Not Showing

Mar 22, 2014

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class C1 extends JFrame
{
public C1() {
JMenuBar b = new JMenuBar();
b.setBackground(Color.green);
setJMenuBar(b);
setVisible(true);
}
public static void main(String[] args) {
C1 c = new C1();
}
}

Why? I tried everything I googled.

View Replies


ADVERTISEMENT

Swing/AWT/SWT :: How To Add JMenuBar

Jan 16, 2015

I am trying to add a JMenuBar to this program with just one dropdown to select one option but I am getting an error with the setJMenuBar(menuBar); line as it does not extend JFram. How I would add a menu to this program another way.

public class Calculator extends JPanel implements ActionListener{
private static final long serialVersionUID = 1L;
JMenuBar menuBar = new JMenuBar();
JMenu noteMenu = new JMenu("Note");
JMenuItem newNote = new JMenuItem("New Note");
public static final int WIDTH = 350;
public static final int HEIGHT = 560;

[Code] ....

View Replies View Related

Swing/AWT/SWT :: Calling Method Does Not Work From JMenuBar

Nov 6, 2014

I have a paint program in Java where I can draw objects. The objects are stored in an arrayList. In the menubar the user can chooce "Back", which means the last item in the arrayList is removed. After that I want the program to loop through the arrayList and draw the remaining items.

My problem is that when I try to do that it will not work from the menu (menuItem2). If I instead add the code to one of the colorpanels (yellowPanel), from where the user can pick colors, it works fine.

menuItem2 uses ActionListener and yellowPanel uses MouseListener.
public class PaintProgram extends JFrame implements ActionListener {

public ArrayList<Draw> shapeList = new ArrayList<>();
int startX, startY, endX, endY, w, h;
private JPanel topPanel;
private JPanel bottomPanel;
private JPanel magentaPanel;
private JPanel greenPanel;
private JPanel bluePanel;
private JPanel blackPanel;

[code]....

View Replies View Related

Swing/AWT/SWT :: JMenuBar Object Not Visible In JFrame

Nov 13, 2014

I' currently wrking on BeatBox application from Head First Java. I made a jpanel the pane of the frame & when i try to add a JMenuBar object to that it is not getting displayed when i run the code. When i add a menuBar directly to the JFrame object it is visible & working fine but not incase when added to JPanel.

package com.java.BeatBoxGUI;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;

[Code] .....

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

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

JSF :: MySQL Data Not Showing?

Apr 18, 2014

I'm trying to show mysql data in JSF using this example [URL] .... . I figured out what <h:dataTable value="#{userBean.getUserList()}" var="u" border="1"> must be <h:dataTable value="#{userBean.userList}" var="u" border="1"> but getting error:

09:08:38,654 ERROR [stderr] (http--127.0.0.1-8080-1) at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:307)

09:08:38,654 ERROR [stderr] (http--127.0.0.1-8080-1) at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:101)

[code]...

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

Output Of Code Showing Different Value?

Jan 13, 2014

I have one code [taking from on line SCJP exam preparation site]. I have 2 question in my mind:

1) addValue() is non static method then why it is running without object inside constructor. By this rule it should show compilation error.
2) With ref variable of parent always non overridden methods of parent run then it must value of 10 [If i forgot 1st point ]

But it is giving 40. Code is as below:

class Base{
int value = 0;
Base(){
addValue();
}
void addValue(){
value += 10;

[Code] .....

View Replies View Related

Showing Min And Max Value Of Float Integer?

Feb 20, 2014

How do I write a program that shows the max and the min value of a float integer? like for example in order to get the max value of a long integer we type System.out.println(Integer.MAX_VALUE); How would I do that for a float integer?

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

Button Not Showing On Panel?

Jan 27, 2014

I have three classes.. 1. panel class 2. frame class and 3. tester class...I am creating the objects like so but when I add button to panel then panel to frame I am not seeing the button. here is my code

import javax.swing.JButton;
import javax.swing.JPanel;
public class Panel extends JPanel{
private JPanel p;
private JButton b;

[code]....

View Replies View Related

Why Images In Applet Not Showing

Aug 30, 2014

So I am trying to make this java applet that will display a random image of three that is a sub folder of my src folder within my project.

When you run the project currently all you get is a white applet. Here is the code:

import java.applet.Applet;
import java. awt.*;
 public class myPictures extends Applet {
Image action;
public void paint(Graphics g){
int rint = (int)(Math.random() * 3);
if(rint == 0){
action = getImage(getDocumentBase(), "../../images/bee3.jpg");
} else if(rint == 1){
action = getImage(getDocumentBase(), "../../images/bee1.jpg");
} else {
action = getImage(getDocumentBase(), "../../images/bee2.jpg");
} } }

View Replies View Related

Progress Monitor Not Showing

Mar 27, 2014

I thought that simply constructing a progressmonitor would show the dialog, and wrote the following code.

[Code] ....

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

[Code] ....

But apparently i was wrong and all i get is an empty JFrame and no Dialog. I even added my own subclass of SwingWorker in case a SwingWorker had to be created in order for a progress monitor to exist. How can I make it show?

View Replies View Related

Showing Error In Concatenate

Oct 1, 2014

class connection {
public static void main (String[] args ) {
  String a=   "jdbc:oracle:thin:@//erp.oracle.com:1521/orcl" + ","+ "apps" + "," + "apps";
   System.out.println(a);
   System.out.println(coninfo());

[Code] ....

View Replies View Related

Errors On Compiling But Not Showing In Eclipse?

May 6, 2015

I am watching BrandonioProductions on youtube. His videos are pretty good, but he doesn't seem to get errors where I get them. Here is an example.

public class compareUnequal {
public static void main(String[] args){
compareTwo();
}
public static void compareTwo(){
String x = "david";
String y = "Notdavid";
if (!x.equals(y)){
System.out.println("Not equal");
}
}
}

It runs ok, but asked me to proceed when there is an error, but I can`t figure out where the error is!

View Replies View Related

Data From Database Is Not Showing On Combobox

Sep 17, 2014

Whats wrong with my code? The data from my database is not showing on my combo box.. I am trying to get my data in my database to my combo box ..

Here is my Code :

private void Fillcombo(){
Connection con = null;
String url = "jdbc:mysql://localhost:3306/";
String db = "purchasedb";
String driver = "com.mysql.jdbc.Driver";
String user = "root";

[Code] ....

View Replies View Related

Create JDialog Showing Database?

Jan 30, 2015

We are asked to create a JDialog showing our database. I am able to show the database but i can't seem to position the heading panel, table and back button. My back button is also not showing up. Here is part of my code...

import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.sql.*;
import javax.swing.*;

[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

Output Showing 0 For Array Elements

Oct 27, 2014

This is my code for the driver class:

import java.util.*;
public class SavingsAccountDriver {
public static void main(String[] args) {
System.out.printf("%10s%10s%10s%10s%10s" , "Month" , "Account #" , "Balance" ,
"Account #" , "Balance");

[Code] .....

Here is the output I get :

Month Account # Balance Account # Balance
----- --------- ------- --------- -------
0 10002 2000.00 10003 3000.00
1 10002 2002.00 10003 0.00
2 10002 2004.00 10003 0.00
3 10002 2006.01 10003 3030.00
4 10002 2008.01 10003 0.00
5 10002 2010.02 10003 0.00
6 10002 2012.03 10003 3060.30
7 10002 2014.04 10003 0.00
8 10002 2016.06 10003 0.00
9 10002 2018.07 10003 3090.90
10 10002 2020.09 10003 0.00
11 10002 2022.11 10003 0.00
12 10002 2024.13 10003 3121.81

Why is it not showing those months updated balance? I feel like I'm pretty close. I guess I should specify that this is supposed to calculate monthly interest for one account and quarterly interest for the other. This is what the output should look like.

Month Account # Balance Account # Balance
----- --------- ------- --------- -------
0 10002 2000.00 10003 3000.00
1 10002 2002.00 10003 3000.00
2 10002 2004.00 10003 3000.00
3 10002 2006.00 10003 3030.00
4 10002 2008.01 10003 3030.00

... ... 12 ... ...

The quarterly interest is the one that is giving me trouble.

View Replies View Related

Table Showing Different Values For Converting Kg To Lbs

Feb 19, 2014

I had to make a table showing different values for converting kg to lbs and I'm confused because when it compiles, some of the decimals show correctly and some of them show with several 0's added on with another number on the end. I've tried to do math.random, but I'm not sure how to tie it in with my program.

//1 kg = 2.2 lbs
public class kg_to_lbs {
public static void main(String[] args) {
//not sure if values are needed..
int kg = 1;
double lbs = 2.20;  
//Table title

[Code]...

and this is some of the results I get

1 | 2.2
2 | 4.4
3 | 6.6000000000000005
4 | 8.8
5 | 11.0
6 | 13.200000000000001

View Replies View Related

Boggle Board Is Not Showing Up When Run The Program?

Jan 18, 2015

I'm making a Boggle game, but the issue here is that the boggle board is not showing up when i run the program.

Here is the code:

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
public class Boggle {
public static void main(String[] args) {

[code]....

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 :: 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 View Related

Print All Values In A Format Showing Their Key

Jun 14, 2014

Java Code:

public static void main(String[] args) {
HashMap<Integer, String> stuff = new HashMap<>();
stuff.put(1, "Book");
stuff.put(2, "Pancake");
stuff.put(3, "Waffle");

for(Map.Entry thing : stuff.entrySet())
System.out.println(thing.getKey() + ": " + thing.getValue());
} mh_sh_highlight_all('java');

So I make a HashMap which is pretty simple. My book showed me how I would print all the values in a format showing their key a ": " and the the actual value. What I don't understand is why the type element for the for each loop is the interface, Map.Entry.

View Replies View Related

JSF :: Not Showing Up Beans Attributes In XHTML

Jan 29, 2015

My code of start.xhtml is:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core">

[Code] .....

when I deploy the app(glassfish) I get this message only:
hi #{user.minimum} a #{user.maximum} .

Instead of a picture: wave.med.gif and message:
hi 0 a 10 .

file hierarchy is attached

View Replies View Related







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