![](https://www.scienceforums.net/uploads/set_resources_1/84c1e40ea0e759e3f1505eb1788ddf3c_pattern.png)
![](https://www.scienceforums.net/uploads/set_resources_1/84c1e40ea0e759e3f1505eb1788ddf3c_default_photo.png)
Blacksage
-
Posts
3 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by Blacksage
-
-
I couldnt Find a topic like this in here so, Post your source code that only you have made dont steal anyone elses stuff. Say what language you did it in and what it dose.
Language: Java
Purpose: Simple 8 ball program
import java.awt.Color; import java.awt.event.ActionEvent; import java.util.Arrays; import java.util.List; import javax.swing.AbstractAction; import javax.swing.Action; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import com.jgoodies.forms.layout.CellConstraints; import com.jgoodies.forms.layout.FormLayout; public class CopyOfEightBall { public static void main(String[] args) { final JTextField question = new JTextField(); final List<String> list = Arrays.asList( "Yes", "My sources say no.", "Yes, in due time.", "Definitely not.", "You will have to wait.", "I have my doubts.", "Outlook so so.", "Looks good to me!", "Who knows?", "Looking good!", "Probably.", "Are you kidding?", "Go for it!", "Don't bet on it." ); Action askAction = new AbstractAction("Ask") { public void actionPerformed(ActionEvent e) { final int num = (int)(Math.random()*list.size()); question.setText(list.get(num)); } }; JButton ask = new JButton (askAction); FormLayout layout = new FormLayout("30dlu, 4dlu, 30dlu, 30dlu, min", "pref, 2dlu, pref, 2dlu, pref, 2dlu, pref"); layout.setRowGroups(new int[][] { { 1, 3, 5 } }); JPanel panel = new JPanel(layout); CellConstraints cc = new CellConstraints(); panel.add(new JLabel("Ask a Question"), cc.xy(1, 1)); panel.add(question, cc.xyw(3, 1, 3)); panel.add(ask, cc.xy(3,3 ) ); JFrame frame = new JFrame(); frame.setContentPane(panel); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setTitle("Finding Slope"); frame.pack(); frame.setBackground(Color.black); frame.setVisible(true); } }
Language: Java
Purpose: Do my some math homework and show the work
import java.awt.Color; import java.awt.event.ActionEvent; import javax.swing.AbstractAction; import javax.swing.Action; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import com.jgoodies.forms.layout.CellConstraints; import com.jgoodies.forms.layout.FormLayout; public class Coordinates { public static void main(String[] args) { final JTextField coordinateOneField = new JTextField(); final JTextField coordinateTwoField = new JTextField(); final JTextField answerField = new JTextField(); final JTextField step1 = new JTextField(); JTextField step2 = new JTextField(); step1.setEnabled(false); step2.setEnabled(false); answerField.setEnabled(false); Action sumAction = new AbstractAction("sum") { private static final long serialVersionUID = 0L; public void actionPerformed(ActionEvent e) { int[] coordinate1 = extractCoordinateFrom(coordinateOneField); int[] coordinate2 = extractCoordinateFrom(coordinateTwoField); step1.setText("m = " + "(" + coordinate2[1] + "-" + coordinate1[1] + ")" + "/" + "(" + coordinate2[0] + "-" + coordinate1[0] + ")"); answerField.setText("m = " + (coordinate2[1] - coordinate1[1]) + "/" + (coordinate2[0] - coordinate1[0])); } private int[] extractCoordinateFrom(JTextField textField) { String text = textField.getText().replaceAll("\\(|\\)", ""); String[] values = text.split(","); int[] numbers = new int[values.length]; for(int i = 0; i < values.length; ++i) { numbers[i] = Integer.parseInt(values[i]); } return numbers; } }; Action clearAction = new AbstractAction("Clear") { public void actionPerformed(ActionEvent e) { coordinateOneField.setText(""); coordinateTwoField.setText(""); step1.setText(""); answerField.setText(""); } }; JButton detailsButton = new JButton(sumAction); JButton clear = new JButton(clearAction); FormLayout layout = new FormLayout("pref, 4dlu, 50dlu, 4dlu, min", // columns "pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref"); layout.setRowGroups(new int[][] { { 1, 3, 5, 7, 9 } }); JPanel panel = new JPanel(layout); CellConstraints cc = new CellConstraints(); panel.add(new JLabel("Coordinate 1"), cc.xy(1, 1)); panel.add(coordinateOneField, cc.xyw(3, 1, 2)); panel.add(new JLabel("Coordinate 2"), cc.xy(1, 3)); panel.add(coordinateTwoField, cc.xyw(3, 3, 2)); panel.add(new JLabel("Step 1"), cc.xy(1,5)); panel.add(step1, cc.xyw(3,5,2)); panel.add(new JLabel("Answer"), cc.xy(1, 7)); panel.add(answerField, cc.xyw(3, 7, 2)); panel.add(detailsButton, cc.xy(1, 9)); panel.add(clear, cc.xy(3,9 )); JFrame frame = new JFrame(); frame.setContentPane(panel); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setTitle("Finding Slope"); frame.pack(); frame.setVisible(true); } }
Language: Java
purpose: Lets you type text and then lets you type in a new file name
that it will create and put the text in.
import java.awt.event.ActionEvent; import java.io.FileOutputStream; import java.io.IOException; import java.io.PrintStream; import javax.swing.AbstractAction; import javax.swing.Action; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextArea; import javax.swing.JTextField; import com.jgoodies.forms.layout.CellConstraints; import com.jgoodies.forms.layout.FormLayout; public class Dspbb { public static void main(String[] args) { final JTextArea numField = new JTextArea(""); final JTextField nameField = new JTextField(""); Action SubmitAction = new AbstractAction("Submit") { public void actionPerformed(ActionEvent e) { final String file2 = nameField.getText(); final String sum = numField.getText(); String[] lines = sum.split("\n"); FileOutputStream fout; try { fout = new FileOutputStream (file2); new PrintStream(fout).println(sum); fout.close(); } catch(IOException e1){ System.err.println("Unalbe to complete"); } } }; JButton submit = new JButton(SubmitAction); FormLayout layout = new FormLayout("pref, 4dlu, 50dlu, 4dlu, min", // columns "pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref"); layout.setRowGroups(new int[][] { { 1, 3, 5, 7, 9 } }); JPanel panel = new JPanel(layout); CellConstraints cc = new CellConstraints(); panel.add(submit, cc.xy(1, 1)); panel.add(nameField, cc.xy(3, 1)); panel.add(numField, cc.xy(1, 3)); JFrame frame = new JFrame(); frame.setContentPane(panel); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setTitle("Finding Slope"); frame.pack(); frame.setVisible(true); } }
0 -
I know alot of people who used limeWire and after words there computer just stop working, If you think about it its a really simple way to send and recieve virii
0
Post your Source
in Computer Science
Posted
Language: Java
Purpose: Simple calculator that not finished yet I just have most of the layout down.