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

 

 

public class testDialog extends JDialog implements ActionListener {
 
 JButton btn,btn1,btn2;
 
    public testDialog(JPanel parent, String title, String btntext, String btntext1, String btntext2) {
        super();
        this.setUndecorated(true);
        //this.setBackground(new Color(250,236,197));

        initUI(parent,title, btntext, btntext1, btntext2);
        
    }

    private void initUI(Container parent,String title, String btntext, String btntext1, String btntext2) {


        JLabel name = new JLabel(title);
        //name.setBackground(new Color(250,236,197));
        name.setFont(new Font("굴림", Font.BOLD, 13));

        btn = new JButton(btntext);
        btn.addActionListener(this);
        
        btn1 = new JButton(btntext1);
        btn1.addActionListener(this);
        
        btn2 = new JButton(btntext2);
        btn2.addActionListener(this);

        createLayout(name, btn, btn1, btn2);

        setModalityType(ModalityType.APPLICATION_MODAL);

        //setTitle("About Notes");
       
        setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        setLocationRelativeTo(parent.getParent());

    }

    private void createLayout(JComponent... arg) {

        Container pane = getContentPane();
        GroupLayout gl = new GroupLayout(pane);
        
        pane.setBackground(new Color(250,236,197));
        pane.setLayout(gl);

        gl.setAutoCreateContainerGaps(true);
        gl.setAutoCreateGaps(true);
       

        gl.setHorizontalGroup(gl.createSequentialGroup()
          .addGroup(gl.createParallelGroup(CENTER)
           .addComponent(arg[0])
           .addGroup(gl.createSequentialGroup()
            //.addGroup(gl.createParallelGroup(GroupLayout.Alignment.LEADING)
                   .addComponent(arg[1])             
                   .addComponent(arg[2])
                   .addComponent(arg[3])))//)
                //.addGap(200)
        );

        gl.setVerticalGroup(gl.createSequentialGroup()
          .addGroup(gl.createParallelGroup(GroupLayout.Alignment.BASELINE)
           .addComponent(arg[0]))
           .addGap(30)
            // .addGroup(gl.createParallelGroup(GroupLayout.Alignment.LEADING)
              //.addGroup(gl.createSequentialGroup()
                .addGroup(gl.createParallelGroup(GroupLayout.Alignment.BASELINE)
                 .addComponent(arg[1])
              .addComponent(arg[2])
              .addComponent(arg[3]))//))

        );

        pack();
    }

 

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

ArrayList<String> array = new ArrayList<String>();


/***

array.add(넣을것);

***/


JComboBox<String> combox = new JComboBox<String>(array .toArray(new String[array .size()]));


toArray() 사용

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

// 날짜 포맷 변경
SimpleDateFormat sdftime = new SimpleDateFormat("yyyy-MM-dd a h:mm");


Date nowDate = new Date();


Date expiryDate = sdftime.parse(sdftime.format(rs.getTimestamp(4)), new ParsePosition(0));


 -> sdftime.parse(sdftime.format(DB Result Set), new ParsePosition(0));)

nowDate.before(expiryDate) // 현재가 만료기간보다 이전일때

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

// JComboBox 선언

JComboBox<String> jcomtodayyear,jcomtodaymonth,jcomtodayday;

 

// 날짜배열 선언
ArrayList<String> yeararray; // 년도

ArrayList<String> montharray; // 월
ArrayList<String> dayarray; // 일


Calendar oCalendar = Calendar.getInstance( );  // 현재 날짜/시간 등의 각종 정보 얻기


// 현재 날짜
 int toyear = oCalendar.get(Calendar.YEAR);
 int tomonth = oCalendar.get(Calendar.MONTH) + 1;
 int today = oCalendar.get(Calendar.DAY_OF_MONTH);


  
  // 년도


  yeararray = new ArrayList<String>();


  for(int i = toyear + 10; i>= toyear -10; i--){
   yeararray.add(String.valueOf(i));
   //System.out.println(i);
  }  
  jcomtodayyear= new JComboBox<String>(yeararray.toArray(new String[yeararray.size()]));

  jcomtodayyear.setBounds(5, 5, 70, 30);
  jcomtodayyear.setSelectedItem(String.valueOf(toyear));



// 월
  
  montharray = new ArrayList<String>();
  
  for(int i = 1; i <= 12; i++){
   montharray.add(addZeroString(i));
   //System.out.println(i);
  }  
  jcomtodaymonth = new JComboBox<String>(montharray.toArray(new String[montharray.size()]));

  jcomtodaymonth.setBounds(80, 5, 70, 30);
  String mcom = tomonth >= 10?String.valueOf(tomonth):"0"+tomonth;
  jcomtodaymonth.setSelectedItem(mcom);



// 일
  
  dayarray = new ArrayList<String>();
  
  for(int i = 1; i <= 31; i++){
   dayarray.add(addZeroString(i));
   //System.out.println(i);
  }  
  jcomtodayday = new JComboBox<String>(dayarray.toArray(new String[dayarray.size()]));

  jcomtodayday.setBounds(160, 5, 70, 30);
  String dcom = today >= 10?String.valueOf(today):"0"+today;
  jcomtodayday.setSelectedItem(dcom);




// 한자리 숫자 앞에 + 0 예) 7일 -> 07일 
 private String addZeroString(int k){
        String value=Integer.toString(k);
        if(value.length()==1) {
         value="0"+value;
        }
        return value;
 }

 

+ Recent posts