salvin francis

+ Follow
since Jan 12, 2009
salvin likes ...
Eclipse IDE Google Web Toolkit Java
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by salvin francis

MigLayout sounds interesting. Thanks for sharing that 
4 days ago
The Brain** language you mentioned is under the classification of Esoteric programming languages. Wiki:
Here's a quote:

Wiki wrote:An esoteric programming language (sometimes shortened to esolang) is a programming language designed to test the boundaries of computer programming language design, as a proof of concept, as software art, as a hacking interface to another language (particularly functional programming or procedural programming languages), or as a joke. The use of esoteric distinguishes these languages from programming languages that working developers use to write software. Usually, an esolang's creators do not intend the language to be used for mainstream programming, although some esoteric features, such as visuospatial syntax,[1] have inspired practical applications in the arts. Such languages are often popular among hackers and hobbyists.

Usability is rarely a goal for esoteric programming language designers—often it is quite the opposite. Their usual aim is to remove or replace conventional language features while still maintaining a language that is Turing-complete, or even one for which the computational class is unknown.

I am not sure that you can call it a troll language, but it definitely is not readable and hence I do not see much practical uses for it. Having said that, it's a great topic for "software art". I have come across Chef language that is quite interesting too. Maybe you can come up with a secret message party trick or similar using such languages

Knute Snortum wrote:* With the UI in the code, you have to be a programmer to change the UI.

True. A programmer would make the changes

Knute Snortum wrote:* With a complex UI, the code becomes almost unreadable.  Then how do you maintain the code outside of modifying the code?  Does the WYSIWYG recreate the UI by reading the code?

I meant to point out that there is a WYSIWYG for Swing. Personally, I have written UI code from scratch (I worked on a project 8 years ago and it had a fairly complex UI). Working with a team we had come up with certain patterns like grouping all "add()" methods together and at the end of a method just before the return statement. E.g. :
We broke up the code into small methods which return a container for each part on the screen.

Knute Snortum wrote:* With the UI outside of the code, you can set different access rights and allow non programmers to tweak the UI.  Things like adding fields would still be a programmer's job, but changing the look and feel of the UI would be possible.

True, this would not be easily done with Swing.

Having a UI config outside code seems good, I have the following questions:
1. How would you approach designing a complex UI with conditions over what would be shown or hidden. Does the FXML contain conditional java logic too ?
2. Does it support designing a UI that falls back gracefully (e.g. a combobox instead of a single-select list when screen is resized to a smaller dimension) ?

Point #2 above is a very huge issue I faced. We had made a ui with a tree to the left and a series of containers to the right depending on what was selected in the tree. When resizing the screen, some panels should automatically "collapse" into corners so that they don't take up the complete view. Some panels had to change components, some panels had to even change layouts, some had to expand to grab the full screen and dominate the view. A user-friendly UI is very difficult to make and it's very difficult to keep all users happy with a UI. But we achieved all this programmatically, If an xml config could do all this, it would have been really great !
5 days ago

Marius Hille wrote:Yep, I did and though I do not understand it completely yet, it works. So I imagine it like layers or objects to remain in OO-speak resp. Java-speak.

Just as a side note, if you are new to java, GUI coding is not the best way to learn. You would end up spending more time getting a component to work the way you want it to and less time understanding how java works.

I think the paradigm of a Panel / Container is common to most UI frameworks. You add a set of components to some lightweight container which acts as a "section" on the screen. This is not specific to java. Even languages like Visual Basic (I used it almost 14 years ago, so my memory might be a bit hazy) had the concept of containers to add your components with and then add that to a main window.

Swing (and AWT) has this cool concept of Layouts which manage the way a component is laid out and resized. Certain containers such as JFrame and JPanel have a default layout (but you can change it)
JFrame's default layout is a BorderLayout. A border layout has 5 areas where you can add a component  : NORTH, SOUTH,EAST,WEST and CENTER.
By default, the add() method adds a component to it's CENTER and the it 'stretches' to fill the full container if there are no components to NORTH, SOUTH, EAST,WEST
Hence, when you add a panel it stretches to the full JFrame, try adding using frame.add(p, BorderLayout.NORTH); and you'll see the difference.

Next, JPanel's default layout is FlowLayout. A FlowLayout does not have a restriction on the number of components. It's behavior is to add components one by one and when there's no more place, wrap it to the next line.

You can change a container's layout using setLayout method. If you want to learn GUI coding in Java, you need to know layouts. You can get away using fully absolute positioning using: setLayout(null); but that's no fun.

I strongly suggest learning core java before diving into GUI coding. Hope this helps.
6 days ago
  • Swing is pure java code so there's no FXML
  • It has integrated IDE support with a WYSIWYG, but that generates java code
  • There is a binding between data and component and an update made to the data object is reflected in the component UI

  • These are the things I feel are common to your list.

    Attached : Screenshot of Eclipse and generated code :
    6 days ago

    Marius Hille wrote:I tried this but still just getting an empty non-functional frame.

    Your code still misses the part where you add the panel to your frame, did you try the code I shared ?

    Marius Hille wrote:So probably just using AWT-technology is not sufficient anymore and I should use JavaFX or Swing, right.

    "sufficient" would probably not be the right word to describe it,  I would say its outdated. I would leave it to others to suggest about Swing vs JavaFx since I do not know much about JavaFx.

    As a side note, thanks for sharing your code this time instead of a screenshot of code.
    1 week ago
    I looked at your code a bit more in-depth today and the following questions came to my mind :

  • Why can one not instantiate World ? The only way you are allowing is via a empty() method which generates according to a fixed SIZE of 10
  • Why is World square ? (as in number of rows=number of columns)

  • I see that you have implemented this as a fixed world with cells which are either Alive or Empty. The way I approached this was that I made an implementation which only kept Alive cells. There were no "Empty" cells.
    Actually this is what fits in the real world philosophy too. In real life, we would observe a 'petri dish' with some cells. These cells would grow/die depending on various conditions, the 'petri dish' is their domain/world. With the implementation of "Empty" it looks like the world has some "slots" where a cell can reside or not.

    Just food for thought

    1 week ago
    I ran that program and it just printed a huge log of dots and zeros !!!
    Even a simple JFrame with a single textarea would be great.

    Good job on that code, I liked it. I am glad to see that your glider "wraps-around" the world.

    minor suggestions: Maybe World.SIZE could have an access modifier (probably public) ?

    1 week ago
    You've not messed up. Your ascii art is good.
    Like campbell Carey said, your code needs a main method. Also the method should be written like this:

    Java is case sensitive, so "system.out.println" wont work. Here's how your program looks when it runs:

    I guess you were going for a halloween theme
    1 week ago

    Marius Quizmaster wrote:so it is not possible at all to even you the AWT library? or should it work nonetheless just with a work around?

    Hi Marius,
    As others mentioned, AWT is an ancient technology. In-fact, swing too is quite old, javafx is now used to make desktop based applications.

    Here's an example code that is similar to your screenshot:

    Please paste your code in code tags instead of screenshot. A screenshot has the disadvantage that someone reading your code cannot run it without typing it all-over again. You are literally asking the person to help you to re-type the code for you. Issues such as misplaced commas, etc. cannot be easily guessed in a screenshot.

    1 week ago

    Piet Souris wrote:Try  -1 % 2.

    The negative realm is something I always avoid

    Yes, negative numbers break my statement.
    1 week ago
    I haven't used intelij much recently, If I could guess, maybe these are compilation issues.

    If the code compiles fine in folder1 and no longer compiles in folder2, maybe intelij does not take care of package renaming when you move the files ?

    Can you post the actual code for Numbers if there are any compilation issues ?
    1 week ago
    Another useful example of % is when you divide by 2:

    Notice a pattern here ?  If a number is divisible by 2, it will return 0 and if not, it will always return 1. This can be used determine if a number is odd or even.

    Another cool feature is that the mod will always return a number from 0 to N-1 where N is the divisor. Eg. if your divisor is 3, the mod will be always either 0 or 1 or 2.
    This can be used to distribute elements in a Round robin manner. Here's a simple program to demonstrate that:


    1 week ago
    Hi jon,

    Mod is a fun thing to do in coding when it comes to numbers, there are a few unique features which I'll discuss after the example below

    (Hope my ascii art is good )

    Notice that 34 is the last 2 digits from 1234

    So, any number % 10 will give you the last digit, and %100 will get last 2 digits and so on ...

    1 week ago

    salvin francis wrote:
    Feel free to criticize

    I just read that OP mention the DRY principle... My code looks horrible now
    2 weeks ago