Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!

Montana Burr

Greenhorn
+ Follow
since May 04, 2014
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 Montana Burr

Campbell Ritchie wrote:You should not start worrying about searching thirty objects; even the most inefficient search will run quickly for so few. Once you have 30000000 objects, then you will find out  whether your search algorithm is working correctly.
What do you know about search algorithms? Do you know which run in constant time, which in logarithmic time, which in linear time and which in quadratic time?
You should consider the following factors before searching:-
How often and you are going to run the search? How often are you going to add things to your collection? How long will it take to sort it?
Have you been through the Java™ Tutorials about collections? That might tell you something about searching.


I don't know too many search algorithms. The only algorithms I used are linear searching and binary searching.
The search will be run at the user's request.
I expect that items will be added infrequently. I want the searching to be performed as quickly as noticable.
Considering my particular use case, I'm considering using a Map with each object's name being the associated key.
One of the tutorials to which you linked mentioned streams, which have a filtering function that I was looking at earlier. Supposedly, I can create a Collection of any subtype, generate a stream by invoking the collection's stream() function, then proceed to run a filter. However, none of the Collection objects I tried (ArrayList & something else) had a stream() function, but perhaps this is because I'm using Android SDK 4.4.
4 years ago
What I want to do is create a collection of objects from which I can select one that meets a certain predicate.  For example, I need a collection of Person objects, and the primary function of the program involves picking the one whose name is "Mario Andretti".

For my personal use, I expect no more than 30 items in this collection.
4 years ago
I have an idea for a program. What this program will do is wait for the sound of a smoke alarm. If it hears a sound that resembles a smoke alarm's horn, it will alert the user (either via a notification sent to a cellphone or via email.)

The basic idea is to have the user train the program in a noiseless environment by going through the regular smoke alarm testing procedure (pressing "test" in the case of a single smoke detector, following the manual in the case of a burglar/fire alarm system.)
5 years ago

Paul Clapham wrote:

Montana Burr wrote:In Java, I feel like creating a subclass of JFrame just to accomplish what I set out to accomplish isn't a very good idea.



Yes, your intuition about GUI design is absolutely correct. You shouldn't create a subclass of JFrame to be your controller. Unfortunately you'll see a lot of bad Swing code which does exactly that, including code which is generated by various widely-known Java tools.

So yes, you should create a separate class which acts as the controller. That code should contain a reference to the JFrame, or at least to the GUI components which it controls, but it shouldn't BE a JFrame.



Thanks for the help!

Just to be clear, that means multiple classes: the one that has the main(), and another one that controls the JFrame.
5 years ago
What I want to do is have a label that is updated whenever an object gets some new, relevant data.

The way you do it in Java looks different from the way we do it in Objective-C. In Objective-C, we have what's known as a protocol. An Objective-C protocol is almost exactly like a Java "implementation." In Obj-C, if I want the user to see the address of where he is, I can have an object that gets the information and invokes a view controller's method; at that point, the view controller would then take the data passed to it and display the data in a label.

However, the view controller is an instance of a subclass of the bundled view controller class. In Java, I feel like creating a subclass of JFrame just to accomplish what I set out to accomplish isn't a very good idea.

I, therefore, ask for your help. Thank you!
5 years ago

Rob Spoor wrote:Use JMenuBar.



One thing I forgot to mention: I don't want the user to be opening/closing the menu (without closing the window.)
5 years ago
Hi,

I'm currently building a Java app. In this app, users are told that they are locked in a room, and that there is a key hidden in the room. The app is supposed to present the options in the form of a menu, from which the users select a location to "look in" first. I can create a JMenu, but I want to know how to make this JMenu appear in the same window as the label.

Here's what I have so far:

5 years ago
I'm creating a Dictionary class that has a few basic methods, including one for finding the definition of a word. Because there are multiple ways that s program can request the definition of a word (for example, the program could look it up on Wiktionary or on The Merriam-Webster Online Dictionary or in a database), I don't want any programmer to instantiate Dictionary. Instead, I want them to instantiate a subclass of Dictionary that is designed for querying the dictionary of his or her choice.

Also, all subclasses of Dictionary should have to define a predefined set of methods. Failure to meet this requirement should cause a compiler error.
6 years ago
I found the answer. If the JVM can't create a process because the program doesn't exist, it'll throw an IOException with an error code of 2. So the solution is to make my program attempt to launch the program in question, looking for an IOException.
6 years ago
I'm thinking the Scala compiler first converts the Scala code to Java code, then uses Java's Compiler API to have that code compiled.

Note that you will, in all probability, eventually use classes that came with your Scala installation. For example, a Map is a Scala collection, and therefore is not a Java Map.
6 years ago
Thank you, Jasper.

Jesper de Jong wrote:
What is exactly the purpose of this _MultikeyMap trait? A normal Map can also have multiple keys that refer to the same value, you don't need a special Map implementation for that.


Because I'd rather not type out multiple key-value pairs if each key is mapped to the same value.
6 years ago
I want to build a program that tells the computer to run a speech synthesizer. However, I want the program to see if the speech synthesizer is installed on the user's computer before the program tells the computer to run the synthesizer.

6 years ago
The Java applet documentation says than an applet that is run using JavaScript code is always treated as a sandboxed applet, regardless of whether or not the applet is configured to be a privileged applet.

Let's say I have a privileged applet, and this privileged applet has public methods. I also have a sandboxed applet that acts as a liaison between the applet and a JavaScript script. When the sandboxed applet gets called by the JavaScript code, will the privileged applet be treated as a sandboxed applet?
6 years ago
Here's my code:


This code doesn't work. Among other error messages, I get "value contains is not a member of Nothing." and "type mismatch; found: Unit required: Option."
6 years ago