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
ADVERTISEMENT
Nov 29, 2014
In my Java SWT application, I have few methods, that take longer time to complete. These methods has to be initiate and run as response to button click. There I want to implement progress bar to show the progress/status of long run method. Long run methods are Java Processes, in which it executes some command line functionality. (ex: run ls method in Linux).
Process p = Runtime.getRuntime.exec(command)
In progress bar status is set using setSelection method which takes int as argument. How to indicate the progress of process in progress bar, because I don't have int value to pass into setSelection method of progressbar.
View Replies
View Related
Mar 29, 2014
I'm struggling with a small project. I have 2 jFrames. The first frame has a button that...
- Display's the second frame containing a progressbar
- Starts a heavy processing thread
I need to update the progressbar on the second jFrame, from a thread started on the first jFrame.
I have 2 problems:
- How do I update the progressbar?
- When the button is clicked, an empty second frame is displayed with no controls. The controls are only rendered/shown, after the large thread process is finished...
I've attached to this post a small screenshot, showing the main idea ...
Source code:
Button action on the first frame:
private void btnGoActionPerformed(java.awt.event.ActionEvent evt) {
Progress progress = new Progress(); // The second frame
progress.setVisible(true);
clsProcess myProcess = new clsProcess(); // The thread process
myProcess.start();
[Code] ....
View Replies
View Related
Mar 7, 2014
I wish to display a progress bar during a lengthy file translation process. When I created a ProgressBar class to do this and tested it with a short test program, it seemed to work fine. But when I add my ProgressBar class to a package containing various other classes, put that package in a jar file, and then execute the class using the progress bar from a menu in my main program, the frame of the progress bar shows up with the appropriate caption but the JLabel, JProgressBar, and JButton are not displayed. I have gone over my code numerous times and checked that the ProgressBar class constructor is getting the proper arguments.
// package gov.nasa.jpl.ephemeris;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
* Progress bar with message text above the bar and a Cancel button below it
*/
public class ProgressBar extends JFrame {
private boolean _cancelled = false;
private JProgressBar _progressBar = null;
[Code] ....
I have also been wondering whether I need a separate instance of the border for each panel, or whether I can just create one instance and use it for all three panels.
View Replies
View Related
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
Dec 16, 2014
i was uploading file to drop-box using java.But the problem is how can i add progress bar to file upload to drop-box.I didn't use java script for it.I didn't get any of this in drop-box API. my code is.
import com.dropbox.core.*;
import java.io.*;
import java.util.Locale;
public class Main {
public static void main(String[] args) throws IOException, DbxException {
// Get your app key and secret from the Dropbox developers website.
final String APP_KEY = "INSERT_APP_KEY";
final String APP_SECRET = "INSERT_APP_SECRET";
[code]....
View Replies
View Related
Oct 1, 2014
I am having a error in progress bar ... I want to see the progress upon checking the sha1 of files
This is the code:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package program1;
//Import packages
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
[Code] .....
This is the error
Exception in thread "Thread-2" java.lang.NullPointerException
at program1.ProgressBar$thread1.run(ProgressBar.java:98)
at java.lang.Thread.run(Thread.java:744)
View Replies
View Related
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
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
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
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
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
View Related
Oct 16, 2014
I have this method:
Java Code:
public static void listFiles(String path) {
File[] list = null;
File root = new File( path );
list = root.listFiles();
if (list == null) return;
for (File f : list) {
if (f.isDirectory()) {
[code]....
How would I get the overall progress of reading the directory I give to it, for example, if I give it the root directory of my computer, it would read through ALL my files and folders, and that works fine.But how would I get progress for a progress bar?
View Replies
View Related
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
Oct 1, 2014
I want a progress bar when checking the sha1 . When getting the sha1 there we see the progress of checking
here is the code
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package program1;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.security.MessageDigest;
import java.util.HashSet;
[Code] ....
This is the output
Exception in thread "Thread-2" java.lang.NullPointerException
at program1.ProgressBar$thread1.run(ProgressBar.java:98)
at java.lang.Thread.run(Thread.java:744)
View Replies
View Related
Oct 5, 2014
I have a datagrid in which i have to display progress bar with the task completed in %.
For example i have two fields in a table source count and completion count.
Where source count in 100000 rows and 50000 rows have been inserted.
In another table and status is displayed in the table.
So I need to display in a progress bar that 50% task has been completed.
View Replies
View Related
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
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
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
May 5, 2014
I'm trying to get a timer to work to decrease the value of a stats bar (like Hunger Level, Energy Level), but it won't paint the bars in the first place, it won't let me start the timer (the start after t.start() is underlined) and now I'm getting an error that won't let me run it at all without putting public static void main (String [] args), even though adding it anywhere is causing other errors
public void hungerTimer () {
int delay = 300;
int period = 300;
interval = 100;
hungerBar.setValue(100);
hungerBar.repaint();
timer = new Timer();
[Code] .....
View Replies
View Related
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
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
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
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
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
Aug 28, 2014
Since the upgrade to JavaFX 8u20 my ProgressIndicator won't rotate anymore when using Caspian style. Is there any workaround for this?
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.ProgressIndicator;
import javafx.stage.Stage;
public class TestApp2 extends Application {
public static void main(String[] args) {
[Code] ....
View Replies
View Related