Skip to content

Instantly share code, notes, and snippets.

View k33ptoo's full-sized avatar
💻
Anything frontend & Kotlin

Amos Chepchieng k33ptoo

💻
Anything frontend & Kotlin
View GitHub Profile
protected override CreateParams CreateParams
{
get
{
const int CS_DROPSHADOW = 0x20000;
CreateParams cp = base.CreateParams;
cp.ClassStyle |= CS_DROPSHADOW;
cp.ExStyle |= 0x02000000; // Turn on WS_EX_COMPOSITED
return cp;
}
@k33ptoo
k33ptoo / Movable JavaFX Window.java
Created July 31, 2017 07:57
Renders a borderless/underdecorated window movable/dragable
/*
* The MIT License
*
* Copyright 2017 keeptoo.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@k33ptoo
k33ptoo / Move.java
Created August 17, 2017 16:38
A snip for making underdecorated Swing Jframes movable
int xy,xx;
//replace sidepane with your control/container to which you want to move
private void sidepaneMouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_sidepaneMouseDragged
// TODO add your handling code here:
int x = evt.getXOnScreen();
int y = evt.getYOnScreen();
this.setLocation(x - xx, y - xy);
}//GEN-LAST:event_sidepaneMouseDragged
private void sidepaneMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_sidepaneMousePressed
@k33ptoo
k33ptoo / JavaFX TC .css
Created September 11, 2017 11:22
Contains basic css for customizing a TableView and Charts.
.table-view .column-header,
.table-view .column-header-background .filler {
-fx-background-color: #6622CC;
}
.table-view .column-header .label{
-fx-text-fill: white;
-fx-font-weight: bold;
-fx-alignment: CENTER_LEFT;
}
.table-view .cell{
@k33ptoo
k33ptoo / Move2.java
Created November 2, 2017 15:59
Make underdecorated window movable in eclipse using WindowBuilder
JPanel panel = new JPanel();
panel.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent arg0) {
xx = arg0.getX();
xy = arg0.getY();
}
});
panel.addMouseMotionListener(new MouseMotionAdapter() {
@k33ptoo
k33ptoo / AndroidManifest.xml
Last active December 15, 2017 08:05
Firebase android show notification on new item added using a service
<application>
<service
android:name=".updates.BackroundLUpdateService"
android:enabled="true"
android:exported="true"></service>
</application>
@k33ptoo
k33ptoo / Table.fxml
Created July 1, 2018 07:39
Adding data to Tableview JavaFX
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="563.0" prefWidth="1102.0" xmlns="http://javafx.com/javafx/9.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="home.controllers.StudentsController">
<TableView fx:id="tbData" layoutX="20.0" layoutY="192.0" prefHeight="349.0" prefWidth="1066.0" stylesheets="@../css/fullpackstyling.css" AnchorPane.bottomAnchor="22.0" AnchorPane.leftAnchor="20.0" AnchorPane.rightAnchor="16.0" AnchorPane.topAnchor="192.0">
<columns>
<TableColumn fx:id="studentId" prefWidth="75.0" text="StudentId" />
<TableColumn fx:id="firstName" prefWidth="75.0" text="First Name" />
<TableColumn fx:id="lastName" prefWidth="75.0" text="Last Name" />
</columns>
<columnResizePolicy>
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
</columnResizePolicy>
@k33ptoo
k33ptoo / StudentController.java
Last active July 1, 2018 07:47
Adding data to Tableview JavaFX
import home.model.StudentsModel;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty;
public class StudentsModel {
private SimpleIntegerProperty studentId;
private SimpleStringProperty firstName;
private SimpleStringProperty lastName;
@k33ptoo
k33ptoo / HintJTextFields.java
Last active April 3, 2019 10:39
A custom hint creator for Java Swing JTextField
//on init components
//add your TextFields Here
JTextField[] tfs = {jTextField1,jTextField2};
setHintText(tfs);
private void setHintText(JTextField[] tfs) {
for (JTextField jtf : tfs) {
jtf.addFocusListener(new FocusListener() {
@Override