I think its a fairly broad question since there are some benefits to windows over linux from a development perspective. However I personally have used debian based linux distro's for the past few years I would say to anyone to choose the right tool for the right job.

However some of the benefits of linux may be :

  • Can be lightweight - Some linux distro's are extremely small so can be fully functional on older hardware
  • Customizable - Most required services are extremely flexible and can be removed and or modified very easily if source code is available
  • Package Management and software installation - Most fully fledged desktop distro's offer an out of the box package manager to keep software installation simple for new users and allow access to a huge amount of readily available software with one click, or using the terminal commands.
  • Open source - Usually, Most Distributions consist of packages that can be easily found and modified and so most aspects of the whole user experience can be changed

Hi,

I was wondering if anyone could help me or point me in the right direction. Iv been developing a source to source compiler for some time, so one language being translated to C++/C.

Now the source has been translated i wish to package a windows and linux c++ compiler with my application, preferably as a standalone binary in a local directory rather than a full system install IE.

-My application Directory
    -My application binary.exe
        -compiler my application will use
            -Mingw.exe
            -g++.exe

However so far the only compiler i can find binary distributions that dont require me to perform a 'make' to produce binaries for is MINGW. This means i can build my c++ application for windows on linux however not linux applications on linux etc.

Would anyone be able to tell me where i could find a compiler with binaries already available for linux and windows that is either redistributable and standalone as mentioned above. Or easy to install on a system level preferably just a C++ compiler, as GCC is a fairly large bundle.

Actually worked a treat and saved me a bunch of unneccessary code. Cheers!

I looked into this, but i cannot find a "handle" method for interface ItemListener at all. The oracle documentation says it contains only 1 method : http://docs.oracle.com/javase/7/docs/api/java/awt/event/ItemListener.html
Also the second choice's listener is attached to a checkbox not a choice so they are inherently different right away...

To implement an itemlistener interface you would have implement its abstract method like:

ItemListener itemlistener = new ItemListener() {

            @Override
            public void itemStateChanged(ItemEvent e) {

            }
        };

A good examples of a complete implementation of an itemlistener attached to a radio button can be found here : http://examples.javacodegeeks.com/desktop-java/awt/event/itemlistener-example/

So i cannot say which is better, but if i had to choose how i would add an item listener to a choice i would probably do something like :

Choice c=new Choice();
c.add("First Choice");
frame.add(c);

c.addItemListener(new ItemListener()
 {
        public void itemStateChanged(ItemEvent ie)
        {
        System.out.println("Your choice was"+c.getSelectedItem());
        }
 });

Im not really sure i can answer the question without knowing what the handle method does, but i hope this helps in some way.

Hi,

I have been trying to create a game loop that is paused when a certain key is pressed. This seemed to work ok in Swing but in javafx the loop locks up the UI, even if i create a seperate thread.

 @FXML
    public void setPaused(KeyEvent e) {

        if (e.getCode().compareTo(KeyCode.P) == 0) {
            //isPaused = !isPaused; Ignored for now
            drawLoop();//begin draw loop
        }

    }

//used to create an interactive loop on the canvas
    public void drawLoop() {

        while(!isPaused){
          redraw();
          try{
          Thread.sleep(17);
          }catch(){
          }
        }

    }

public long redraw() {
        long t = System.currentTimeMillis();
        width = getWidth();
        height = getHeight();
        drawTiles(); //simple draws images onto a canvas, basically a drawImage(buffer) function
        return System.currentTimeMillis() - t;
    }

This is an extremely cutback version of what i have in full ( i had threads at one point for the redraw function, same problem), but ultimately from doing reading iv found that Javafx uses the event dispatcher to handle the UI and apparently calling a loop from a button press locks this thread up...to my understanding i could be wrong.

Can anyone recommend an alternative way to achieve a simple redraw loop that wont freeze my UI in a loop and can be triggered and stop via keyboard? Any help would be appreciated :)

Hello,

im currently working on a program to split a string based on symbols only, i need to seperate the string around the symbols whilst keeping the symbols as well eg.

test_String123^;

would result in an array containing : [test] [] [String] [] [123] [_] [^]

However although i have achieved it with this code :

exampelstring.split("(?<=\\^)|(?=\\^)|(?<=\\_)|(?=\\_)");

I was wondering if there is a way to achieve this with less code as if i add more symbols then the regex becomes huge have a forward and behind check for each symbol. Is there a way to combine multiple lookaheads and lookbehinds into the same regex or a cleaner way of performing such a split?

Thanks for helping :)

wxGTK is installed, however wxGTK-gl is not in the linux mint repository at all. So it seems you are correct about the missing wxGTK-gl package, however i have o idea where to get it and install it with all required dependencies/

Hello,

Iv been trying to compile a simple opengl / wxwidgets program in c++ on linux mint. However when i try to compile with :

g++ MyGLCanvas.cpp  MyGLCanvas.h openGLProjectApp.cpp  openGLProjectApp.h openGLProjectFrm.cpp openGLProjectFrm.h `wx-config --cxxflags --libs --gl-libs -lGL` -o simpleprogram

I get an error message :

cannot find -lwx_gtk2u_-lGL-2.8
collect2: error: ld returned 1 exit status

I have installed mesa and all the standard opengl library's such as libglumesa etc. However still seem to be unable to compile with g++, any advice would be very useful. The library lwxgtk2U-lgl is unfindable on any repository site i have been on as well.

Hello,
I was hoping someone can help me, im looking for a way to extend a basic shape class in particular the roundedrectangle2d class and be able to draw it in the same way we could handle an object with a simple call to g.draw(object instance);

However im having problems with it not being drawn to the canvas, i only see a gray rectangle for the code below :

import java.awt.BasicStroke;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;

import javax.swing.JComponent;

public class objectView extends JComponent {

    private static final long serialVersionUID = 1L;

    public objectView()
    {

    }

    @Override
    public Dimension getMinimumSize() {
        return new Dimension(100, 100);
    }
    public Dimension setPreferredSize(int width, int height) {
        return new Dimension(width, height);
    }

    @Override
    public Dimension getPreferredSize() {
        return new Dimension(400, 300);
    }

    @Override
    public void paintComponent(Graphics g) {
         Graphics2D graphics2 = (Graphics2D) g;

        int margin = 0;
        Dimension dim = getSize();

        graphics2.setColor(Color.GRAY);
        graphics2.fillRect(margin, margin, dim.width - margin * 2, dim.height - margin * 2);

        BasicStroke fineStroke=new BasicStroke(1);
        graphics2.setStroke(fineStroke);
        graphics2.setColor(Color.red);
        drawObject fo = new FileObject();
        fo.setRoundRect(100, 100, 240, 160, 10, 10); //tried just incase its size was 0
        graphics2.fill(fo);
        graphics2.draw(fo);

    }
}

import java.awt.Rectangle;
import java.awt.geom.Rectangle2D;
import java.awt.geom.RoundRectangle2D;

public class drawObject extends RoundRectangle2D{

    public drawObject() {
        new RoundRectangle2D.Float(100, 100, 240, 160, 10, 10);
    setFrame(new Rectangle(100,100,100,100));

        // TODO Auto-generated constructor stub
    }

    @Override
    public Rectangle2D getBounds2D() {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public double getArcHeight() {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    public double getArcWidth() ...

Thank you all tons, it was the event listener but i also learned some other stuff!.

hmm all of that is good advice, and i did change it all but i still have the same problem. It actually seems to be the jbutton event is called twice. Adding 2 items to the list instead of just 1.

If i do :

public void actionPerformed(ActionEvent e) {

        if (e.getSource() == printbutton) 
        {
            System.out.println("triggered");
            this.validate();

        }

    }

instead of my add to list function then it prints the line triggered twice instead of just once, per button click.... im unsure why

Hello,
Iv recently been having trouble with a java project im working on as i need a button to add a sentence to a Swing list box. The problem im having is it uses an observable class and an observer.
Fundamentally the list adds the elements to an array in an observable class and the observer is class uses this array and adds them to the list box. The problem im having is it adds twice as many as the number of times you click the button :

public void update(Observable o, Object arg) {

        updatelist();
    }

    public void updatelist()
    {
        this.model = new DefaultListModel();
        this.List= new JList();

        this.List = new JList( this.observerlink.getlist() );
        // above gets array of elements from other class

        this.scrolllist = new JScrollPane(logList);
        drawGUI();
        this.validate();
    }

    public void testregnum(String item)
    {
        if(this.observerlink.getMatch(item)!=null && !this.observerlink.suspendedpermit(item))
        {
            observerlink.addLog("works");

        }
        else if(this.lnkVehicle_list.getMatch(item)!=null && this.lnkVehicle_list.suspendedpermit(item))
        {
            observerlink.addLog("doesent work");
        }
    }

    public void actionPerformed(ActionEvent e) {

         if(e.getSource()==addtolist) //check for reg number
         {
            testString();
            this.repaint();
         }

     }

These are the functions im using attached to a button. Ultimately they just add a string in an array inside class observerlink. It then uses this array as storage incase there are multiple windows. The only problem is when it updates it adds each item in the array twice to the list!

Any help in understanding or fixing this problem would be appreicated :)

Iv been developing a parser using java, however due to testing on multiple machines i have errors now on one machine i corrected as the machine was using jdk/jre v1.6, and on my newer machine jdk/jre 1.7

The question i have is, what are the implications of using the String in a case statement in v1.7 vs the use of a series of if conditions that i implemented in java 1.6?

Will a String casestatement as a finite state machine perform any better or worse than lets say an optimal series of if conditions?

Is there any benefit to one over the other when it comes to string comparison?

Example :

If(testString.equals("test"))
{
return true;
}

Switch(testString)
{
case "Test": return true;
default : break;
}

Should i use the if conditons only for backwards compatibility in java versions?
What is the best structure to use for large string based state machines?

Any advice on any of those points will be appreciated :)

Very helpful thanks, the book im using is compilers tools and techniques by Alfred V.aho, Ravi sethi, jeffrey D Ullman. It has been good for my overall understanding but there are parts i must admit that iv found guilty of going too deep before you fully understand the concept. Hence not understanding exactly what had to be done.

Thanks for the insight!

hello,
Iv recently been working on a compiler, so far i have a fairly decent working lexical analyzer and token scanner. So i can break down the code into a series of tokens and analyze them for correct strucutre.

I also understand how to generate x86 instructions. However im lost somewhere in between linking these two. The book i have describes the first and last step but seems to omit how i get from:

Have a series of tokens that are correct eg :

import java.whatever;
Keyword | package Name | seperator | class name | seperator

It does not explain how i go from having a series of tokens that are known to be in the correct structure of the language to outputing binary or even assembly language from these tokens. Must i scan through the tokens again and generate binary or an assembly statement for each line? Or should it be implemented in a higher level of abstraction and add to the total value's of an executeable class?

I know its kind of a broad question, but any help on the general logic and filling the gap between correct tokens to outputing binary would be good :) its not something im grasping from the book.

Hello,
Iv recently just started using javafx and i am struggling finding a way to access data from a controller class, at the moment i can do it using method.invoke, however it seems like more of a hack than a legitimate clean option of accessing data from a controller class.

try {
            URL location = getClass().getResource("newwindow.fxml");
            FXMLLoader fxmlloader = new FXMLLoader();
            fxmlloader.setLocation(location);
            fxmlloader.setBuilderFactory(new JavaFXBuilderFactory());
            Parent root = (Parent) fxmlloader.load(location.openStream());
            //above defines fxml class from the fxml file

            Stage stage = new Stage();
            Scene scene = new Scene(root);
            stage.setScene(scene);
            stage.show();
            //above gets stage from fxml file

             Method m = fxmlloader.getController().getClass().getMethod("getrows");
             System.out.println(m.invoke(fxmlloader.getController()));
        }
        catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) 
        {
            Logger.getLogger(EngineEditorController.class.getName()).log(Level.SEVERE, null, ex);
        }    

the above is how i am accessing the controller class method getrows() at the moment, im looking for a cleaner way either via fxml somehow or a way to pass data to the parent controller, i.e new file window is called from my main window. The controller class code is like so :

public class newWindowController implements Initializable {

    @FXML private Button okbutton;
    @FXML private Button cancelbutton;

    private int rowreturn; //used to return the number of items from controller
    private int columnreturn;

    @FXML
    private void handleOkButtonAction(ActionEvent event) throws IOException {

        System.out.println("connected");
    }

    public int getrows()
    {

      return rowreturn;  
    }

If anyone knows if this is the correct way to access data from a controller class or knows a better way any help would be appreciated, it doesent seem to be well documented by oracle yet...

my bad, i was setting canvas size based on fxml values that are 0 on initialize. Just incase anyone has had a similar problem.

hey,

Im having a problem adding a javafx Canvas node to the scrollpane node. Im using the .setcontent(canvas) method of the scrollpane and there are no syntax errors. The Scrollpane does expand in width (hbar appears longer) but it still looks empty.

I know the canvas is working correctly as if i add it directly using root.getchildren.add(canvas) it appears no problem.

Does javafx have a problem adding the canvas to a scrollpane? If not could anyone provide a very simple example on how to do it. And if so do you know of any alternatives?

Javafx 2.2 is the version im using.

Hello,
Im looking for a way to construct a scale-able 2d list or something of the sort.
What i have so far is an array

int [][] mydata = new int[6][4];

The problem is in my editor i wont know how long to make the array as people are going to be able to add and remove elements. Naturally i tried to implement 2 lists but realized right away it was the same as a 2d array.

List<Integer> column = new ArrayList<Integer>();
List<Integer> row = new ArrayList<Integer>();

What data type should i use to implement a structure that allows me to add elements to it at run time without constructing and copying an entirely new array with its size + 1 every time an element is to be added?

I have seen examples of 2d lists and arraylists but they seem syntactically confusing and imo wouldnt lend themselves well to maintainability... so any help would be nice :)

thanks, thats what i thought when i tried it originally and found it not to be serializeable. Quite annoying but ill try the image icon thing thanks!

hello,
Iv been trying to write a java program to read an image from a list of images in a file I.E:

  • File
  • Filename
  • Image1
  • Filename
  • Image2
  • Filename
  • Image3

The problem i am having is that the filename's are string objects followed by an image. So i was wondering if anyone could point me in the right direction to read the file i have written.

public class imageloader {
    String name;
    BufferedImage image;

    public imageloader(String url) 
    {
        try {

            FileInputStream saveFile = new FileInputStream(url);

            try {

                ObjectInputStream restore = new ObjectInputStream(saveFile);
                this.name = (String) restore.readObject();
                this.image = ImageIO.read(restore);

                System.out.println(this.name);

            } catch (IOException e) {

                e.printStackTrace();
            } catch (ClassNotFoundException e) {

                e.printStackTrace();
            }

        } catch (FileNotFoundException e) {

            e.printStackTrace();
        }

    }

}

This is how i am how i am saving the file

try{  
            FileOutputStream saveFile=new FileOutputStream("testfile");
            ObjectOutputStream save = new ObjectOutputStream(saveFile);
            // Now we do the save.
            save.writeObject(this.name);
            ImageIO.write(image, "png", saveFile);
            // Close the file.
            save.close(); // This also closes saveFile.
            }

Currently it throws no errors, but does not seem to actually read the data back into the buffered image. Any Ideas?

Hey,
Im looking for the cleanest way to scan through a text file and remove symbols only if they meet certain conditions.
So far i have been using the Scanner, but it removes them regardless and i was looking for the best way of providing conditions like those for comments

remove - //to end of the line
or - /remove until it finds another /

Should i provide these inside lots of if conditions or does scanner provide a neater way to do something like this? or maybe using a case statement?

public static String Stripsymbols(String line) {

        String strippedline="";
        String symbols = ".+;<>-=,*{}()";
        String search = null;

        for (int i = 0; i < symbols.length(); i++) // while not at end of line
        {

            search = "" + symbols.charAt(i); // add operator to search for

            if (line.contains(search)) // if operator found in line
            {
                line = line.replaceAll("\\W", " "); //remove symbol and replace with empty
                //used to be line = line.replaceALL(search, " ");

            }
        }

        strippedline=line;
        return strippedline;
    }

Thats my code so far, a few redundancies but im more or less still trying to figure out the best way to provide it lots of variant conditionals for the symbols, all this does is remove the symbols, i need it to remove for example both slashes // to the end of the line etc or both symbols /* to the next set in the same way a compiler might.

So yeh...best way to add conditionals to the remove statement ...

worked like a charm thanks

Hello i am having problems creating an update query, I have two tables both have an Title column and one table has an ID column. I want to take the ID from the table that has it when the titles of both columns match one of the titles against any of the others for example :

ID    Title          |  Title
1      Book1         |   Book3    ID 3
2      Book2         |   Book2    ID 2
3      Book3         |   Book4    ID 4
4      Book4         |   Book3    ID would be 3

So when one of the titles in the right table matches any of the ones on the left it takes the left tables ID and updates my 3rd Empty table's ID list and inserts that ID into it.

UPDATE Table3.newone p, Table1 a, Table2 b
INNER JOIN Table1
ON b.Title = a.Title
SET p.ID = a.ID
WHERE a.Title = b.Title

I tried this, but it doesent quite work, i always get an error about: Unknown column 'a.Title' in 'on clause'
Even though all the tables have a Title column and have data in it and i have used the Title column in other queries without problems. So any help solving this task would be appreciated :)

hmm thanks adam i think it nearly works but i seem to be getting this error:

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from TableA a

inner join Tableb b
on a.ItemName = b.ItemName' at line 3

dunno why it says its wrong...

i mean, only the ID column is empty, the item name column has data in both, with some being similar so i want only the elements with the same name to copy their ID's if that makes sense.

yes that works but i still dont have the condition
since i need to make sure the item names are the same so it doesent assign one a wrong ID if other data is inserted. thanks though

Some example data is :
TableA:

**ItemName****ID**
   CD         2
   Curtains   8
   Screen     10
   Desk       5     

TableB:

**ItemName****ID**
   CD         
   Curtains  
   Screen     
   Desk   

I want to compare item names so if tableA.ItemName = tableB.Itemname i copy its id into tableB. Note tableB will be empty up until this point im doing this whilst creating the tables. ANy help would be good. I tried mikes way but to no avail.

Hello, im a beginner at sql and i am struggling at comparing data from one table to another and then copying other data.
*I have 2 tables both of which have 2 columns with the same name lets call them tableA and tableB.

  • tableA has a column id and tableb has a columnid
  • and i want to insert the item name thats in tableA into the empty column in tableB

    INSERT INTO tableb (itemname)
    SELECT
    tableA.itemName,itemA.ID as a_role,tableB.ID as b_role
    FROM tableA,tableB
    WHERE a_role=b_role

But this throws me an error saying : #1054 - Unknown column 'a_role' in 'where clause'
Anyone any idea how to accomplish this seemingly simple task? Iv spent a long time googling solutions and i done think im far away from an answer but any help would be nice :)

Hello,
iv looked around google and have found it is possible to put an applet into a jframe. The problem i am having is that my applet is to be hosted online, what i want is to take the applet that is online and display it from a swing or awt front end. Can anyone link me or tell me if it is possible to make a jframe download/embed the applet via url into a jframe or generic window?