Howard Bates

Greenhorn
+ Follow
since Feb 26, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Howard Bates

I figured it out!

These: textIn_s0.setText(character.getSkillZero());

Should be: textIn_s0.setText(characterRestore.getSkillZero());

Thanks!
15 years ago
Thanks! I have changed to the following:
} catch(IOException e1){
textOut.setText("ERROR!");
} catch(ClassNotFoundException e2){
textOut.setText("ERROR!");
}

I am not seeing any errors, just not populating fields.

~HB
15 years ago
Here is the code that opens the 'character.ser':
item02 = new JMenuItem("Open");
item02.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
int retval = fileChooser.showOpenDialog(RolePlayerUtility.this);
if (retval == JFileChooser.APPROVE_OPTION) {
File file = fileChooser.getSelectedFile();
ObjectInputStream is = new ObjectInputStream(new FileInputStream(file));
Character characterRestore = (Character) is.readObject();
textIn_s0.setText(character.getSkillZero());
textIn_s1.setText(character.getSkillZeroBonus());
textIn_s2.setText(character.getSkillOne());
textIn_s3.setText(character.getSkillOneBonus());
textIn_s4.setText(character.getSkillTwo());
textIn_s5.setText(character.getSkillTwoBonus());
textIn_s6.setText(character.getSkillThree());
textIn_s7.setText(character.getSkillThreeBonus());
textIn_s8.setText(character.getSkillFour());
textIn_s9.setText(character.getSkillFourBonus());
textIn_s10.setText(character.getSkillFive());
textIn_s11.setText(character.getSkillFiveBonus());
}
} catch(Exception e1){}
}
}
);
______________________________________________________________________
Works perfectly if I do not close running program. If I close, re-open, and then try, all fields remain blank.

Thanks!

~HB
15 years ago
Hello. I have written a program that saves JTextField values to a .ser file. As long as the program is still running, I can read those values back into eaxh JTextField. If I close the program, re-open it, and try to read them in again, the JTextFields remain blank. Am I doing something wrong?

Thanks!
15 years ago
Hello,

I am trying to create a dice rolling program. I want users to be able to enter number of dice to roll, then type of dice to roll i.e. d6, d20, etc. I need the variable for the die roll result to be added up and displayed to the user in a text box. This is the code I have to do it:

public void doDiceStuff()
{
dice = new DieRoller();
String input_1 = textIn_1.getText();
String input_2 = textIn_2.getText();
int qty = Integer.parseInt(input_1);
int dieType = Integer.parseInt(input_2);
for (i = 0; i <= qty; i++) {
int newValue = newValue + dice.rollIt2(dieType);
}
textOut_0.setText("" + newValue);
}
I get an error on the last line: "Cannot find symbol - variable newValue"

Thank you for your help!

~Howard
16 years ago
Thanks for the help folks!

I changed:

import net.miginfocom.swing.MigLayout;

to:

import net.miginfocom.swt.MigLayout;

and I get this error:

Cannot access org.eclipse.swt.widgets.Layout

My CLASSPATH is:

.;E:\JAVA\BatesProjects\miglayout15-swt.jar;E:\JAVA\BatesProjects\riverlayout.zip;E:\JAVA\BatesProjects\tablelayout.jar
16 years ago
Thank you for your quick reply!

I just tried it, but I got the following error:

Package net.miginfocom.swing does not exist.

So close......

Thanks!

~Howard
16 years ago
Hello.

I am trying to use different layout managers but I can't seem to get them to work. I run the JDK off of my jumpdrive and I use BlueJ as my IDE. I have put the Layout jar file in my jre/lib/ext folder and used the following code to access:

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

public class MigTest
{
/**
* Constructor for objects of class MigTest
*/
public MigTest()
{
JPanel p = new JPanel(new MigLayout("", "[right]"));

p.add(new JLabel("General"), "split, span, gaptop 10");
p.add(new JSeparator(), "growx, wrap, gaptop 10");

p.add(new JLabel("Company"), "gap 10");
p.add(new JTextField(""), "span, growx");
p.add(new JLabel("Contact"), "gap 10");
p.add(new JTextField(""), "span, growx, wrap");

p.add(new JLabel("Propeller"),"split, span, gaptop 10");
p.add(new JSeparator(), "growx, wrap, gaptop 10");

p.add(new JLabel("PTI/kW"), "gap 10");
p.add(new JTextField(10), "");
p.add(new JLabel("Power/kW"), "gap 10");
p.add(new JTextField(10), "wrap");
p.add(new JLabel("R/mm"), "gap 10");
p.add(new JTextField(10), "wrap");
p.add(new JLabel("D/mm"), "gap 10");
p.add(new JTextField(10));
}
}

I get the error on my import statement for miglayout. I have also edited my CLASSPATH to point directly to the jar file, but to no avail.

Thanks,

Howard
16 years ago