RadioButton exam

Programming/JAVA,JSP 2013. 2. 3. 12:23 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

import javax.swing.*;

import javax.swing.border.Border;

 

import java.awt.event.*;

import java.awt.*;

 

class MyFrame extends JFrame implements ActionListener {

 

    private JRadioButton small, medium, large;

    private JRadioButton ane, cafela, cafemo;

    private JLabel text;

    private JPanel topPanel, sizePanel, resultPanel, itemPanel;

 

    private JPanel centerPanel;

   

    public MyFrame() {

        setTitle("라디오 버튼 테스트");

        setSize(300, 150);

        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

 

        topPanel = new JPanel();

        JLabel label = new JLabel("어떤 크기의 커피를 주문하시겠습니까?");

        topPanel.add(label);

        add(topPanel, BorderLayout.NORTH);

 

        // centerPanel

        centerPanel = new JPanel();

        add(centerPanel, BorderLayout.CENTER);

        centerPanel.setLayout(new GridLayout(2,1));

       

        // sizePanel

        sizePanel = new JPanel();

        small = new JRadioButton("Small Size");

        medium = new JRadioButton("Medium Size");

        large = new JRadioButton("Large Size");

 

        ButtonGroup size = new ButtonGroup();

        size.add(small);

        size.add(medium);

        size.add(large);

        small.addActionListener(this);

        medium.addActionListener(this);

        large.addActionListener(this);

        sizePanel.add(small);

        sizePanel.add(medium);

        sizePanel.add(large);

        centerPanel.add(sizePanel);

 

        // itemPanel

        itemPanel = new JPanel();

        ane = new JRadioButton("아메리카노");

        cafela = new JRadioButton("카페라떼");

        cafemo = new JRadioButton("카페모카");

 

        ButtonGroup item = new ButtonGroup();

        item.add(ane);

        item.add(cafela);

        item.add(cafemo);

        ane.addActionListener(this);

        cafela.addActionListener(this);

        cafemo.addActionListener(this);

        itemPanel.add(ane);

        itemPanel.add(cafela);

        itemPanel.add(cafemo);

        centerPanel.add(itemPanel);

 

        // resultPanel

        resultPanel = new JPanel();

        text = new JLabel("크기가 선택되지 않았습니다.");

        text.setForeground(Color.red);

        resultPanel.add(text);

        add(resultPanel, BorderLayout.SOUTH);

        setVisible(true);

    }

 

    public void actionPerformed(ActionEvent e) {

        String itemString = null;

        String sizeString = null;

       

       

        if (ane.isSelected()) {

           itemString = "아메리카노";

        }

        else if (cafela.isSelected()) {

           itemString = "카페라떼";

        }

        else if (cafemo.isSelected()) {

           itemString = "카페모카";

        }

 

        if (small.isSelected()) {

           sizeString = "small";

        }

        else if (medium.isSelected()) {

           sizeString = "medium";

        }

        else if (large.isSelected()) {

           sizeString = "large";

        }

        text.setText(itemString + sizeString

               + " 주문하셨습니다.");

       

    }

}

 

public class RadioButtonTest extends JFrame {

    public static void main(String[] args) {

        new MyFrame();

    }

}

 

'Programming > JAVA,JSP' 카테고리의 다른 글

JAVA JDBC 튜토리얼 예제 사이트  (0) 2013.02.24
JAVA 채팅 프로그램 + GUI  (0) 2013.02.23
[IT]자바의 위기, 한국 IT의 시금석  (0) 2013.02.02
JAVA 비행기게임  (0) 2013.01.09
JAVA 오목 게임 #1  (0) 2012.11.23
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

http://www.ddanzi.com/blog/archives/119097


'Programming > JAVA,JSP' 카테고리의 다른 글

JAVA 채팅 프로그램 + GUI  (0) 2013.02.23
RadioButton exam  (0) 2013.02.03
JAVA 비행기게임  (0) 2013.01.09
JAVA 오목 게임 #1  (0) 2012.11.23
JAVA 프레임 안에 프레임  (1) 2012.11.18
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

#include <iostream>

#include <string>

using namespace std;

 

int main()

{

    string str;

    string tempStr[10];

    int tempStrSeq = 0;

    int tempStrCount[10] = {0};

    int start = 0, many = 0;

    getline(cin, str, '\n');

    for( int i = 0 ; i < str.length() ; i++ )

    {

        if( str.at(i) == ' ' || str.at(i) == ',' || str.at(i) == '.' )

        {

            if( many != 0)

            {

                cout << str.substr(start,many) << endl;

                int flag = 0;

                for( int j = 0 ; j < tempStrSeq + 1 ; j++ )

                {

                    if( tempStr[j].compare(str.substr(start,many)) == 0 )

                    {

                        flag++;

                        tempStrCount[j]++;

                    }

                    else

                    {

                        // 같지않다면

                    }

                }

                if( flag == 0)

                {

                    tempStr[tempStrSeq] = str.substr(start,many);

                    tempStrCount[tempStrSeq]++;

                    tempStrSeq++;

                }

                cout << "s : "<< start << "m : " << many << endl;

                many = 0;

            }

            start = i+1;

        }

        else

        {

            many++;

        }

    }

    if( many != 0)

    {

        cout << str.substr(start,many) << endl;

        int flag = 0;

        for( int j = 0 ; j < tempStrSeq + 1 ; j++ )

        {

           if( tempStr[j].compare(str.substr(start,many)) == 0 )

            {

                flag++;

                tempStrCount[j]++;

            }

            else

            {

                // 같지않다면

            }

        }

        if( flag == 0)

        {

            tempStr[tempStrSeq] = str.substr(start,many);

            tempStrSeq++;

            tempStrCount[tempStrSeq]++;

        }

        cout << "s : "<< start << "m : " << many << endl;

    }

 

    // TODO: 계산

 

    for( int i = 0 ; i < 10 ; i++ )

    {

        cout << tempStr[i] ;

        cout << " " << tempStrCount[i] << endl;

    }

}

'Programming > C,CPP,CS' 카테고리의 다른 글

아스키코드표  (0) 2013.05.02
프로그래밍용으로 좋은 폰트  (0) 2013.03.23
CPP string 줄단위 입력  (0) 2013.01.26
링크드리스트 학생관리  (0) 2013.01.19
C언어 달력소스코드  (0) 2013.01.13

CPP string 줄단위 입력

Programming/C,CPP,CS 2013. 1. 26. 15:48 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
CPP string 줄단위 입력


 string str;
 getline(cin, str, '\n');

 

 

336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

 

시스코 라우터 디폴트 값 확인 사이트

라우터 디폴트 비밀번호

router switch default password username ip

http://www.routeripaddress.com/74/cisco_routers/

'CiscoNetwork' 카테고리의 다른 글

ipTIME 공유기 포트 미러링 지원 제품 및 설정방법  (0) 2015.09.16
CISCO packet tracer VPN client 설정  (0) 2013.12.02
UTP5 cables PPT  (0) 2013.04.29
실습장비 관련 정보  (0) 2013.01.25
PacketTracer 5.3.1  (0) 2012.07.20