-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2e5d818
Showing
11 changed files
with
149 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package KBManipulation; | ||
import java.awt.*; | ||
import java.awt.event.KeyAdapter; | ||
import java.awt.event.KeyEvent; | ||
|
||
public class KBmanipulation extends KeyAdapter{ | ||
public void keyPressed(KeyEvent e) | ||
{ | ||
if (e.getKeyCode()== KeyEvent.VK_Q) | ||
System.out.println("Key Q pressed!"); | ||
} | ||
|
||
public static void switcChar(int button){ | ||
Toolkit toolkit = Toolkit.getDefaultToolkit(); | ||
try { | ||
Thread.sleep(100); | ||
} catch (InterruptedException e) { | ||
Thread.currentThread().interrupt(); | ||
} | ||
switch (button){ | ||
case KeyEvent.VK_EXCLAMATION_MARK: | ||
toolkit.setLockingKeyState(KeyEvent.VK_BACK_SPACE, Boolean.TRUE);; | ||
try { | ||
Thread.sleep(100); | ||
} catch (InterruptedException e) { | ||
Thread.currentThread().interrupt(); | ||
} | ||
toolkit.setLockingKeyState(KeyEvent.VK_BACK_SPACE, false); | ||
toolkit.setLockingKeyState(KeyEvent.VK_1,true); | ||
try { | ||
Thread.sleep(100); | ||
} catch (InterruptedException e) { | ||
Thread.currentThread().interrupt(); | ||
} | ||
toolkit.setLockingKeyState(KeyEvent.VK_1,false); | ||
break; | ||
} | ||
|
||
}/* | ||
public void keyTyped(KeyEvent ke) { | ||
return ke.getKeyCode(); | ||
}*/ | ||
|
||
|
||
public static void capsLockRandomize(boolean on) { | ||
Toolkit toolkit = Toolkit.getDefaultToolkit(); | ||
try { | ||
Thread.sleep(100); | ||
} catch (InterruptedException e) { | ||
Thread.currentThread().interrupt(); | ||
} | ||
if (on) | ||
toolkit.setLockingKeyState(KeyEvent.VK_CAPS_LOCK, Boolean.TRUE); | ||
else | ||
toolkit.setLockingKeyState(KeyEvent.VK_CAPS_LOCK, Boolean.FALSE); | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import javax.imageio.ImageIO; | ||
import javax.swing.*; | ||
import java.awt.*; | ||
import java.awt.event.ActionEvent; | ||
import java.awt.event.ActionListener; | ||
import java.awt.event.KeyEvent; | ||
import java.awt.image.BufferedImage; | ||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
import static KBManipulation.KBmanipulation.capsLockRandomize; | ||
|
||
|
||
public class gui implements ActionListener { | ||
private boolean trigger; | ||
private JLabel label; | ||
private JFrame frame; | ||
private JPanel panel; | ||
private String strButton="Start flaming"; | ||
private SwingWorker worker; | ||
JButton button=new JButton(strButton); | ||
public gui(){ | ||
frame=new JFrame(); | ||
button.addActionListener(this); | ||
label=new JLabel(); | ||
panel=new JPanel(); | ||
|
||
//panel.setBorder(BorderFactory.createEmptyBorder(50,50,20,50)); | ||
//panel.setLayout(new GridLayout(5,1)); | ||
try { | ||
BufferedImage myPicture = ImageIO.read(new File("assets/main.png")); | ||
JLabel picLabel = new JLabel(new ImageIcon(myPicture)); | ||
//picLabel.setMinimumSize(new Dimension(500,500)); | ||
panel.add(picLabel); | ||
} | ||
catch (IOException exception){} | ||
Color c = new Color(133, 23, 1); | ||
JPanel secondPanel = new JPanel(); | ||
secondPanel.setBackground(c); | ||
secondPanel.add(button); | ||
panel.setBackground(c); | ||
frame= new JFrame(); | ||
//frame.setLayout(new BorderLayout(50,50)); | ||
//panel.setMinimumSize(new Dimension(500,500)); | ||
|
||
frame.add(panel,BorderLayout.CENTER); | ||
frame.add(secondPanel,BorderLayout.PAGE_END); | ||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | ||
frame.setTitle("flame keyboard"); | ||
frame.pack(); | ||
frame.setVisible(true); | ||
|
||
} | ||
//231527 | ||
public void jButtonActionPerformed(java.awt.event.ActionEvent evt) { | ||
trigger=!trigger; | ||
strButton=trigger?"Start flaming":"stop flaming"; | ||
if (getWorker().getState().equals(SwingWorker.StateValue.STARTED)) { | ||
worker.cancel(true); | ||
worker = null; | ||
} else { | ||
getWorker().execute(); | ||
} | ||
} | ||
public static void main(String[] args){ | ||
new gui(); | ||
} | ||
private SwingWorker getWorker() { | ||
worker = worker == null ? worker = new SwingWorker() { | ||
@Override | ||
protected Object doInBackground() throws Exception { | ||
while (true) { | ||
capsLockRandomize(Math.random()<0.5); | ||
//if (Math.random()<0.5) | ||
//switcChar(keyTyped()); | ||
Thread.sleep(100); | ||
} | ||
} | ||
} : worker; | ||
return worker; | ||
} | ||
|
||
@Override | ||
public void actionPerformed(ActionEvent e) { | ||
jButtonActionPerformed(e); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
public class main { | ||
public static void main(String[] args){ | ||
new gui(); | ||
} | ||
} |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.