crazygerad
February 21st, 2006, 08:52 PM
I am using Breezy, so far its stable with the java console thing updated to 1.5 or v5. I am trying to do an exercise in a book and it works well when I use java and javac but looking for an easier time I got Eclipse through Synaptic (I might add it's a very useful tool).
So I am using two classes, I checked them for errors and they are exactly like in the book and whenever I try to run it gives me this error:
** ERROR **: file ../../../src/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c: line 572 (createRawData): assertion failed: (data_fid != 0)
aborting...
I did google about it, and all I could find is that people either weren't able to reproduce it, unanswered question or that I should update gcc 4.0 to 4.1 that will have that problem fixed but i checked the repositories and it doesn't exist.
Any help would be greatly appreciated since I have to learn this to build a program for a class. Sorry that the code isn't well written here, it seems I can't make it keep the original tabs and stuff.
so what I am trying to run is this:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class TwoButtons {
/**
* @param args
*/
JFrame frame;
JLabel label;
public static void main(String[] args) {
// TODO Auto-generated method stub
TwoButtons gui = new TwoButtons();
gui.go();
}
public void go() {
frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E);
JButton labelButton = new JButton("Change Label");
labelButton.addActionListener(new LabelListener());
JButton colorButton = new JButton("Change Circle");
colorButton.addActionListener(new ColorListener());
label = new JLabel ("I'm a label");
MyDrawPanel drawPanel = new MyDrawPanel();
frame.getContentPane().add(BorderLayout.SOUTH, colorButton);
frame.getContentPane().add(BorderLayout.CENTER, drawPanel);
frame.getContentPane().add(BorderLayout.EAST, labelButton);
frame.getContentPane().add(BorderLayout.WEST, label);
frame.setSize(300,300);
frame.setVisible(true);
}
class LabelListener implements ActionListener {
public void actionPerformed(ActionEvent event) {
label.setText("Ouch!");
}
}
class ColorListener implements ActionListener {
public void actionPerformed(ActionEvent event) {
frame.repaint();
}
}
}
Other file:
import java.awt.*;
import javax.swing.*;
public class MyDrawPanel extends JPanel {
public void paintComponent(Graphics g) {
g.fillRect(0,0, this.getWidth(), this.getHeight());
int red = (int) (Math.random() * 255);
int green = (int) (Math.random() * 255);
int blue = (int) (Math.random() * 255);
Color randomColor = new Color(red, green, blue);
g.setColor(randomColor);
g.fillOval(70,70,100,100);
}
}
So I am using two classes, I checked them for errors and they are exactly like in the book and whenever I try to run it gives me this error:
** ERROR **: file ../../../src/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c: line 572 (createRawData): assertion failed: (data_fid != 0)
aborting...
I did google about it, and all I could find is that people either weren't able to reproduce it, unanswered question or that I should update gcc 4.0 to 4.1 that will have that problem fixed but i checked the repositories and it doesn't exist.
Any help would be greatly appreciated since I have to learn this to build a program for a class. Sorry that the code isn't well written here, it seems I can't make it keep the original tabs and stuff.
so what I am trying to run is this:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class TwoButtons {
/**
* @param args
*/
JFrame frame;
JLabel label;
public static void main(String[] args) {
// TODO Auto-generated method stub
TwoButtons gui = new TwoButtons();
gui.go();
}
public void go() {
frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E);
JButton labelButton = new JButton("Change Label");
labelButton.addActionListener(new LabelListener());
JButton colorButton = new JButton("Change Circle");
colorButton.addActionListener(new ColorListener());
label = new JLabel ("I'm a label");
MyDrawPanel drawPanel = new MyDrawPanel();
frame.getContentPane().add(BorderLayout.SOUTH, colorButton);
frame.getContentPane().add(BorderLayout.CENTER, drawPanel);
frame.getContentPane().add(BorderLayout.EAST, labelButton);
frame.getContentPane().add(BorderLayout.WEST, label);
frame.setSize(300,300);
frame.setVisible(true);
}
class LabelListener implements ActionListener {
public void actionPerformed(ActionEvent event) {
label.setText("Ouch!");
}
}
class ColorListener implements ActionListener {
public void actionPerformed(ActionEvent event) {
frame.repaint();
}
}
}
Other file:
import java.awt.*;
import javax.swing.*;
public class MyDrawPanel extends JPanel {
public void paintComponent(Graphics g) {
g.fillRect(0,0, this.getWidth(), this.getHeight());
int red = (int) (Math.random() * 255);
int green = (int) (Math.random() * 255);
int blue = (int) (Math.random() * 255);
Color randomColor = new Color(red, green, blue);
g.setColor(randomColor);
g.fillOval(70,70,100,100);
}
}