-
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
1 parent
d601a03
commit ab489a0
Showing
3 changed files
with
92 additions
and
121 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 |
---|---|---|
@@ -1,12 +1,10 @@ | ||
# Changes | ||
All notable changes to this project will be documented in `CHANGELOG.md`. | ||
## Added | ||
Nothing has been added. | ||
* `PopupHandler` - stops me from duplicating a bunch of code just for settings. | ||
|
||
## Modified | ||
* Fixed the percentage going over 100% | ||
* Changed thread code a little bit | ||
* Added a "Hits" counter for successfully scanned servers | ||
* Thread handling has been modified to be (potentially) faster and use less lines of code. | ||
|
||
## Removed | ||
Nothing has been removed. | ||
* Hits feature |
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
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,63 @@ | ||
package com.stupidrepo.mcscanner; | ||
|
||
import javax.swing.JButton; | ||
import javax.swing.JFrame; | ||
import javax.swing.JLabel; | ||
import javax.swing.JOptionPane; | ||
import javax.swing.JTextField; | ||
import javax.swing.WindowConstants; | ||
import java.awt.BorderLayout; | ||
import java.awt.event.WindowEvent; | ||
|
||
public class PopupHandler { | ||
private final String message; | ||
private final String defaultText; | ||
private final String buttonText; | ||
|
||
public String responseText; | ||
|
||
public PopupHandler(String message, String defaultText, String buttonText) { | ||
this.message = message; | ||
this.defaultText = defaultText; | ||
this.buttonText = buttonText; | ||
} | ||
|
||
public void showAndWait() { | ||
JFrame threadFrame = new JFrame("MCScanner"); | ||
threadFrame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); | ||
threadFrame.setSize(500, 125); | ||
threadFrame.setLayout(new BorderLayout()); | ||
|
||
JLabel threadLabel = new JLabel(this.message); | ||
threadLabel.setHorizontalAlignment(0); | ||
|
||
threadFrame.add(threadLabel, "North"); | ||
|
||
JTextField threadField = new JTextField(this.defaultText); | ||
threadField.setHorizontalAlignment(0); | ||
|
||
threadFrame.add(threadField, "Center"); | ||
|
||
JButton threadButton = new JButton(this.buttonText); | ||
threadFrame.add(threadButton, "East"); | ||
|
||
threadButton.addActionListener(e -> { | ||
this.responseText = threadField.getText(); | ||
threadFrame.setVisible(false); | ||
threadFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); | ||
threadFrame.dispatchEvent(new WindowEvent(threadFrame, 201)); | ||
}); | ||
|
||
threadFrame.setVisible(true); | ||
|
||
while(threadFrame.isVisible()) { | ||
try { | ||
Thread.sleep(100); | ||
} catch (InterruptedException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
threadFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); | ||
} | ||
} |