Results 1 to 12 of 12
  1. #1
    Deathslice is offline Member
    Join Date
    Jan 2015
    Location
    Miami, FL
    Posts
    86
    Rep Power
    0

    Default Suggestions on what libraries to use for my final project

    I'm planning to do a trivia based game of who wants to be a millionaire and I want the main screen to look like the one you see on this jpg http://i.ytimg.com/vi/WZucbmuv-_E/maxresdefault.jpg. What GUI libraries would be best suited for this?
    Last edited by Deathslice; 03-31-2015 at 02:27 PM.

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,717
    Rep Power
    17

    Default Re: Suggestions on what libraries to use for my final project

    I'm not sure what you mean by "best", but Swing is well documented and well known which maximizes your chance of help on forums like this.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    25

    Default Re: Suggestions on what libraries to use for my final project

    ... but JavaFX is its more modern replacement, and given time, will probably take over from Swing as the most popular Java GUI.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    Deathslice is offline Member
    Join Date
    Jan 2015
    Location
    Miami, FL
    Posts
    86
    Rep Power
    0

    Default Re: Suggestions on what libraries to use for my final project

    I'll try javaFX and come back once I have something to show for. Oh, and sorry for the late reply.

    edit: One final question, is there any libraries in net beans that I can use to incorporate some of the audio from who wants to be a millionaire. You know, the music that gets all dramatic as you get closer to the one million dollar question
    Last edited by Deathslice; 03-31-2015 at 02:29 PM.

  5. #5
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,143
    Rep Power
    14

    Default Re: Suggestions on what libraries to use for my final project

    This is the first result for googling "javafx audio": Incorporating Media Assets Into JavaFX Applications: Introduction to JavaFX Media | JavaFX 2 Tutorials and Documentation

    But I would highly recommend starting smaller. Make sure you have step one working perfectly before you move on to step two.
    How to Ask Questions the Smart Way
    Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
    Static Void Games forum - Come say hello!

  6. #6
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Suggestions on what libraries to use for my final project

    Quote Originally Posted by Deathslice View Post
    edit: One final question, is there any libraries in net beans
    Netbeans is only a development tool. You are looking for a Java library. If you google for "netbeans libraries" you'll not get the results you want.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  7. #7
    Deathslice is offline Member
    Join Date
    Jan 2015
    Location
    Miami, FL
    Posts
    86
    Rep Power
    0

    Default Re: Suggestions on what libraries to use for my final project

    ya I should have typed java libraries but no harm done.

    I guess the first simple step is create a static design of the game since the design is basically going to be a static image of the who wants to be a millionaire logo in the background with a set of four possible answers. The only thing that will ever change is the question and the answers which I could read from a file.
    Last edited by Deathslice; 03-31-2015 at 04:04 PM.

  8. #8
    Deathslice is offline Member
    Join Date
    Jan 2015
    Location
    Miami, FL
    Posts
    86
    Rep Power
    0

    Default Re: Suggestions on what libraries to use for my final project

    Alright I'm back to display what I've currently done so far as I said I would.

    Here is the code using javafx
    Java FX Code:
    package whowantstobeamillionairetriviagame;
    
    import java.io.File;
    import javafx.application.Application;
    import javafx.geometry.Insets;
    import javafx.geometry.Pos;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.scene.image.Image;
    import javafx.scene.image.ImageView;
    import javafx.scene.layout.Background;
    import javafx.scene.layout.Priority;
    import javafx.scene.layout.StackPane;
    import javafx.scene.layout.VBox;
    import javafx.scene.paint.Paint;
    import javafx.scene.shape.Rectangle;
    import javafx.scene.text.Font;
    import javafx.scene.text.FontWeight;
    import javafx.stage.Stage;
    
    public class WhoWantsToBeAMillionaireTriviaGame extends Application {
    
        private VBox menuLayout = new VBox();
    
        @Override
        public void start(Stage startingStage) throws Exception 
        {
            StackPane backgroundSettings = new StackPane();
    
            Image backgroundColor = new Image("http://1.bp.blogspot.com/-p0s06MBIx_U/T8zKIBZ24pI/AAAAAAAAA7Y/n8hMZfpRic0/s1600/dark+blue+wallpaper+10.jpg");
    
            ImageView background = new ImageView();
            background.setImage(backgroundColor);
    
            createMenuLayout();
    
            backgroundSettings.getChildren().addAll(background, menuLayout);
    
            Scene backgroundScene = new Scene(backgroundSettings);
            startingStage.setScene(backgroundScene);
    
            startingStage.setTitle("Who Wants to be a Millionaire");
            startingStage.show();
        }
    
        private VBox createMenuLayout() {
            menuLayout.setSpacing(20);
            menuLayout.setAlignment(Pos.TOP_CENTER);
    
            Image millionaireLogo = new Image(new File("MillionaireLogo1.PNG").toURI().toString());
    
            ImageView logoPicture = new ImageView();
            logoPicture.setImage(millionaireLogo);
            logoPicture.setPreserveRatio(true);
            logoPicture.setSmooth(true);
            logoPicture.setCache(true);
    
            menuLayout.getChildren().add(logoPicture);
    
            Button menuButtons[] = new Button[]{
                new Button("Play"),
                new Button("Options"),
                new Button("Help"),
                new Button("Exit")
            };
    
            for (int i = 0; i < 4; i++) 
            {
                menuButtons[i].setPrefSize(200, 30);
                Rectangle r = new Rectangle(200, 30, Paint.valueOf("346699"));
                r.setArcHeight(30);
                r.setArcWidth(30);
                menuButtons[i].setOnMouseEntered(e -> r.setFill(Paint.valueOf("0f69b4")));
                menuButtons[i].setOnMouseExited(e -> r.setFill(Paint.valueOf("346699")));
                menuButtons[i].setBackground(Background.EMPTY);
                menuButtons[i].setTextFill(Paint.valueOf("White"));
                menuButtons[i].setFont(Font.font("Serif", FontWeight.BOLD, 16));
                VBox.setMargin(menuButtons[i], new Insets(0, 0, 0, 8));
                VBox.setVgrow(menuButtons[i], Priority.ALWAYS);
                StackPane sp = new StackPane();
                sp.getChildren().addAll(r, menuButtons[i]);
                menuLayout.getChildren().add(sp);
            }
    
            return menuLayout;
        }
    
        public static void main(String[] args) {
            launch(args);
        }
    }
    What I'm done with currently is the main menu(This is one day's worth of work) and the next thing that I have set in my mind is to add the theme(the audio) of the show and play it as you start the program. Tell me how you think it look so far.
    Last edited by Deathslice; 04-07-2015 at 04:51 AM.

  9. #9
    Deathslice is offline Member
    Join Date
    Jan 2015
    Location
    Miami, FL
    Posts
    86
    Rep Power
    0

    Default Re: Suggestions on what libraries to use for my final project

    I'm done with the main menu as of today(Now I can starting working on the buttons). At this point I would like someone to look at my code and evaluate it's strong and weak points and what I could to eliminate those weak points.

    Here it is
    Java FX Code:
    package whowantstobeamillionairetriviagame;
    
    import java.io.File;
    
    import java.util.Optional;
    
    import javafx.application.Application;
    import javafx.application.Platform;
    
    import javafx.geometry.Insets;
    import javafx.geometry.Pos;
    
    import javafx.scene.Scene;
    import javafx.scene.control.Alert;
    import javafx.scene.control.Alert.AlertType;
    import javafx.scene.media.Media;
    import javafx.scene.control.Button;
    import javafx.scene.control.ButtonType;
    import javafx.scene.image.Image;
    import javafx.scene.image.ImageView;
    import javafx.scene.layout.Background;
    import javafx.scene.layout.Priority;
    import javafx.scene.layout.StackPane;
    import javafx.scene.layout.VBox;
    import javafx.scene.media.MediaPlayer;
    import javafx.scene.paint.Paint;
    import javafx.scene.shape.Rectangle;
    import javafx.scene.text.Font;
    import javafx.scene.text.FontWeight;
    import javafx.stage.Stage;
    
    public class WhoWantsToBeAMillionaireTriviaGame extends Application 
    {
        private VBox menuLayout;
        private MediaPlayer mediaPlayer;
        private final Button menuButtons[] = new Button[4];
    
        @Override
        public void start(Stage startingStage) 
        {  
            String fileName = checkFiles();
            
            if(!fileName.isEmpty())
            {
                showErrorMessage(fileName);
                Platform.exit();
                System.exit(0);
            }
            
            StackPane backgroundSettings = new StackPane();
    
            Image backgroundColor = new Image(new File("ImageFiles/BlueBackgroundColor.JPG").toURI().toString());
    
            ImageView background = new ImageView();
            background.setImage(backgroundColor);
    
            createMenuLayout();
    
            backgroundSettings.getChildren().addAll(background, menuLayout);
            
            menuButtons[3].setOnMouseClicked(e -> 
            {
                Alert exitConfirmation = new Alert(Alert.AlertType.CONFIRMATION, "Are you sure you want to exit this Application?");
                exitConfirmation.setTitle("Exit Application");
                exitConfirmation.setHeaderText("Confirm Exit");
                Optional<ButtonType> choice = exitConfirmation.showAndWait();
                if(choice.get() == ButtonType.OK)
                {
                    startingStage.close();
                }
            });
            
            playThemeIntro();
    
            Scene backgroundScene = new Scene(backgroundSettings);
            startingStage.setScene(backgroundScene);
      
            startingStage.setOnCloseRequest(e -> 
            {
                Alert exitConfirmation = new Alert(Alert.AlertType.CONFIRMATION, "Are you sure you want to exit this Application?");
                exitConfirmation.setTitle("Exit Application");
                exitConfirmation.setHeaderText("Confirm Exit");
                Optional<ButtonType> choice = exitConfirmation.showAndWait();
                if(choice.get() == ButtonType.OK)
                {
                    startingStage.close();
                }
                else
                {
                    e.consume();
                }
            });
            
            startingStage.setTitle("Who Wants to be a Millionaire");
            startingStage.show();
        }
        
        private void showErrorMessage(String file)
        {
            Alert errorAlert = new Alert(AlertType.ERROR);
            errorAlert.setTitle("Error");
            errorAlert.setHeaderText(null);
            errorAlert.setContentText("Couldn't find " + file + " in your project directory");
            errorAlert.showAndWait();
        }
        
        private String checkFiles()
        {
            File files[] = new File[3];
            String fileName = "";
            
            files[0] = new File("ImageFiles/BlueBackgroundColor.JPG");
            files[1] = new File("ImageFiles/MillionaireLogo1.PNG");
            files[2] = new File("AudioFiles/GameIntroTheme.MP3");
            
            for (File file : files) 
            {
                if (!file.exists()) 
                {
                    fileName += file.toString() + "  ";
                }
            }
            
            return fileName;
        }
        
        private void playThemeIntro()
        {
            Media gameIntroTheme = new Media(new File("AudioFiles/GameIntroTheme.MP3").toURI().toString());
            mediaPlayer = new MediaPlayer(gameIntroTheme);
            mediaPlayer.setAutoPlay(true);
            mediaPlayer.setVolume(0.1);
        }
    
        private VBox createMenuLayout() 
        {
            menuLayout = new VBox();
            menuLayout.setSpacing(20);
            menuLayout.setAlignment(Pos.TOP_CENTER);
    
            Image millionaireLogo = new Image(new File("ImageFiles/MillionaireLogo1.PNG").toURI().toString());
    
            ImageView logoPicture = new ImageView();
            logoPicture.setImage(millionaireLogo);
            logoPicture.setPreserveRatio(true);
            logoPicture.setSmooth(true);
            logoPicture.setCache(true);
    
            menuLayout.getChildren().add(logoPicture);
    
            menuButtons[0] = new Button("Play");
            menuButtons[1] = new Button("Options");
            menuButtons[2] = new Button("How to play the game");
            menuButtons[3] = new Button("Exit");
    
            for (int i = 0; i < 4; i++) 
            {
                menuButtons[i].setPrefSize(200, 30);
                Rectangle r = new Rectangle(200, 30, Paint.valueOf("346699"));
                r.setArcHeight(30);
                r.setArcWidth(30);
                menuButtons[i].setOnMouseEntered(e -> r.setFill(Paint.valueOf("0f69b4")));
                menuButtons[i].setOnMouseExited(e -> r.setFill(Paint.valueOf("346699")));
                menuButtons[i].setBackground(Background.EMPTY);
                menuButtons[i].setTextFill(Paint.valueOf("White"));
                menuButtons[i].setFont(Font.font("Serif", FontWeight.BOLD, 16));
                VBox.setMargin(menuButtons[i], new Insets(0, 0, 0, 8));
                VBox.setVgrow(menuButtons[i], Priority.ALWAYS);
                StackPane sp = new StackPane();
                sp.getChildren().addAll(r, menuButtons[i]);
                menuLayout.getChildren().add(sp);
            }
    
            return menuLayout;
        }
    
        public static void main(String[] args) 
        {
                launch(args);
        }
    }
    Last edited by Deathslice; 04-09-2015 at 12:17 AM.

  10. #10
    Deathslice is offline Member
    Join Date
    Jan 2015
    Location
    Miami, FL
    Posts
    86
    Rep Power
    0

    Default Re: Suggestions on what libraries to use for my final project

    Alright guys now I need suggestions. Given the code that I have on my latest post, how could I effectively manage going back and forth through different screens?

  11. #11
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: Suggestions on what libraries to use for my final project

    This article might help.
    It uses FXML to build the screens, but the logic is the same.
    One controller per screen and they are stacked (using a StackPane).
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  12. #12
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    25

    Default Re: Suggestions on what libraries to use for my final project

    Since this is now all about JavaFX, I'm moving the thread from New to Java.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Project Suggestions!!!
    By bankoner in forum New To Java
    Replies: 12
    Last Post: 10-11-2013, 08:39 PM
  2. Replies: 4
    Last Post: 04-09-2012, 06:56 PM
  3. Suggestions for project
    By Qsc in forum New To Java
    Replies: 3
    Last Post: 11-08-2011, 01:48 PM
  4. Suggestions for graphical libraries?
    By cullam in forum New To Java
    Replies: 7
    Last Post: 08-26-2011, 04:49 PM
  5. Suggestions for my Java-project?
    By shabbee in forum New To Java
    Replies: 1
    Last Post: 01-01-2009, 10:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •