Fill Different Size Boxes With Bags Most Efficiently

Jan 23, 2015

I have to write an example program to fill boxes most efficiently with bags. All bags are the same size. The boxes come in Large, Medium and Small. Large boxes hold 20 bags. Medium boxes hold 10 bags. Small boxes hold 5 bags. I am getting input from JOptionPane input dialog box and then parsing that input to an integer.

I have to fill the large and medium boxes completely. I am not sure how to do this without an if statement. I can use one, but we have not covered it in class, so I am skeptical about using one to solve the problem. If I just divide the input number with integer division, I'm not going to get the remainder, right? So I'm thinking that I can mod my input number by 20 (the number of bags the user inputs) and then mod that number by 10 and then mod that number by 5, would that work?

View Replies


ADVERTISEMENT

JavaFX 2.0 :: HTMLEditor - Default Size / Cannot Fill Full Screen

May 10, 2015

The code:
 
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.BorderPane;

[Code] ....
 
run (when window height > 700px ) :
 
HTMLEditor  default height is 670px, the other area (green color) is not filled,why?
 
HTMLEditor   高度总是670px, 怎么把HTMLEditor 填充满窗口?
 
这是一个bug吗?

is it bug?

View Replies View Related

I/O / Streams :: How To Send Messages Efficiently From Backend To Frontend

Apr 8, 2014

I'm working on a project that has two separate components. The first is a back end, that will do most of the heavy lifting, the other part is a front end GUI. The GUI will include the back end into it's project as an imported JAR file.

I need to be able to keep these two decoupled, as I might be writing different front ends using the same back end. The challenge in front of me (well one of many) is how to pass messages from the back end to the GUI so I can report things that are happening.

For example, if i call method FOO, FOO might do several different things; connect to a database, divide by zero, solve world hunger. I want to be able to either tie a JTextArea , or another component (or multiple components) to this stack of information, or at the very least, have something listening for this information, and when I see that my back end reports something, my front end is quickly aware of this information, and then I can process it and inform the user of the front end.

It would also be useful to be able to send a message from front end to back end , so perhaps the back end might learn that the front end user is unhappy and would like to stop running the current query.

View Replies View Related

Multiple Message Boxes

Jun 4, 2015

In vb.Net, when I do the code msgbox("hello world") and put it in a loop, it will execute that command and show a new messagebox for every time the code goes through the loop. I am wanting to do something similar with java but I'm afraid I don't know how.I know that the following code will display a messagebox as I am describing it

Java Code:

JOptionPane.showMessageDialog(null, "message", "title", 1); mh_sh_highlight_all('java');

But when put in a loop, it does two things:

1) It hangs the program

2) It will only display the first message box and when you press ok, the other message boxes will be disregarded and not displayed (I'm assuming because of the hang).

View Replies View Related

JOptionPane Message Boxes Not Opening?

Nov 25, 2014

For some reason the two JOptionPane message boxes at the end of my code don't seem to open when I run the program.

package assg2.kevin;
 import java.awt.HeadlessException;
import javax.swing.*;
import java.util.Arrays;
import java.util.Random;
 public class Assg2Kevin {
 
[Code] ....

View Replies View Related

Display What The Computer Chose (GUI Boxes)

Nov 29, 2014

for my class we have to make a rock paper scissors game using GUI boxes. Everything is working fine I'm just having trouble displaying what the computer chose. In other words, after the user selects Rock, paper or scissors, the scoreboard just pops up displaying the score. Here's the last working program before I started tinkering with it.

// your code goes here
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Icon;

[Code].....

View Replies View Related

JSP :: Create Text Boxes From Dropdown

Jul 9, 2014

I am able to generate text boxes. But I need one specific thing in that:

Through a drop-down I should select a number and those many text boxes should get generated.

Suppose I selected 4 from the drop down list. Then on screen it should display:

Student 1: Textbox
Student2: Textbox
Student3: Textbox
Student4: Textbox

View Replies View Related

JTextField - How To Use Multiple Text Boxes

Jun 17, 2015

I am trying to use JTextField. I have windows 7.I have jdk 8u45. I am trying to use multiple text boxes. I have written the following code:
 
import javax.swing.*;
import java.awt.*;
class Avg5Nums{
int num1, num2, num3, num4, num5;
double Avg;
Avg5Nums(int val1, int val2, int val3, int val4, int val5) {

[Code] ....

View Replies View Related

Swing/AWT/SWT :: Check Boxes On First Column Of Table

Sep 10, 2014

From what I can determine check boxes are applied in SWT to the first column only of a table.

final Table table_project = new Table(g3_tabfolder_projects, SWT.BORDER | SWT.CHECK);

However I require check boxes on all cells. I tried creating a table for each column (which gives me my check boxes) but as the number of enries are often numerous and thus require vertical scroll the tables become out of sync (and to the user that sync is important).

Before I knock up some code to try and synchronise the tables I just wanted to check any alternative approaches. The project is SWT based.

View Replies View Related

Java - Multiple Languages In Dialog Boxes

Oct 22, 2014

My application (e.g., the print dialog box) needs to support multiple languages (user selected either at starting application or by switch in code).

How can this be achieved under Windows 7, Enterprise (works OK under Linux). I have tried : E.g.,

Locale.setDefault( .. );
JComponent.setDefaultLocale(Locale.LANG);
Setting resource bundle

but to no avail. The application always inherit the Win 7 system locale.

View Replies View Related

Set Methods In Super And Subclass By Using Dialog Boxes

Nov 7, 2014

I am creating a set of 3 subclasses, 1 superclass, and an application. In my instructions it says to make set methods in my super and subclass by using dialog boxes. In the application you have 3 different arrays where you create objects and are supposed to call the methods from the subclasses to be used in the application. I don't know how to make the dialog boxes from my subclasses to show up in my application.

View Replies View Related

How To Output Information Entered In JOptionPane Dialogue Boxes

Feb 25, 2014

I understand the basics of using the JOptionPane Message boxes, but how do i take the information that is entered and store it as a file, or print it. I'm in my 6th week of class, and this happens to be maintenance related. 

import javax.swing.JOptionPane;
 public class Example_Maintenance_System{
  public static void main (String [] args) {
  //Operator Name Input
String operator_name;
operator_name = JOptionPane.showInputDialog("Please scan your barcode");

[code]....

View Replies View Related

How To Generate Alternate Color Of Balls Combination For 3 Boxes

Feb 24, 2014

I am working on a project in which I have three box (as of now) and each box will have some color of balls. So I am storing them in a Map of String and List of String as mention below.

Map<String, List<String>> boxBallMap = new LinkedHashMap<String, List<String>>();

Data in the above map is like this -

Java Code:

{box1=[blue, red, orange]}
{box2=[blue, red]}
{box3=[blue, red, orange]} mh_sh_highlight_all('java'); ProblemStatement:-

Basis on the above input, I need to return a mapping which will be List<Map<String, String>>, let's say for above input, below mapping would be return as an output -

Java Code:

[{box1=blue, box2=red, box3=orange},
{box1=red, box3=blue},
{box1=orange, box2=blue, box3=red}] mh_sh_highlight_all('java');

Here if you see, each row has alternate color of balls for each box - meaning blue for box1, red for box2, orange for box3 in first row. I cannot have same color of balls in each row. So this combination is not possible as it has same color of balls for two boxes in one row.

Java Code: {box1=blue, box2=blue, box3=orange} mh_sh_highlight_all('java');

And also, in the second row, I won't use those balls which have been used in the first row for that box. In second row, box1 has red why? bcoz blue was already used in the first row for box1 and box3 has blue and no box2 in second row.

The output combination is getting generated basis on the input being passed as shown above.

I started with the below code -

Java Code:

List<String> balls1 = Arrays.asList("red", "blue", "orange");
List<String> balls2 = Arrays.asList("red", "blue");
List<String> balls3 = Arrays.asList("red", "blue", "orange");
Map<String, List<String>> maps = new LinkedHashMap<String, List<String>>();

[Code] ....

Below is my method in which the crux of logic should be there

Java Code:

private static List<Map<String, String>> generateMappings(Map<String, List<String>> map) {
return null;
} mh_sh_highlight_all('java');

Below algorithm might work but still not sure how should I fit this in the code -

- sort the boxes by the number of balls they have in it (ascending, from the smallest to the largest box).
- while there are colors left
- loop over the sorted list of boxes
- in each iteration pick a color from the box (if there is one left), that is not already picked in the current iteration (of the while loop)

View Replies View Related

Swing/AWT/SWT :: Creating Text Fields / Labels And Input Boxes On GUI

Oct 18, 2014

How to create text fields, labels and input boxes on a GUI, we haven't covered these in class as of yet, but I want my project to stand out so I'd like to know how to build a GUI now.

View Replies View Related

How To Fill Array Of Points

Oct 10, 2014

I need to write a program but I am having hard time filling an array of triangles...we are suppose to have 3 different classes..1 class of points..1 class of triangles and 1 main method which apply all those..here what I have been come up so far for the point class which I believe is good..

public class Point {
private float x;
private float y;
//Making x equal to the x coordinate and y equal to the y coordinate like on a graph
public Point(float xCoordinate, float yCoordinate) {
x = xCoordinate;
y = yCoordinate;

[Code] ....

Now here is my question how I am suppose in the main method fill an array of triangles for 100 triangles or less?

View Replies View Related

Fill 2D Array With No Duplicates

Nov 2, 2014

THE PROGRAM DOES NOT HAVE ERRORS. FILL THE 2D ARRAY WITHOUT DUPLICATES VALUES. AND DISPLAY IF THE ARRAY IS MAGIC SQUARE OR NOT.

View Replies View Related

Fill A Panel With Seats

Jun 13, 2014

We get a database and some DAO classes. We had to fill a ShowPanel with different shows being given in a theatre, and then when you choose from this you get several dates. Then when you click a date, the seatings appear in the SeatPanel. I got the first part with the shows and dates. But Im stuck at getting the seatings.We have a controller class which calls the shows+dates (this happens in one method). But i always get a nullpointerexception for the seatings. (this happens in a different method). I think i just don't know how to link the chosen show+date with the seatings.For the moment i have

public ArrayList<Seats> getSeating() throws SeatingException{
Show s = shows.getName();
ArrayList<Showdate> showdate = s.getDates();
ArrayList<Place> seating = new ArrayList<Place>();
try{
for (Showdate sd : showdate ){

[code]...

The given class PlaceDao has a static getInstance() method and an ArrayList<model.Place> getSeating(model.Showdate showdate) method.In the next stage i have to try and fill the panel with the seatings, but first i need to be able to call them.

View Replies View Related

Array Will Not Fill Properly

Dec 8, 2014

my validAccounts array will not fill properly and has a null value in it.I added a print statement that prints the contents of the array and it is filling correctly but the very last value is null. I am supposed to be asking the user for a account number and password and it is not printing out correctly due to the fact that the array is not filled correctly.

import java.util.*;
import java.io.*;
public class ATM2 {
public static Scanner kbd;
public static final int MAXSIZE = 50002;

[code]....

View Replies View Related

How To Fill A String With Characters Randomly

Jul 5, 2014

I need to make a string filled with naughts and crosses like this one : "xxx ooo xox". There are 3 groups separated with a space. how to fill the string randomly ?

View Replies View Related

Randomly Fill 2D Array In Constructor

Dec 7, 2014

I must fill a 2d array randomly and then apply methods to the array. However i keep getting an out of bounds exception no matter what dimensions i use. I have a test and a class program.

import java.util.*;
import java.lang.Math;
import java.util.Arrays;
import java.util.Random;
class SummerStats {
Random rand = new Random();

[Code] .....

View Replies View Related

Using JDK To Fill In Spread Sheets In Excel

Jan 27, 2015

I would like to make a small gift for my dad and i have a spreadsheet and i would like to make a small program that asks information and the puts it in the right column in the spreadsheet .For example i ask how many children do you have in your class and you answer 7 and that number goes into the spreadsheet.

View Replies View Related

ValidAccounts - Array Will Not Fill Properly

Dec 8, 2014

My validAccounts array has a null value in it when i print it. How to do this.

I am NOT allowed to use bufferedReader or ArrayLists. This must be done with loops.

import java.util.*;
import java.io.*;
public class ATM2 {
public static Scanner kbd;
public static final int MAXSIZE = 50002;
public static void main(String[] args) {
kbd = new Scanner(System.in);

[Code] ....

View Replies View Related

Swing/AWT/SWT :: Fill JTable From Database With SwingWorker?

Sep 26, 2014

Why this code is not working/my JTable won't updated after i click the button

import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.ResultSet;

[code]....

View Replies View Related

How To Deal With Exam Like PDF - Fill In Oval Image

Feb 1, 2015

So, let's say I have a pdf that looks like an exam or anything that has answer choices and an oval to fill in.

So, if I want to create a program that fills in some of those ovals, I would first need to find the coordinates? I can use something like gimp?

And once I have those coordinates, what do I do? Like do I extract the oval image and replace it with a filled in one? Is there a library that lets me do this - also lets me set the size to make sure the new filled in oval image is the same size?

View Replies View Related

Bingo Board - Having Array To Fill A Grid

Dec 16, 2014

I am attempting to make a 5x5 bingo board. My array generates 75 numbers(15 per bingo letter) and displays them in a random order. What I am having trouble figuring out is how to fill the 5x5 grid with 25 numbers from my array. And yes, my code is probably much longer and much more redundant than it needs to be. Also, I think I'm using cells and grids terribly wrong (possibly the entire java language) but I'm not sure.

import java.util.*;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JLabel;
import java.awt.event.*;
import java.util.ArrayList;
import java.awt.GridLayout;
import javax.swing.JButton;
public class bingoboard extends JFrame

[code]...

View Replies View Related

Swing/AWT/SWT :: How To Fill Text Fields With Selection From JList

May 2, 2015

I have an addressBook GUI where I have a JList that populates with the contacts names, and once I double click a contacts name I'm wanting to fill the textfields with the contacts corresponding data.

ex) ContactType: Family (enum), Name: Zoidberg, Address: 111 Space Drive, City: New York City, etc...

I've got it to where I select open from the JMenu, it populates the JList, but once I select a contacts name, all the textfields are populated, but only with the contacts name

ex) Name: Zoidberg, Address: Zoidberg, City: Zoidberg, etc....

What am i doing wrong here, and how can i fix it to where it fills out the correct data?

Here's my code so far:

public class AddressBookGUI extends JFrame {
private final int WIDTH = 450;
private final int HEIGHT = 300;
private JLabel currentlySelected;
private JTextField contactTypeTextField;

[code]...

I'm certain the logic is messed up near the end where i set all text fields to the index, because no matter what field i want to fill it's at it's going to set it to whatever index I select, but I don't know how to fix it.

View Replies View Related







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