Jump to content

Blacksage

Members
  • Posts

    3
  • Joined

  • Last visited

Retained

  • Lepton

Blacksage's Achievements

Lepton

Lepton (1/13)

10

Reputation

  1. Language: Java Purpose: Simple calculator that not finished yet I just have most of the layout down. import java.awt.Color; 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 newCalc { public static void main(String[] args) { JTextField Field = new JTextField(""); JButton one = new JButton("1"); JButton two = new JButton("2"); JButton three = new JButton("3"); JButton four = new JButton("4"); JButton five = new JButton("5"); JButton six = new JButton("6"); JButton seven = new JButton("7"); JButton eight = new JButton("8"); JButton nine = new JButton("9"); JButton cero = new JButton("0"); JButton enter = new JButton("e"); JButton clear = new JButton("c"); JButton plus = new JButton("+"); JButton minus = new JButton("-"); JButton divide = new JButton("/"); JButton times = new JButton("x"); FormLayout layout = new FormLayout("25dlu, 1dlu, 25dlu, 1dlu, 25dlu, 1dlu, 25dlu, 25dlu, 40dlu", "pref, 1dlu, pref, 1dlu, pref, 1dlu, pref, 1dlu, pref"); layout.setRowGroups(new int[][] { { 1, 3, 5, 7, 9 } }); JPanel panel = new JPanel(layout); CellConstraints cc = new CellConstraints(); panel.add(Field, cc.xyw(1,1,7)); panel.add(one, cc.xy(1,3)); panel.add(two, cc.xy(3,3)); panel.add(three,cc.xy(5,3)); panel.add(divide, cc.xy(7,3)); panel.add(four, cc.xy(1,5 ) ); panel.add(five, cc.xy(3,5)); panel.add(six, cc.xy(5,5)); panel.add(minus, cc.xy(7,5)); panel.add(seven, cc.xy(1,7)); panel.add(eight, cc.xy(3,7)); panel.add(nine, cc.xy(5,7)); panel.add(plus, cc.xy(7,7)); panel.add(enter, cc.xy(1,9)); panel.add(cero, cc.xy(3, 9)); panel.add(clear, cc.xy(5, 9)); panel.add(times, cc.xy(7,9)); JFrame frame = new JFrame(); frame.setContentPane(panel); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setTitle("Calculator"); frame.pack(); frame.setBackground(Color.lightGray); frame.setVisible(true); } }
  2. 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); } }
  3. 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
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.