Welcome, Guest
You have to register before you can post on our site.

Username/Email:
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 2,800
» Latest member: DavidIrova
» Forum threads: 856
» Forum posts: 3,643

Full Statistics

Online Users
There are currently 4 online users.
» 0 Member(s) | 1 Guest(s)
Bing, Google, Yandex

Latest Threads
Looking for Adventure? Fi...
Forum: Random Discussion
Last Post: iHOMEz
11-16-2024, 09:18 PM
» Replies: 0
» Views: 471
Prettys Womans in your to...
Forum: Random Discussion
Last Post: iHOMEz
10-30-2024, 07:45 AM
» Replies: 0
» Views: 748
Prettys Womans in your ci...
Forum: Random Discussion
Last Post: iHOMEz
10-26-2024, 10:50 AM
» Replies: 0
» Views: 780
Beautiful Womans from you...
Forum: Random Discussion
Last Post: iHOMEz
10-19-2024, 02:48 PM
» Replies: 0
» Views: 880
Prettys Womans in your ci...
Forum: Random Discussion
Last Post: iHOMEz
10-06-2024, 05:00 PM
» Replies: 0
» Views: 1,044
Womans from your city - V...
Forum: Random Discussion
Last Post: iHOMEz
07-28-2024, 10:26 AM
» Replies: 0
» Views: 1,415
Supreme Сasual Dating - A...
Forum: Random Discussion
Last Post: iHOMEz
06-14-2024, 11:28 AM
» Replies: 0
» Views: 1,843
Beautiful Womans in your ...
Forum: VB.NET
Last Post: iHOMEz
06-09-2024, 09:23 PM
» Replies: 0
» Views: 1,644
Hangman in Rust
Forum: Other
Last Post: brandonio21
02-04-2018, 11:14 AM
» Replies: 2
» Views: 20,637
How to: Search files from...
Forum: VB.NET
Last Post: brandonio21
11-25-2017, 12:55 PM
» Replies: 1
» Views: 15,954

 
  PIN Program
Posted by: WitherSlayer - 01-09-2013, 08:37 PM - Forum: Java - No Replies

Pretty much the same as my password program http://bpforums.info/viewtopic.php?f=23&...c0f07db121


[code2=java]import javax.swing.JOptionPane;
public class Codeword {

public static void PIN(){
String PIN = "2995";//This is the PIN
String input = (JOptionPane.showInputDialog("Insert PIN:"));// This is the question asked

if (input.equals(PIN)){
JOptionPane.showMessageDialog(null, "Access Granted");//If you get it right
JOptionPane.showMessageDialog(null, "This is the information:BLAH BLAH BLAH BLAH BLAH BLAH");//The information
}else{
JOptionPane.showMessageDialog(null, "Access Denied");//If you get it wrong nothing happends
}
}[/code2]
The PIN right now is 2995

Print this item

  Password Program
Posted by: WitherSlayer - 01-09-2013, 08:26 PM - Forum: Java - Replies (2)

This program will ask the person for a password and if they get it right the will be shown some info. Fully commented!
[code2=java]import javax.swing.JOptionPane;
public class password {

public static void password (){
String password = "Potato";//This is the actual password
String input = (JOptionPane.showInputDialog("Insert Password:"));// This is the question asked

if (input.equals(password)){
JOptionPane.showMessageDialog(null, "Access Granted");//If you get it right
JOptionPane.showMessageDialog(null, "This is the information:BLAH BLAH BLAH BLAH BLAH BLAH");//The information

}else{
JOptionPane.showMessageDialog(null, "Access Denied");//If you get it wrong nothing happens
}
}[/code2]

p.s. The password right now is Potato

Print this item

  What is required to run the Java Framework?
Posted by: Derek275 - 01-07-2013, 10:58 AM - Forum: Java - Replies (1)

Like, is it written in a language that can run from the computer itself, or does it have to have an operating system like Windows or Mac? Like, can I write a bootloader and in the end open the Java Framework and be able to run .jar files on this system?

Print this item

  JFrames and JTabbedPanes
Posted by: Derek275 - 01-04-2013, 05:03 PM - Forum: Java - No Replies

What I am trying to do is make a program that, when a person clicks a button, it'll add a tab page to the JTabbedPane, and add another JFrame to the tab page. I think I know how to do it, by using

Code:
JTabbedPane.addTab(otherClassWithJFrame);

If this won't work, can anyone tell me otherwise, and how would I make it where 'otherClassWithJFrame' had no title bar? Any help will be greatly appreciated. Thank you and have an amazing day!

Print this item

  One of my first object oriented programs
Posted by: WitherSlayer - 01-03-2013, 07:19 PM - Forum: Java - Replies (1)

Copy these to codes into different eclipse classes
[code2=java]public class carPetrol
{

int tPetrol = 0;

public carPetrol(){

}
public carPetrol(int petrolAmount){
tPetrol = petrolAmount;
}



public void fillTank(int amount){
tPetrol = tPetrol + amount;

}
public void drive(int amount){
tPetrol = tPetrol - amount;

}
public int meterReading(){
return tPetrol;
}

}[/code2]

You will need to run the second program for this to work.

[code2=java]public class carPetrolTest {

public static void main(String[] args){
carPetrol petrolTank = new carPetrol(0);
petrolTank.fillTank(100);
petrolTank.drive(20);
System.out.println(petrolTank.meterReading() + " litres of gas remaining");
}
}[/code2]

Print this item

  Why are all the topics on the last page unavailable?
Posted by: WitherSlayer - 01-03-2013, 05:19 PM - Forum: Java - Replies (1)

Why are all the topics for java on the last page unavailable? <!-- s:?: --><img src="{SMILIES_PATH}/icon_question.gif" alt=":?:" title="Question" /><!-- s:?: -->

Print this item

  COD: Which is the best?
Posted by: WitherSlayer - 01-03-2013, 05:00 PM - Forum: Gaming - Replies (2)

COD. There are so many CODs now that it is hard to choose which one to buy.

Print this item

  Editable Label
Posted by: brandonio21 - 01-03-2013, 11:28 AM - Forum: Code Snippets - Replies (2)

This is more of a control than a code snippet, but I wanted to share my "editable label" control anyway.

The premise behind this control is the idea that users should be able to view and edit information; however, the ability to edit should remain non-intrusive. This is especially useful for people like on-phone tech-support who often need to view information but very rarely need to edit it.

The control consists of the following items
-A FlowLayoutPanel
-Two Labels
-A TextBox

Here is the code behind the control:
[code2=vbnet]Public Class ChangableLabel
'============================================================================
'ChangableLabel class created by Brandon Milton (brandonio21)
'This class was created specifically for a tutorial on the BrandonioProductions YouTube channel
' You can find this channel at: <!-- m --><a class="postlink" href="http://youtube.com/BrandonioProductions">http://youtube.com/BrandonioProductions</a><!-- m -->
'Discussion of this class is held at BP Forums
' A direct link to the thread: <!-- l --><a class="postlink-local" href="http://bpforums.info/viewtopic.php?f=22&t=745">viewtopic.php?f=22&t=745</a><!-- l -->
'Feel free to use this class in any way, but please remember to credit the author somewhere in the application
'=============================================================================

Public Property IdentifierText As String
'This property allows us to change the text of the first label when objectilized (sp?)
Get
Return lbl_identifier.Text
End Get
Set(value As String)
lbl_identifier.Text = value
End Set
End Property
Public Property InformationText As String
'This property allows us to change the text of the second label when objectilized (sp?)
Get
Return lbl_information.Text
End Get
Set(value As String)
lbl_information.Text = value
End Set
End Property

Private Sub lbl_information_MouseDoubleClick(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles lbl_information.MouseDoubleClick
'Here we want the textbox to appear
Dim oldLabel As Label = CType(flp_main.Controls.Item(1), Label) 'Save the label
flp_main.Controls.RemoveAt(1) 'Remove the label from the FlowLayoutPanel (so it can be replaced)

Dim txt_information As New TextBox 'Create textbox
Dim textboxSize As New Size(GetLabelWidth(oldLabel) + 25, txt_information.Size.Height) 'set size to ~ same size as label to avoid awkwardness
txt_information.Size = textboxSize 'set the size
txt_information.Text = oldLabel.Text 'set the text as old label text
AddHandler txt_information.KeyPress, AddressOf txt_information_keypress 'add handler to detect "enter" presses

flp_main.Controls.Add(txt_information) 'add the textbox to the FlowLayoutPanel
End Sub

Private Function GetLabelWidth(ByVal label As Label) As Integer
'This method gets the pixel width of labels
Dim g As Graphics = label.CreateGraphics() 'create graphix object for label to access info
Dim fontSize As SizeF 'var to save font sizes
fontSize = g.MeasureString(label.Text, label.Font) 'save the pixeled size of the label's text
Return fontSize.Width 'return the object (this is a function, afterall)
End Function
Private Sub txt_information_keypress(sender As Object, e As KeyPressEventArgs)
'this method is used to detect when the enter key is pressed on the textbox, return everything to normal state
If (e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Enter)) Then
Dim txt_information As TextBox = CType(sender, TextBox) 'save textbox var
Dim newLabel As New Label 'create new label
newLabel.AutoSize = True 'This gave lots of problems; allows for the control to resize with new label
newLabel.Text = txt_information.Text 'set the labels text to user input
AddHandler newLabel.MouseDoubleClick, AddressOf lbl_information_MouseDoubleClick
AddHandler newLabel.TextChanged, AddressOf ResizeControl
'^Adding handlers to resize the control and to detect double clicks, self-explanatory

'now we need to remove the textbox and add the label
flp_main.Controls.RemoveAt(1)
flp_main.Controls.Add(newLabel)


ResizeControl() 'resize the entire control to fit the new objects
End If
End Sub

Private Sub ResizeControl() Handles lbl_identifier.TextChanged, lbl_information.TextChanged
'this method resizes the control to fit the new objects and to make room for others around it

'create vars to hold size information
Dim identLabel As Label = CType(flp_main.Controls.Item(0), Label) 'save copy of first label
Dim infoLabel As Label = CType(flp_main.Controls.Item(1), Label) 'save copy of second label
Dim paddingSpace As Integer = 50

Dim width As Integer = GetLabelWidth(identLabel) + GetLabelWidth(infoLabel) + paddingSpace 'add all the widths!
Me.Size = New Size(width, Me.Size.Height) 'set the new size
End Sub


End Class[/code2]

Here is a quick screenshot of the control in action:
[attachment=2]<!-- ia2 -->changeablelabelconcept.png<!-- ia2 -->[/attachment]


Instead of typing out all of the information about this control, I have made a video tutorial that explains it. Watch it here:
[youtube]PcumZmVh4JM[/youtube]

Download the project here:
[attachment=1]<!-- ia1 -->TextBoxChangeControlTut.zip<!-- ia1 -->[/attachment]

Download only the control resources here:[attachment=0]<!-- ia0 -->ChangableLabel.zip<!-- ia0 -->[/attachment]



Attached Files Thumbnail(s)
   

.zip   TextBoxChangeControlTut.zip (Size: 72.03 KB / Downloads: 647)
.zip   ChangableLabel.zip (Size: 4.33 KB / Downloads: 647)
Print this item

  Count 100
Posted by: WitherSlayer - 01-03-2013, 02:21 AM - Forum: Java - Replies (2)

This is more of an explanatory program than a practical. It will count to 100 and show you when it it finished.
[code2=java]import java.util.Scanner;
public class New {

static Scanner input = new Scanner(System.in);
public static void main(String[]args){
countNumber();}


public static void countNumber(){
int i = 0;
while (i <= 100){//The while statement says that this will repeat 100 times
System.out.println(i);
i++;
if(i == 101){
System.out.println("I now equals 100");


}
}
}
}[/code2]
p.s. Sorry that it does not tell you exactly what is doing

Print this item

  RandomNumberGenerator
Posted by: WitherSlayer - 01-03-2013, 02:09 AM - Forum: Java - Replies (3)

This code will generate 100 random numbers (can be changed) from 0 to 6. Then it will count how many of each number there was. This is a take on Brandon's Random Number Generator on YouTube

------------------------------------------------------
[code2=java]import java.util.Random;
public class GnrtngRndmNmbrs {

public static void main(String[] args){
int one = 0;
int two = 0;
int three = 0;
int four = 0;
int five = 0;
int six = 0;
int nill = 0;
int i = 0;
/*To change the amount of random numbers generated
* change the statement below from
* while (i <= 100); to
* while (i <= YourAmountOfNumbers);
*/
while (i <= 100){
Random rnd = new Random();


System.out.println(rnd.nextInt(7));


if ((rnd.nextInt(7) > 0.99) & rnd.nextInt(7) < 1.1){
one = one + 1;
}
if ((rnd.nextInt(7) > 1.99) & rnd.nextInt(7) < 2.1){
two = two + 1;
}
if ((rnd.nextInt(7) > 2.99) & rnd.nextInt(7) < 3.1){
three = three + 1;
}
if ((rnd.nextInt(7) > 3.99) & rnd.nextInt(7) < 4.1){
four = four + 1;
}
if ((rnd.nextInt(7) > 4.99) & rnd.nextInt(7) < 5.1){
five = five + 1;
}
if ((rnd.nextInt(7) > 5.99) & rnd.nextInt(7) < 6.1){
six = six + 1;
}
if (rnd.nextInt(7) < 0.1){
nill = nill + 1;
}
i++;
}

System.out.println("There were " + one + " ones");
System.out.println("There were " + two + " twos");
System.out.println("There were " + three + " threes");
System.out.println("There were " + four + " fours");
System.out.println("There were " + five + " fives");
System.out.println("There were " + six + " sixes");
System.out.println("There were " + nill + " zeros");
}

}[/code2]
------------------------------------------------------
Have fun! <!-- s:lol: --><img src="{SMILIES_PATH}/icon_lol.gif" alt=":lol:" title="Laughing" /><!-- s:lol: -->

Print this item