Swing/AWT/SWT :: GridbagLayout Gridy Not Working

May 4, 2014

I'm trying to make a simple window that displays 5 text fields on x number of rows, depending on what I set x to. Attempting to do this with GridBag Layout but I can't seem to get a new row started. The closest I can get is to repeat the same fields on the same row. I'm trying to modify the row by putting the code in a loop and setting gridy = i, that way each iteration should place the code lower than the first. I'm new with GridBagLayout so I'm probably missing something simple. The constructor with the loop is below. I've commented out code that doesn't seem to work but left the gridx and gridy.

public PAMCalculator()
{
setTitle("PAM Calculator");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(WIDTH, HEIGHT);
GridBagLayout gridbag = new GridBagLayout();
GridBagConstraints gridConstraints = new GridBagConstraints();
setLayout(gridbag);

[code]....

View Replies


ADVERTISEMENT

How To Use GridBagLayout And CardLayout Together

Jan 17, 2014

How do you use GridBagLayout and CardLayout together?

I'm trying to add these buttons to a panel, but it breaks the GridBagLayout, here's what is in the doc;

Java Code:
button = new JButton("Button 1");
c.fill = GridBagConstraints.HORIZONTAL;
c.gridx = 0;
c.gridy = 0;

[Code] .....

I'm trying to do:

Java Code:
JPanel m = new JPanel();
button = new JButton("Button 1");
c.fill = GridBagConstraints.HORIZONTAL;
c.gridx = 0;
c.gridy = 0;
m.add(button, c);

[Code] .....

However it reverts as though it's using flowlayout. What is it I'm missing?

View Replies View Related

Set Components To GridbagLayout

Jan 1, 2014

I decide to make a new GUI just for fun and practise and i want to learn more about Layouts.. right know i am try to understand some staff about GridBagLayout.

I want to make a GUI with this Layout :

So..first i am a frame with borderlayout then i put a JMenuBar and bla bla bla and i create panel with GridLayout which i put on myFrame.add(panel1,BorderLayout.WEST) and also i make an another JPanel which i put of the Center of main Frame (myFrame.add(panel2,BorderLayout.Center))

when i run the program i get this GUI :

Now the problem is that i can't put the JButton on the top of the gridLayout just to look like the first picture.. i Read about anchor and i try to

gbc.anchor = GridBagConstraints.NORTH; but without results.. still the components are on the middle of the JPanel..

Here is my Code () :

Java Code:

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;

[Code] .....

View Replies View Related

Displaying Textfeild With GridBagLayout / GridBagConstraints

Dec 28, 2014

I'm having some issues with displaying my textfeild with the GridBagLayout GridBagConstraints..here is my source code for my window:

package net.test.main;
 
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SpringLayout;
import java.awt.Insets;
import java.awt.BorderLayout;

[code]....

View Replies View Related

Swing/AWT/SWT :: Progress Bar Not Working?

Feb 14, 2014

I'm trying to get a progress bar to work on my GUI.

This is what I have so far, the parameters are taken from another class that takes in an image in packets from a Raspberry Pi and stores them to a file on PC.

public void ImageInfoReceivedHandler(int sizeOfFile) {
progressBar.setMinimum(0);
progressBar.setMaximum(sizeOfFile);
progressBar.setIndeterminate(false);

[Code] .....

The println are printing out the correct values and they are being implemented in the methods, but nothing is happening in the GUI.

I have a thread setup in the GUI when a button is pressed

getImageButton.setText("Timer Started");
transmit = new transferImage(port);
lblImgProcess.setText("Getting Image, Please Wait");
transferThread = new Thread(transmit);
transferThread.start();

So the thread starts and image is then transmitted, does the progress bar need to be in that event handler?

View Replies View Related

Swing/AWT/SWT :: SetDefaultLookAndFeel Is Not Working

Mar 26, 2014

setDefaultLookAndFeel is not working as i'm expecting.this is my code: URL....

import javax.swing.*;
import java.awt.*;
import javax.swing.event.*;
import java.awt.event.*;
import javax.swing.text.*;
import java.io.*;
import java.text.*;

[code]....

after reading the oracle tutorial on how to make frames and reading FrameDemo2.java. URL....i thought setDefaultLookAndFeelDecorated(true); would give me a different decoration than the default windows 7 border.but toggling between true and false changes nothing, and changing setUndecorated does nothing either.what am i supposed to do to make it look like the one in theFrameDemo2 window?

View Replies View Related

Swing/AWT/SWT :: JButton Actionlistener Not Working?

Mar 5, 2014

I was suspecting I had a jButton not working, so I added a console print to test. See below. When I click the button, the console doesn't display anything. Am I using the button wrong?

private void jButtonUpdateItemsMouseClicked(java.awt.event.MouseEvent evt) {
System.out.println("click");
System.out.println(drawPreviousRectangle);//this is a boolean
}

I have also tried the following with the same results (or lack of).

private void jButtonUpdateMajorDeckItemsActionPerformed(java.awt.event.ActionEvent evt) {
System.out.println("click");
System.out.println(drawPreviousRectangle);//this is a boolean
}

View Replies View Related

Swing/AWT/SWT :: ScrollPane Not Working As Expected

Mar 11, 2014

I am trying to get a scrollPane working correctly, but not having any luck. The picture drawn in the center panel is quite large and goes off the screen. I visited URL... but I am missing something vital. Both tracks show, but there is no knob to do the scrolling.

public DViewer() {
super();
frame = new JFrame();
frame.setSize(Toolkit.getDefaultToolkit().getScreenSize());
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

[code]....

View Replies View Related

Swing/AWT/SWT :: Scroll Pane Is Not Working

Sep 6, 2014

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.sql.*;
class Stock extends JFrame implements ActionListener

[code]....

well everything seems to be working fine only the scroll pane is not working.

View Replies View Related

Swing/AWT/SWT :: Submit Button Not Working?

Feb 27, 2015

The class does get compiled but the submit button doesn't work?

/**
* Orchestration class for Account
*/
import java.awt.*; //Importing the java.awt.* class
import java.awt.event.*;//Importing the java.awt.event.* class
import javax.swing.*;//Importing the javax.swing. class
public class AccountDemo extends JFrame
{
/// initializes the variables in the container

[Code] ....

View Replies View Related

Swing/AWT/SWT :: Drawing Various Shapes - Repaint Not Working

Jan 16, 2015

I'm trying to make a simple program that will feature some graphics. It will have a JCombobox that the user selects to draw various shapes. I can't get the repaint function to work however.

package selectingshapes;
import java.awt.Graphics;
import java.awt.Color;
import javax.swing.JPanel;
import java.awt.Graphics2D;

[Code] .....

View Replies View Related

Swing/AWT/SWT :: Using SetBounds Or SetLocation On JTextArea Not Working

Oct 31, 2014

I am adding a JTextArea to my JPanel with this code:

commentTextArea.setLineWrap(true);
commentTextArea.setWrapStyleWord(true);
commentTextArea.setVisible(true);
this.add(commentTextArea);
commentTextArea.setBounds(0, 0, 100, 100);
//commentTextArea.setLocation(0, 0);

Whenever I use setLocation(0,0), the JTextArea never moves. It is always in the top middle of the screen, not at (0,0). The same goes for setBounds(0,0,100,100) BUT the height and width are set this way, just not the location. Why is this?

Full Code

import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import javax.swing.JFrame;
import javax.swing.JMenuBar;

[Code] .....

View Replies View Related

Swing/AWT/SWT :: JFrame - Scroll Pane Is Not Working

Sep 5, 2014

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.sql.*;
class Stock extends JFrame implements ActionListener

[Code] ....

Everything is fine but the scroll pane is not working!

View Replies View Related

Swing/AWT/SWT :: Continuous Audio Data Stream Not Working

Oct 15, 2014

I am trying to make my audio loop and i tried the code below

public void audioloop() {
AudioPlayer MGP = AudioPlayer.player;
AudioStream BGM;
AudioData MD;
ContinuousAudioDataStream loop = null;
try {

[Code] ....

But is not working. I was thinking may be API is not work with java 7 because i got the following warning (AudioStream is internal proprietary API and may be removed in a future release);

View Replies View Related

Swing/AWT/SWT :: Positioning Slider Of Vertical Scrollbar Not Working

Apr 4, 2014

I have written a drum machine using Java. Into said drum machine I list all 47 available MIDI drums. The instrument list is placed into a JPanel, along with a gridArray of checkboxes. The JPanel is then in turn added to a scrollpane. I have listed the MIDI drums in order of 'ground-up'. For example, the bass drum is generally at the bottom of most drum kits, so it is at the bottom of my MIDI drums list. Next up would be the snare, followed by the cymbals, and then by all the specialty percussives. Since most beats are started from the 'ground-up', laying to foundation, so to speak, I want the scroll bar of the scrollpane which houses the JPanel, which in turn houses the instrument list and the beat checkboxes, to be positioned, upon opening, at the bottom of the scroll pane. Nothing I have tried works. It always positions the slider somewhere in the middle of the scroll track. Below is a listing of just the buildGUI portion of the code, all the MIDI functionality has been removed to keep the size of the post to this forum down.

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

public class BeatBoxG
{
JFrame overallOuterFrame;
JScrollPane namesAndSquares;

[code]....

View Replies View Related

Swing/AWT/SWT :: Restaurant Bill Calculator - JFrame Is Not Working

Sep 5, 2014

Why the JFrame is not working

// Project: RestaurantBillCalculator.java Calculates a table's bill.

// Import statements for different classes
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import java.text.*;
import java.util.*;
import javax.swing.*;
public class RestaurantBillCalculator extends JFrame

[Code] ....

View Replies View Related

Swing/AWT/SWT :: Analog Clock Working But Seconds Repeating In Java

Oct 6, 2014

I made an Analog Clock and its working but when a remove the filloval (Background) the seconds hand keep repeating itself..here is the code

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import javax.swing.JFrame;
import javax.swing.JPanel;

[code]....

View Replies View Related

Swing/AWT/SWT :: Printing JTable - Java (TM) Platform SE Binary Has Stopped Working

Nov 19, 2014

I am getting the following message when trying to print a JTable.

"Java(TM) platform SE binary has stopped working"

Here is the code:

try {
MessageFormat headerFormat = new MessageFormat("Page {0}");
MessageFormat footerFormat = new MessageFormat("- {0} -");
table.print(JTable.PrintMode.FIT_WIDTH, headerFormat, footerFormat);
} catch (java.awt.print.PrinterException pe) {
System.err.println("Error printing: " + pe.getMessage());
}

View Replies View Related

Project Is Working On JFrame - But Not Working On JApplet

Apr 10, 2014

I am developing an application to share my client screen with server, it is working well on swing. But i want to develop as web application, i am trying to using applet. But i am facing the fallowing problem..,

1) The Applet screen also open and project also running well on server mechine. But unable to see the client screen on the server.

2) The problem may be to display the JDesktopPane or JInternalFrame.

My working Server Code extends withe JFrame..Java Code:

package remoteserver;
import java.awt.BorderLayout;
import java.awt.Container;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import javax.swing.JApplet;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

[code]....

View Replies View Related

Why Key Not Working

Aug 29, 2014

Why in my program keys are not working, what I forgot to write?

import javax.swing.JFrame;
public class Main {
public static void main(String args[]) {
JFrame frame = new JFrame("Stickman");
frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);
frame.setSize(450, 490);

[code]....

View Replies View Related

Jar Is Not Working

Mar 5, 2014

I got my code into a jar, but when I run it I get his message:I just used Eclipse to make my jar and I thought I did it right but I guess not.

View Replies View Related

Scanner Is Not Working

Apr 24, 2014

I wrote a piece of code:

for(int i = 0; i < x; i++){
System.out.println("Enter students full name:");
sName[i] = result.fullName(sc.nextLine());
sExam[i] = result.examName("VB");
System.out.println("Enter students exam score:");
int scor = sc.nextInt();
sScore[i] = result.examScore(scor);
sGrade[i] = result.examGrade(scor);
}

When i run it i get:

Enter number of students:
1
Enter students full name:
Enter students exam score:

The problem is, i cant enter "full name", program is just jumping to the next step "exam score".

View Replies View Related

GetColor Is Not Working?

Oct 9, 2014

I am working on a fairly simple program where I have a colour change three times using the red green blue spectrum. The problem is that I keep getting a result of zero no matter what I do.

import java.awt.*;
 class RectangleMain
{
public static void main (String[] args) {
ColouredRectangle blocky = new ColouredRectangle(50, 100, 20, 40, Color.red);
System.out.println(blocky.getColour());
blocky.mixColour(Color.blue);

[code]...

View Replies View Related

KeyListener Is Not Working?

May 31, 2014

I'm programming a game, but the keyListener doesn't work. Here is the source code:

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
 public class InputHandler implements KeyListener{
 public InputHandler(Game game) {
game.addKeyListener(this);

[code]....

My Question is: Why will it not say "up", if I press "w"?

View Replies View Related

If Statement Not Working?

May 5, 2014

I'm having a problem where an if statement isn't working. In the Person class boolean olderThan ignores my if statement so it always returns false and I just don't get why that's happening.

import java.util.Calendar;
public class Person {
private String name;
private MyDate birthday;
  public Person(String name, int pp, int kk, int vv) {
this.name = name;

[code].....

View Replies View Related

Jar File Is Not Working

Feb 25, 2015

I have added a Simple Jar file in Eclipse Proect->BuildPath->jar file but class Inside that are not showing in My project this is my Project Structure and I have all ready checked in Order and Export..But jar file is not working.

View Replies View Related







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