Click here to Skip to main content
15,887,746 members
Home / Discussions / Java
   

Java

 
QuestionJava Parallel Port Interfacing [modified] Pin
Fahimul718-Mar-10 9:49
Fahimul718-Mar-10 9:49 
AnswerRe: Java Parallel Port Interfacing Pin
Richard MacCutchan18-Mar-10 22:56
mveRichard MacCutchan18-Mar-10 22:56 
GeneralRe: Java Parallel Port Interfacing Pin
Fahimul719-Mar-10 0:27
Fahimul719-Mar-10 0:27 
GeneralRe: Java Parallel Port Interfacing Pin
Richard MacCutchan19-Mar-10 1:20
mveRichard MacCutchan19-Mar-10 1:20 
GeneralRe: Java Parallel Port Interfacing Pin
Fahimul719-Mar-10 3:24
Fahimul719-Mar-10 3:24 
QuestionFirst Fit Help Pin
Blackberry8917-Mar-10 10:15
Blackberry8917-Mar-10 10:15 
AnswerRe: First Fit Help Pin
TorstenH.18-Mar-10 2:14
TorstenH.18-Mar-10 2:14 
QuestionJava Conversions Pin
James WG Murphy17-Mar-10 7:34
James WG Murphy17-Mar-10 7:34 
I am currently writing a program which will perform binary to decimal, decimal to binary, hexadecimal to decimal, decimal to hexadecimal conversions, 1's compliment, 2's compliment, and show the list of boolean algebra rules.

I have created the GUI however, I cannot figure out how to make the Jbuttons generate the coding needed for a binary to decimal conversion of the input in a JTextField. Please help me. The code is below:


package swing1;

/**
 *
 * @author James
 */
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.lang.*;
import java.io.*;


public class swing {

    public static void main (String[] args) {

        JFrame frame = new JFrame("Computer Architecture Conversions");
        frame.setVisible(true);
        frame.setSize(500,500);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        
        JPanel panel = new JPanel ();
        frame.add(panel);

        JButton button = new JButton ("Binary to Decimal") ;
        JButton button2 = new JButton ("Decimal to Binary");
        JButton button3 = new JButton ("Decimal to Hexadecimal");
        JButton button4 = new JButton ("Hexadecimal to Decimal");
        JButton button5 = new JButton ("Library of Boolean Algebra Rules");
        JButton button6 = new JButton ("1's Complement");
        JButton button7 = new JButton ("2's Complement");
        panel.add(button);
        panel.add(button2);
        panel.add(button3);
        panel.add(button4);
        panel.add(button5);
        panel.add(button6);
        panel.add(button7);
        button.addActionListener(new Action());
        button2.addActionListener(new Action2());
        button3.addActionListener(new Action3());
        button4.addActionListener(new Action4());
        button5.addActionListener(new Action5());
        button6.addActionListener(new Action6());
        button7.addActionListener(new Action7());
    }
        static class Action implements ActionListener{

            public void actionPerformed (ActionEvent e){
            JFrame frame2 = new JFrame ("Binary to Decimal Conversion");
            frame2.setVisible(true);
            frame2.setSize(500,300);
            JLabel label = new JLabel ("Binary");
            JPanel panel = new JPanel();
            JButton b2d = new JButton("Convert to Decimal Now!");
            JTextField text = new JTextField(25);
            frame2.add(panel);
            panel.add(text);
            panel.add(label);
            panel.add(b2d);
            }
        }

        static class Action2 implements ActionListener{
            
            public void actionPerformed (ActionEvent e){
            JFrame frame3 = new JFrame ("Decimal to Binary Conversion");
            frame3.setVisible(true);
            frame3.setSize(500,300);
            JLabel label = new JLabel ("Decimal");
            JPanel panel = new JPanel();
            JButton d2b = new JButton("Convert to Binary Now!");
            JTextField text = new JTextField(25);
            frame3.add(panel);
            panel.add(text);
            panel.add(label);
            panel.add(d2b);
                
            }
        }

         static class Action3 implements ActionListener{

            public void actionPerformed (ActionEvent e){
            JFrame frame4 = new JFrame ("Decimal to Hexadecimal Conversion");
            frame4.setVisible(true);
            frame4.setSize(500,300);
            JLabel label = new JLabel ("Decimal");
            JPanel panel = new JPanel();
            JButton d2h = new JButton("Convert to Hexadecimal Now!");
            JTextField text = new JTextField(25);
            frame4.add(panel);
            panel.add(text);
            panel.add(label);
            panel.add(d2h);
            }
        }
     static class Action4 implements ActionListener{

            public void actionPerformed (ActionEvent e){
            JFrame frame5 = new JFrame ("Hexadecimal to Decimal Conversion");
            frame5.setVisible(true);
            frame5.setSize(500,300);
            JLabel label = new JLabel ("Hexadecimal");
            JPanel panel = new JPanel();
            JButton h2d = new JButton("Convert to Decimal Now!");
            JTextField text = new JTextField(25);
            frame5.add(panel);
            panel.add(text);
            panel.add(label);
            panel.add(h2d);
            }
        }

    static class Action5 implements ActionListener{

            public void actionPerformed (ActionEvent e){
            JFrame frame6 = new JFrame ("Library of Boolean Algebra Rules");
            frame6.setVisible(true);
            frame6.setSize(500,300);
            JLabel label = new JLabel ("You clicked me!");
            JPanel panel = new JPanel();
            frame6.add(panel);
            panel.add(label);
            }
        }

     static class Action6 implements ActionListener{

            public void actionPerformed (ActionEvent e){
            JFrame frame7 = new JFrame ("1's Complement Conversion");
            frame7.setVisible(true);
            frame7.setSize(500,300);
            JLabel label = new JLabel ("You clicked me!");
            JPanel panel = new JPanel();
            frame7.add(panel);
            panel.add(label);
            }
        }

     static class Action7 implements ActionListener{

            public void actionPerformed (ActionEvent e){
            JFrame frame8 = new JFrame ("2's Complement Conversion");
            frame8.setVisible(true);
            frame8.setSize(500,300);
            JLabel label = new JLabel ("You clicked me!");
            JPanel panel = new JPanel();
            frame8.add(panel);
            panel.add(label);
            }
        }
    }

AnswerRe: Java Conversions Pin
Richard MacCutchan17-Mar-10 7:55
mveRichard MacCutchan17-Mar-10 7:55 
AnswerRe: Java Conversions [modified] Pin
TorstenH.18-Mar-10 2:02
TorstenH.18-Mar-10 2:02 
QuestionJNLP Error Pin
002comp16-Mar-10 22:37
002comp16-Mar-10 22:37 
AnswerRe: JNLP Error(Solved) Pin
002comp17-Mar-10 0:05
002comp17-Mar-10 0:05 
AnswerRe: JButton Help Pin
Richard MacCutchan16-Mar-10 22:47
mveRichard MacCutchan16-Mar-10 22:47 
GeneralRe: JButton Help Pin
James WG Murphy17-Mar-10 2:58
James WG Murphy17-Mar-10 2:58 
GeneralRe: JButton Help Pin
Richard MacCutchan17-Mar-10 4:04
mveRichard MacCutchan17-Mar-10 4:04 
GeneralRe: JButton Help Pin
David Skelly17-Mar-10 6:19
David Skelly17-Mar-10 6:19 
AnswerRe: JButton Help Pin
David Skelly16-Mar-10 23:29
David Skelly16-Mar-10 23:29 
Questiondate_time problum in java?? Pin
AmbiguousName16-Mar-10 2:34
AmbiguousName16-Mar-10 2:34 
AnswerRe: date_time problum in java?? Pin
O.Phil16-Mar-10 3:02
O.Phil16-Mar-10 3:02 
GeneralRe: date_time problum in java?? Pin
AmbiguousName16-Mar-10 3:15
AmbiguousName16-Mar-10 3:15 
Questionuser authentication Pin
Kunalpuranik15-Mar-10 19:04
Kunalpuranik15-Mar-10 19:04 
AnswerRe: user authentication Pin
Richard MacCutchan15-Mar-10 22:29
mveRichard MacCutchan15-Mar-10 22:29 
GeneralRe: user authentication Pin
Kunalpuranik16-Mar-10 0:32
Kunalpuranik16-Mar-10 0:32 
GeneralRe: user authentication Pin
Richard MacCutchan16-Mar-10 3:30
mveRichard MacCutchan16-Mar-10 3:30 
GeneralRe: user authentication Pin
David Skelly16-Mar-10 3:39
David Skelly16-Mar-10 3:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.