• Breaking News

    Wednesday, January 22, 2020

    We have low and high level languages.. but what do you predict the successor to current high level languages will be/do? Ask Programming

    We have low and high level languages.. but what do you predict the successor to current high level languages will be/do? Ask Programming


    We have low and high level languages.. but what do you predict the successor to current high level languages will be/do?

    Posted: 22 Jan 2020 06:19 AM PST

    What we consider to be high level is certainly not the "highest" is it? What might the higher level languages of the future look like?

    submitted by /u/stexski
    [link] [comments]

    How does Mongoose Populate Work?

    Posted: 22 Jan 2020 05:22 PM PST

    So I'm learning how to use MongoDB with Mongoose and I've trying to understand how to reference between different Mongoose populations . I've read the documentation and several StackOverFlow/Medium articles about it, I understand how to implement it, but I don't understand how it works.

    For Example, let's say we have two schemas. One is UserSchema and it says

    var mongoose = require('mongoose'); var UserSchema = new mongoose.Schema({ name: String }); module.exports = mongoose.model("User", UserSchema); 

    and postSchema that says:

    var mongoose = require('mongoose'); var PostSchema = new mongoose.Schema({ title: String, postedBy: { type: mongoose.Schema.Types.ObjectId, ref: 'User' }, comments: [{ text: String, postedBy: { type: mongoose.Schema.Types.ObjectId, ref: 'User' } ] }); module.exports = mongoose.model("Post", PostSchema); 

    How does do the postSchema and userSchema know which proper _ObjectID to select?

    submitted by /u/cancerous_176
    [link] [comments]

    Is there a way to use TensorFlow 1.15 in Android Studio?

    Posted: 22 Jan 2020 01:31 PM PST

    I've trained a neural network in Google Colab using TensorFlow 1.15, exported the graph as a .pb file, and now I have Android Studio set up ready to use the network. (This is my first time using Android Studio or training a neural network so sorry if any of my questions are dumb.)

    But basically I get an error when trying to load the model, which a Google search suggests is due to me training the neural network in TF 1.15 and then trying to use TF 1.13 to load it in Android Studio. The solution was to simply change this in the Gradle file:

    implementation 'org.tensorflow:tensorflow-android:[INSERT CORRECT VERSION]' 

    However it seems I can't use TensorFlow 1.15, which is a problem as I could only get GPU support working with that version in Colab. Is there any way I can use TF 1.15? Or if anyone can offer any other solutions to my problem, I'd be happy to give more information on it (just thought it wasn't relevant to my main question.)

    submitted by /u/Dependent-Dig
    [link] [comments]

    What datastructure do you recommend for my use-case?

    Posted: 22 Jan 2020 01:20 PM PST

    I need direction or help with my use case

    I want fast access to my data it should be something like a multindex map

    Attributes: (for simplicity only 3 in reality more)

    PSEUCODECODE

    int goldvalue; stringarray start_moves[3]; stringarray second_moves[3]; //where I can do something like this: int value = map[goldvalue][start_moves][second_moves] //points to an integer value. 

    The problem with doing this with a map is I cant do something like this where I ignore all second_moves values and only want to consider the first two.

    map[goldvalue][start_moves][] 

    I mean I could just calculate the values for this/all cases but is there maybe a better way for this?

    Picture for illustration:

    https://imgur.com/a/tjbePDi

    submitted by /u/Menosa
    [link] [comments]

    How to create a program for grading a Logics course (truth table, proofs, etc).

    Posted: 22 Jan 2020 02:48 PM PST

    Hi. I am a newbie beginner programmer and wanted a project to start on by helping my Philosophy professor with writing a program that checks the answers for proofs, truth tables and such.

    I figured this would be a step for me to better understand the full scope of developing, knowing what hurdles I'll be facing, and knowing where or how to start.

    submitted by /u/RickyWho
    [link] [comments]

    Need help interfacing with ADC

    Posted: 22 Jan 2020 01:06 PM PST

    Hello all I could really use your kind knowledge to help me with interfacing my ADC for a project as I can't seem to get a valid output. I want to write a code that interfaces the ADC to microcontroller. Appreciate if you could spot and tell me my mistakes as my coding skills are pretty trash. I also took a photo of the oscilloscope trace between MISO (Ch 1) and MOSI (Ch 2) triggered by SCK because it looks really weird. Thanks :)

    ADC: AD7714YNZ

    MCU: MAX32630FTHR

    Oscilloscope Trace:

    https://drive.google.com/open?id=1GEytO1E00ro-cPkTSfL_-YPJMki_DG1H

    Here's the code below:

    #include "mbed.h" #include "max32630fthr.h" // for ADC (Configured for channels AIN1(+)/AIN6(-)) #define COMM_REG 0x00 //Communication Register #define MODE_REG 0x10 //Mode register #define FIL_HIGH_REG 0x20 //Filter High Register #define FIL_LOW_REG 0x30 //Filter Low Regiser #define TEST_REG 0x40 //Test Register #define DATA_REG 0x50 //Data Register #define ZER_SCALE_REG 0x60 //Zero-scale Calibration Register #define FULL_SCALE_REG 0x70 //Full-scale Calibration Register #define NUM_OF_SAMPLES 1001 uint32_t ADC_ReadReg(uint32_t reg); void ADC_WriteReg(uint32_t reg, uint32_t val); SPI spi(P5_1, P5_2, P5_0); //MOSI, MISO, SCK Serial pc(USBTX, USBRX); //Virtual communication to PC DigitalIn drdy(P3_1); int drdybit = drdy; DigitalOut rLED(P2_4), gLED(P2_5), bLED(P2_6); //Set RGB User LEDs int j; int main() { uint32_t reg = 0; uint32_t sta = 0; rLED = LED_OFF; bLED = LED_OFF; gLED = LED_OFF; //Initialise SPI Interface spi.format(8,3); //8-bit, Mode 3 (CLK idle state HIGH,Data sampled on rising edge, shifted on falling) spi.frequency(1000000); //1 MHz SCLK //Reset ADC and Registers //ADC_Reset(); /*Read current status and values of all registers */ reg = ADC_ReadReg(MODE_REG); pc.printf("Mode: 0x%X\n",reg); reg = ADC_ReadReg(FIL_HIGH_REG); pc.printf("Filter High: 0x%X\n",reg); reg = ADC_ReadReg(FIL_LOW_REG); pc.printf("Filter Low: 0x%X\n",reg); reg = ADC_ReadReg(DATA_REG); pc.printf("Data: 0x%X\n",reg); reg = ADC_ReadReg(ZER_SCALE_REG); pc.printf("Zero Scale: 0x%X\n",reg); reg = ADC_ReadReg(FULL_SCALE_REG); pc.printf("Full Scale Reg: 0x%X\n",reg); /*Initialise all ADC registers */ ADC_WriteReg(FIL_HIGH_REG, 0x61); /*Set bipolar operation, 24 bit word length, current boost ON, MCLK out enabled,0001 to Filter Select bits in Filter High Register, (0xD1 for Unipolar), (0x71 for Bipolar)(0x27 for Test Mode)*/ ADC_WriteReg(FIL_LOW_REG, 0x39); /*Write 00111001 to Filter Low Reg Filter High + Filter Low: 000100111001b = 313 dec*/ ADC_WriteReg(MODE_REG, 0x20); /*Set (0x38 Av = 64)(0x20 Av = 1), Initiate self-calibration (will revert to normal operation automatically burnout currents OFF, filter sync OFF (0x21 w/ filter sync)*/ for(int j=0; j<NUM_OF_SAMPLES; j++) { thread_sleep_for(100); while(!0x80){} //poll DRDY bit int outputcode = ADC_ReadReg(DATA_REG); pc.printf("output: 0x%X\t\tDRDY: %d\n", outputcode, drdybit); } pc.printf("Sampling stopped, No. of samples read: %d\n", j); // mbed runs continuous loop while(1) { //Blink blue LED bLED = !bLED; thread_sleep_for(500); } } /********************************************************************************** *Function: ADC_ReadReg *Description: Read a register from AD7714YNZ * ADC has 8-bit registers and 24-bit registers **********************************************************************************/ uint32_t ADC_ReadReg(uint32_t reg) { uint32_t data_length = 0; uint32_t register_value = 0; uint32_t rx_data[3] = {0, 0, 0}; // determine data length switch (reg) { // 8 bit result case COMM_REG: case MODE_REG: case FIL_HIGH_REG: case FIL_LOW_REG: case TEST_REG: data_length = 1; break; // 24 bit result case DATA_REG: case ZER_SCALE_REG: case FULL_SCALE_REG: data_length = 3; break; } // convert write address to read address reg |= 0x08; //Results in only the R/W bit changing // send location to comm register spi.write(reg); // get the data if (data_length == 3) { rx_data[0] = spi.write(0xFF); rx_data[0] <<= 16; rx_data[1] = spi.write(0xFF); rx_data[1] <<= 8; rx_data[2] = spi.write(0xFF); register_value = rx_data[2] | rx_data[1] | rx_data[0]; } else { register_value = spi.write(0xFF); } return (register_value); } /********************************************************************************** *Function: ADC_WriteReg *Description: Write to a register from AD7714YNZ * ADC has 8-bit registers and 24-bit registers ***********************************************************************************/ void ADC_WriteReg( uint32_t reg, uint32_t val ) { uint32_t data_length = 0; // determine data length switch (reg) { // 8 bit case COMM_REG: case MODE_REG: case FIL_HIGH_REG: case FIL_LOW_REG: case TEST_REG: data_length = 1; break; // 24 bit case DATA_REG: case ZER_SCALE_REG: case FULL_SCALE_REG: data_length = 3; break; } // send location to comm register spi.write(reg); // send the data if (data_length == 3) { spi.write ((val & 0x00FF0000) >> 16); spi.write((val & 0x0000FF00) >> 8); } spi.write(val & 0x000000FF); return; } 
    submitted by /u/6yearsolder
    [link] [comments]

    Password sanitization within stacktraces & errors

    Posted: 22 Jan 2020 02:02 PM PST

    We're currently running into an interesting problem regarding the sanitization of error logs being printed into our server logs. We have proper global error handling set up and have custom error messages that are sent back as responses from our OSGi java servlets.

    We use dockerized containers as server instances that are autoscaled, so we're thinking about setting up a log aggregator and storing our exceptions within a DB in the cloud, that way we can also track metrics about our exceptions and pinpoint how we could improve our development process to reduce certain types of errors, etc.

    I did a bit of research about how that should be done and I found this. The OWASP Logging sheet cheat. It mentions that passwords should never be logged among a few other things. That brings us to my question:

    How do I go about properly sanitizing my logs without using some janky text processing or manually covering up all the potential cases?

    Example stacktrace:

    pkg.exceptions.CustomException: some registration error ERROR: duplicate key value violates unique constraint "x_username_org_id_key" Detail: Key (username, org_id)=(SOME EMAIL, 1) already exists. Query: with A as (some query) insert into someTable (..values...) Parameters: [X, X, X, X, X, SOME_EMAIL, THE_PASSWORD] at somepkg.etc 

    This is a pretty common error with registration systems that happens due to username collisions. Sure there's ways that this specific case can be avoided by ensuring the username isn't taken before the insertion isn't attempted and handling that case separately, but that's just a single case among many others.

    After looking around to find a solution there doesn't seem to be an obvious way to solve the problem and I'm wondering if everyone out there has simply implemented their own version of a log sanitizer? We could simply purge the stacktrace if some troublesome strings are present, but that's not the best solution. Any suggestions?

    submitted by /u/ddunit
    [link] [comments]

    What standard SQL isolation levels do the SQLite isolation levels correspond to?

    Posted: 22 Jan 2020 01:14 PM PST

    Amazon alexa for computers, kinda..

    Posted: 22 Jan 2020 12:53 PM PST

    Ok, so i wanted to do something like amazon alexa but for computers, basicly it would be something you install, it will then automatically luanch at startup, easy but i got a problem for example lets say i say "alexa, what time is it?" in my mic i want something to appear on screen like 8:42 for example on top of everything but i dont know how to do that. I also want to attach an image to the text that will appear anyone can help me with that? Or how that is even called? And in what language should i do my project? Thanks!

    submitted by /u/2011Minecon
    [link] [comments]

    Python documentation in IDE

    Posted: 22 Jan 2020 12:11 PM PST

    Hi, I'm still pretty new to programming. I learned the basics of python and now I'm learning some data oriented libraries pandas, numpy, seaborn etc.

    My issue is there is no way I can remember all the arguments and how to use them, so I constantly check documentation and i'm googling different websites, but that seems very inefficient. I use pycharm community edition and there is this ctrl + q feature that has help for some functions, I found that you can insert links to external sources there for reference, but it works for some and not for others, eg.

    pandas: https://pandas.pydata.org/pandas-docs/stable/generated/{element.qname}.html does work

    seaborn: https://seaborn.pydata.org/reference/{module.name}.{element.name}.html#{module.name}.{element.name} does not

    Is there any way to access documentation easier or should I just have all the documentations open at all times? Wrong IDE maybe? I used Rstudio for a while at university and it seemed crazy good at that.

    submitted by /u/wizzy83
    [link] [comments]

    3d mouse Interface

    Posted: 22 Jan 2020 11:43 AM PST

    I got some ideas about a diy Spacemouse thingamajig, my question is, I have a generic joystick thing with 6 individual axis, that shows up under windows, without any special drivers. Also many programs have a feature that you can use generic spacemice so that you don't need a specific add-on for your specific Spacemouse. So what would it take to remap the axis of the joystick to the axis of a generic Spacemouse ( sort of a translator joystick -> Spacemouse protocol ). Can anyone point me in the right direction?

    Thank you all for your help.

    submitted by /u/vogel25
    [link] [comments]

    Having trouble with a JavaScript excercise

    Posted: 22 Jan 2020 10:59 AM PST

    I am trying to complete a CodeWars Kata that asks me to write a function that returns the sum of two smallest integer in a given array.

    Here's how I wrote it: ``` function sumTwoSmallestNumbers(numbers) {

    var smallest1 = numbers[0]; for (let i = 0; i < numbers.length; i++) { if (numbers[i] < smallest1) { smallest1 = numbers[i]; } } var smallest2 = numbers[0]; for (let j = 0; j < numbers.length; j++) { if (numbers[j] != smallest1 && numbers[j] < smallest2) { smallest2 = numbers[j]; } } return smallest1 + smallest2; } ```

    This works as intended but when the smallest value is in position 0, both smallest1 and smallest2 gets assigned with that exact same small value.

    I can't seem to identify the problem.

    submitted by /u/Singha360
    [link] [comments]

    Does python have while, elwhile and else?

    Posted: 22 Jan 2020 09:03 AM PST

    I know python has if, elif and else. Does python have while, elwhile and else?

    submitted by /u/beni55
    [link] [comments]

    Is there any way to create a loop in C without using while, do while, for, or goto?

    Posted: 22 Jan 2020 07:10 AM PST

    My assignment is to form a simple list without using any of these. No combination of Google searches is getting me anywhere. I saw that there is a for-each loop but that apparently doesn't exist in C.

    For reference the output looks something like this:

    1. x equals 10.
    2. x equals 9.

    And so on

    submitted by /u/Afabledhero1
    [link] [comments]

    I'm at a loss here - why doesn't my background url image show up?

    Posted: 22 Jan 2020 06:39 AM PST

    Code Pic - https://imgur.com/a/8Bbzili

    What it looks like right now - https://imgur.com/a/TT5y6vE

    What it SHOULD look like - https://imgur.com/a/CGOpxzh

    I checked the path to the image, should be fine. Spelling - also checked (but maybe I'm wrong on both).

    Been fiddling for half an hour now.

    submitted by /u/moltenw
    [link] [comments]

    simple doubt

    Posted: 22 Jan 2020 06:32 AM PST

    I'm a freshman at college, going to finals in programming, and i found this while studying and I have no idea what this means, help me out pls.

    for(... : ...) {....}

    what does the : means?

    submitted by /u/afonso18
    [link] [comments]

    Why isnt there a professional basketball team of half robot players and half Human players? Are robots unable to beat Humans while obeying the rules? Or are Humans just not interested in watching professional basketball players get beat?

    Posted: 22 Jan 2020 02:36 PM PST

    I rarely watch basketball but would be interested to watch a game thats part Humans and part robots.

    submitted by /u/BenRayfield
    [link] [comments]

    Why does a server sign a cookie?

    Posted: 22 Jan 2020 02:45 AM PST

    Beginner in coding

    Posted: 22 Jan 2020 02:38 AM PST

    Could you guys help me with a bit of a very basic code that I tried writing and it gets stuck after the first input? Please don;t judge I'm just getting started.

    include<iostream>

    using namespace std;

    int main()

    {

    int sum,n,i,a,media;

    sum=0, i=0;

    cout<<"Input umber of values n=";cin>>n;

    while(i<n);

    {

    cout<<"Input values a=";cin>>a;

    sum=sum+a;

    i++;

    }

    media=sum/n;

    cout<<"Media este";media;

    }

    submitted by /u/TheKnightSpinner
    [link] [comments]

    Quick Question

    Posted: 22 Jan 2020 06:16 AM PST

    Hi,

    I was wondering if someone could help provide some context to the question below:

    "What would cause an image to face bandwidth issue on a low traffic site?'

    submitted by /u/AddisonRoad
    [link] [comments]

    How to build a low-code web-app builder?

    Posted: 22 Jan 2020 02:26 AM PST

    Please no Christopher Nolan references.

    Could you please help me out with advice - I want to build a low-code web-app builder but can't find any hints/info on how to get started or which programming languages/frameworks to use. (so far I know how to build on react.js)

    submitted by /u/Grishagev
    [link] [comments]

    Script to manipulate browser page

    Posted: 22 Jan 2020 01:28 AM PST

    Hey!

    Id like to try to make some kind of script that does something to a webpage im currently browsing. Not a page that i host or can access in any other way than browsing. For example id like to be able to click buttons. Of course i would have to know the selector for the buttons or what event or function they trigger. But im not sure what to look up to learn how to manipulate a browser like this. Any tips?

    submitted by /u/NinRejper
    [link] [comments]

    Integration with REST API dilemma - question

    Posted: 22 Jan 2020 01:20 AM PST

    Hello. I need to integrate website with REST API, but i'm not sure if I want to do it correctly.

    Let say API provides cars for sale. Each car has properties like door number, color, engine type, fuel type. I can ask API by different makes - fords, chevrolets etc. I can also ask API to search by attributes.

    The thing is I want to create dropdown filters. API let me to ask about possible properties. But how to update filters basing on choices?

    Scenario 1: I select chevrolet. I would like to update different filters to show only available options. If we have only red Chevrolets in API - color filter should show only red now, different options should disappear.

    I know how I can do it: User select chevrolet -> request to PHP script that connects to API -> search chevrolets, and loop them to find colors -> return to browser. I get results by pages (30 offers per page) - what if there is 200 offers to loop by? Wouldnt that be slow? 200/30 = 7 requests to API

    Is it good way of thinking? Should PHP process API request or should I do it in JS? (let say website is PHP based anyway)

    What is proper way of doing this type of integration?

    submitted by /u/flav404
    [link] [comments]

    error in javafx project

    Posted: 22 Jan 2020 12:40 AM PST

    Hi, so I am creating a javafx project and everything worked fine until I was forced to chang it into maven project, which is something I never worked with. Please help, I am getting the following error:

    Exception in Application start method

    Exception in thread "main" java.lang.reflect.InvocationTargetException

    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke([NativeMethodAccessorImpl.java:62](https://NativeMethodAccessorImpl.java:62)) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke([DelegatingMethodAccessorImpl.java:43](https://DelegatingMethodAccessorImpl.java:43)) at java.base/java.lang.reflect.Method.invoke([Method.java:567](https://Method.java:567)) at java.base/sun.launcher.LauncherHelper$FXHelper.main([LauncherHelper.java:1051](https://LauncherHelper.java:1051)) 

    Caused by: java.lang.RuntimeException: Exception in Application start method

    at [javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)](https://javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)) at [javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)](https://javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)) at java.base/java.lang.Thread.run([Thread.java:835](https://Thread.java:835)) 

    Caused by: java.lang.NullPointerException: Location is required.

    at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl([FXMLLoader.java:3230](https://FXMLLoader.java:3230)) at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl([FXMLLoader.java:3194](https://FXMLLoader.java:3194)) at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl([FXMLLoader.java:3163](https://FXMLLoader.java:3163)) at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl([FXMLLoader.java:3136](https://FXMLLoader.java:3136)) at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl([FXMLLoader.java:3113](https://FXMLLoader.java:3113)) at javafx.fxml/javafx.fxml.FXMLLoader.load([FXMLLoader.java:3106](https://FXMLLoader.java:3106)) at sample.Main.switchScene([Main.java:42](https://Main.java:42)) at sample.Main.start([Main.java:31](https://Main.java:31)) at [javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)](https://javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)) at [javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)](https://javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)) at [javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)](https://javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)) at java.base/java.security.AccessController.doPrivileged([AccessController.java:389](https://AccessController.java:389)) at [javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)](https://javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)) at [javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)](https://javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)) at [javafx.graphics/com.sun.glass.ui.win.WinApplication.\_runLoop](https://javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop)(Native Method) at [javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)](https://javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)) 

    ------------------------------------------------------------------------------------------------------------------------------

    Part of code:

    Main.java:

    package sample;
    import javafx.application.Application;
    import javafx.fxml.FXMLLoader;
    import javafx.scene.Parent;
    import javafx.scene.Scene;
    import javafx.stage.Stage;
    import sample.views.login.LoginController;
    import java.io.IOException;
    public class Main extends Application {
    public static final String WINDOW_TITLE = "Project";
    public static final int WINDOW_WIDTH = 1200;
    public static final int WINDOW_HEIGHT = 700;
    public static Stage currentStage;
    public static Scene previousScene;

    u/Override
    public void start(Stage primaryStage) throws Exception {
    currentStage = primaryStage;
    currentStage.setTitle(WINDOW_TITLE);
    switchScene(LoginController.RESOURCE_MAIN_PATH);
    currentStage.show();
    }

    public static void switchScene(String resourcePath) {
    if (currentStage.getScene() != null) {
    previousScene = currentStage.getScene();
    }

    try {
    Parent root = FXMLLoader.load(Main.class.getResource(resourcePath));
    Scene scene = new Scene(root, Main.WINDOW_WIDTH, Main.WINDOW_HEIGHT);
    currentStage.setScene(scene);
    } catch (IOException e) {
    e.printStackTrace();
    }
    }
    }

    LoginController.java:

    package sample.views.login;
    import javafx.event.ActionEvent;
    import javafx.fxml.FXML;
    import javafx.scene.control.Button;
    import javafx.scene.control.Label;
    import javafx.scene.control.PasswordField;
    import javafx.scene.control.TextField;
    import sample.Controller;
    import sample.Main;
    public class LoginController {
    public static final String RESOURCE_MAIN_PATH = "views/login/login.fxml";
    private Label isConnected;
    u/FXML
    private TextField input_login;
    u/FXML
    private PasswordField input_password;
    u/FXML
    private Button button_submit;
    u/FXML
    private void handleSubmitAction(ActionEvent event) {
    Main.switchScene(Controller.RESOURCE_PATH);
    }
    }

    login.fxml:

    <?xml version="1.0" encoding="UTF-8"?>
    <?import javafx.scene.control.*?>
    <?import javafx.scene.layout.*?>
    <GridPane fx:controller="sample.views.login.LoginController" stylesheets="@login.css" xmlns:fx="http://javafx.com/fxml" xmlns="http://javafx.com/javafx" alignment="CENTER">
    <VBox GridPane.rowIndex="0" GridPane.columnIndex="0" spacing="32" alignment="CENTER">
    <Label text="Hello" id="title\_label"/>
    <VBox spacing="8">
    <VBox spacing="2">
    <Label text="Login:"/>
    <TextField fx:id="input\_login" styleClass="input"/>
    </VBox>
    <VBox spacing="2">
    <Label text="Hasło:"/>
    <PasswordField fx:id="input\_password" styleClass="input"/>
    </VBox>
    </VBox>
    <Button text="Zaloguj" fx:id="button\_submit" styleClass="button" onAction="#handleSubmitAction"/>
    </VBox>
    </GridPane>

    pom.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>groupId</groupId>
    <artifactId>test</artifactId>
    <dependencies>
    <dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>8.0.19</version>
    </dependency>
    </dependencies>
    <version>1.0-SNAPSHOT</version>
    <properties>
    <maven.compiler.release>11</maven.compiler.release>
    </properties>
    <build>
    <pluginManagement>
    <plugins>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.8.1</version>
    </plugin>
    </plugins>
    </pluginManagement>
    </build>
    </project>

    submitted by /u/ChilledShark
    [link] [comments]

    No comments:

    Post a Comment