Skip to content

Instantly share code, notes, and snippets.

@CaelumF
Last active November 5, 2016 01:29
Show Gist options
  • Save CaelumF/dc54a2b3082d7827ee24feb9a20ca094 to your computer and use it in GitHub Desktop.
Save CaelumF/dc54a2b3082d7827ee24feb9a20ca094 to your computer and use it in GitHub Desktop.
After exercise, working(simple) IRC client with JavaFX UI
|_|_|_|_|_|here is the complete IntelliJ project zip: http://www.filedropper.com/showdownload.php/javafxproject
This file contains the modifcations needed to be made to Controller.java after finishing the tutorial to make a basic JavaFX IRC Client.
Only Controller.java is changed, so I've omitted the other files.
---Adding pircbot to classpath---
Pircbot packages need to be added to the classpath. Which is easily done through IntelliJ by going to:
File > Project Structure > Libraries > + > From Maven...
and then put in:
pircbot:pircbot:1.5.0
Then click the search button(Shift + enter), wait for it to load, tick all the boxes and press ok.
Apply changes to the Project Structure and Pircbot is added to the classpath.
---no internet?---
If not everyone has internet to download Pircbot from Maven Central, you can download the jars on one pc, distribute them to those without internet and get them to:
1) Make a 'lib' folder inside project(but outside of src folder)
2) Copy jar(s) to 'lib'
3) Right click each jar and select "Add as Library..."
Lib layout example: http://i.imgur.com/zwsFuug.png
----from other gist----
File layout: http://i.imgur.com/dviIFhU.png
Other helpful links:
Pircbot site, with download: http://www.jibble.org/pircbot.php
Pircbot maven online: https://mvnrepository.com/artifact/pircbot/pircbot
Pircbot maven location: pircbot:pircbot:1.5.0
Scene Builder download page:http://gluonhq.com/labs/scene-builder/
Gist 1(expected tutorial completion result): https://gist.github.com/CaelumF/ac54faa10b801ab9af17f4fce2416a19
public class Controller extends PircBot implements Initializable{
@FXML
TextArea textArea;
@FXML
TextField textField;
public void onTextFieldAction(){
textArea.setText(textArea.getText() + "\n" + textField.getText());
sendMessage("##CoderdojoBots", textField.getText()); //Sends message
textField.clear(); // Clears input field
textArea.end(); //Scrolls to bottom of textArea
}
@Override protected void onMessage(String channel, String sender, String login, String hostname, String message){
super.onMessage(channel, sender, login, hostname, message);
textArea.setText(textArea.getText() + "\n" + message);
}
@Override public void initialize(URL location, ResourceBundle resources){
try{
setVerbose(true);
setName("TestBotadxz");
connect("irc.freenode.net");
joinChannel("##CoderdojoBots");
}catch(IOException e){
e.printStackTrace();
}catch(IrcException e){
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment