/    Sign up×
Community /Pin to ProfileBookmark

Problem Debugging Weird Error Message

Hello all,

For the past five hours or so I’ve been coding and debugging a simple input/output program and have been stuck on this one error message I keep getting. I don’t know what kind of error it is because the program runs just fine; I use eclipse and the message appears in red in the console window.

This is my coding…..

[CODE]import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.HeadlessException;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.URL;
import java.util.Scanner;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.border.BevelBorder;
import javax.swing.border.EtchedBorder;
import javax.swing.border.LineBorder;
import javax.swing.border.TitledBorder;
/**
* Class to provide a simple GUI for a ATM machine.
* Original provide by DJ Rao
* Modified by Don Byrkett on 9/9/08
*/
public class BSGATM implements ActionListener {
private int amount = 0;
private JLabel currAmount;
private JFrame frame;
private JButton [] buttons;
private ImageIcon bsgLogo;
private ImageIcon bsgIcon;
// Constructor
public BSGATM() {
try {
frame = new JFrame(“Battlestar Galactica ATM”);
Dimension size = new Dimension(250, 300);
frame.setPreferredSize(size);
frame.setSize(size);
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(new BorderLayout(5, 5));
// Layout the frame with all the necessary components.
layoutFrame(frame);
frame.setVisible(true);
} catch (HeadlessException he) {
// No GUI to work with
currAmount = null;
}
}
// Public method to obtain input
public int getAmountFromUser() {
if (currAmount != null) {
try {
synchronized (currAmount) {
currAmount.wait();
amount = Integer.parseInt(currAmount.getText());
}
} catch (InterruptedException e) {
e.printStackTrace();
}
} else {
Scanner keyboard = new Scanner(System.in);
amount = keyboard.nextInt();
}
return amount;
}
// Public method to display change
public void dispenseChange(String s) {
if (currAmount == null) {
System.out.println(“The change for ” + amount + ” is:n”);
System.out.println(s);
} else {
JLabel title = new JLabel(” Cylon Proof BSG ATM “, JLabel.CENTER);
Color bc = title.getBackground();
title.setBackground(title.getForeground());
title.setForeground(bc);
title.setOpaque(true);
title.setBorder(new BevelBorder(BevelBorder.LOWERED));
JTextArea ta = new JTextArea(s, 8, 30);
ta.setFont(new Font(“courier”, Font.PLAIN, 12));
ta.setBorder(new TitledBorder(“Change for ” + amount + ” is:”));
ta.setEditable(false);
JTextArea ta2 = new JTextArea(“Bills dispatched to accounts for verification.n” +
“Please collect actual bills from accounts department.n” +
” -Thank you”, 3, 30);
ta2.setEditable(false);
ta2.setOpaque(false);
JPanel message = new JPanel(new BorderLayout(5, 5));
message.add(title, BorderLayout.NORTH);
message.add(ta, BorderLayout.CENTER);
message.add(ta2, BorderLayout.SOUTH);
message.setBorder(new LineBorder(Color.lightGray, 1, true));
JOptionPane.showMessageDialog(frame, message, “BSG ATM Response”, JOptionPane.OK_OPTION, bsgLogo);
frame.setVisible(false);
frame.dispose();
}
}

private void layoutFrame(JFrame frame) {
// Load icon for pretty stuff.
try {
bsgLogo = new ImageIcon(new URL(“http://www.users.muohio.edu/raodm/BSGLogoIcon.png”));
bsgIcon = new ImageIcon(bsgLogo.getImage().getScaledInstance(16, 16, Image.SCALE_SMOOTH));
} catch (Exception e) {
e.printStackTrace();
bsgIcon = null;
}
frame.setIconImage(bsgIcon.getImage());
frame.add(createAmountField(), BorderLayout.NORTH);
frame.add(createButtons(), BorderLayout.CENTER);
JButton button = new JButton(“Dispense Amount”, bsgIcon);
button.addActionListener(this);
button.setActionCommand(“*”);
frame.add(button, BorderLayout.SOUTH);
buttons[12] = button;
}

private JPanel createButtons() {
buttons = new JButton[13];
JPanel buttonPanel = new JPanel(new GridLayout(4, 3, 5, 5));
String buttonLabels = “1234567890C?”;
for(int i = 0; (i < buttonLabels.length()); i++) {
JButton button = new JButton(buttonLabels.substring(i, i + 1));
button.addActionListener(this);
button.setActionCommand(buttonLabels.substring(i, i + 1));
buttonPanel.add(button);
buttons[i] = button;
}
return buttonPanel;
}

private JPanel createAmountField() {
currAmount = new JLabel(“0”, JLabel.RIGHT);
currAmount.setFont(currAmount.getFont().deriveFont(30f));
currAmount.setForeground(Color.green);
currAmount.setBackground(Color.black);
currAmount.setOpaque(true);
TitledBorder border = new TitledBorder(new EtchedBorder(Color.gray, Color.white),
“Punch-in Amount:”);
border.setTitleColor(Color.red);
JLabel logo = new JLabel(bsgLogo);
logo.setBackground(Color.black);
JPanel panel = new JPanel(new BorderLayout(5, 5));
panel.add(currAmount, BorderLayout.CENTER);
panel.add(logo, BorderLayout.WEST);
panel.setBackground(Color.black);
panel.setBorder(border);
return panel;
}

public void actionPerformed(ActionEvent ae) {
int action = “0123456789C?*”.indexOf(ae.getActionCommand().charAt(0));
if (action == -1) {
return;
}
switch (action) {
case 10:
currAmount.setText(“0”);
break;

case 11:
JOptionPane.showMessageDialog(frame, “A mystery button to arouse your curiosity :-)n” +
“Sorry, this button currently does nothing.n” +
“But with a little more Java knowlege You can deciden” +
“what this button is going to do!nThe possibilities are endless…”);
break;

case 12:
for(int i = 0; (i < buttons.length); i++) {
buttons[i].setEnabled(false);
}
synchronized (currAmount) {
currAmount.notifyAll();
}
break;

default:
String text = currAmount.getText().equals(“0”) ? “” : currAmount.getText();
text = text + action;
if (text.length() > 6) {
Toolkit.getDefaultToolkit().beep();
return;
}
currAmount.setText(text);
//currAmount.repaint();
}
}
}
[/CODE]

[CODE]
public class AtmMiddleWare {
public static void main(String[] args) {

//Constructing a new object of the BSGATM class named ‘atm’
BSGATM atm = new BSGATM ();
int Amount;
Amount = atm.getAmountFromUser();
String s = new String ();
s = “Number of $100 bills : nNumber of $50 bills :nNumber of $20 bills : nNumber of $10 bills : nNumber of $5 bills : nNumber of $1 bills : “;
atm.dispenseChange(s + “n” + Amount);

}

}
[/CODE]

and here is the error message–if you want to call it that, considering the program runs just fine–that I don’t understand…….

[CODE]2008-09-18 23:55:50.429 java[291] CFLog (0): CFMessagePort: bootstrap_register(): failed 1103 (0x44f), port = 0xf103, name = ‘java.ServiceProvider’
See /usr/include/servers/bootstrap_defs.h for the error codes.
2008-09-18 23:55:50.429 java[291] CFLog (99): CFMessagePortCreateLocal(): failed to name Mach port (java.ServiceProvider)
[/CODE]

to post a comment
Java

1 Comments(s)

Copy linkTweet thisAlerts:
@chazzySep 19.2008 — what os is this running on?
×

Success!

Help @nvibest spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...