■
やっと、いきなりandroid SDKを使った開発は今の自分のJavaスキルにはハードルが高すぎる事が分かったので、今日はNative Javaでカレンダーを作ってみた。途中だけど、今の所の成果はこんな感じ。JFrameにJPanelを二つ乗っけて、下のパネルにこのグリッドを、上のパネルに年月と現在時刻を表示するともうちょっとそれらしくなるかな??
現状のソースはこんな感じ。
---CalendarButton.java---
import java.awt.*;
import javax.swing.*;
class CalendarButton extends JButton {
public int Y;
public int M;
public int D;
public int W;
//CalendarButton CalendarButton( int year, int month, int day, int week, boolean holiday, boolean highlight ) {
CalendarButton( int year, int month, int day, int week, boolean holiday, boolean highlight ) {
//JButton b;
//CalendarButton b;
super(Integer.toString(day));
Y = year; M = month; D = day; W = week;
//b = new JButton(Integer.toString(day));
if( 1 == week )
this.setForeground(Color.RED);
else if( 7 == week )
this.setForeground(Color.BLUE);
else
this.setForeground(Color.GRAY);
this.setBackground(Color.BLACK);
if( highlight ) {
this.setForeground(Color.WHITE);
this.setBackground(Color.GRAY);
}
this.setVisible(true);
//return (CalendarButton)b;
}
}
---CalendarButton.java---
---CalendarGrid.java---
import java.awt.*;
import javax.swing.*;
import java.util.Calendar;
//class CalendarGrid extends GridLayout {
class CalendarGrid extends JFrame {
CalendarGrid() {
JFrame MainFrame;
Container c;
// JPanel MainPanel;
GridLayout CalendarGrid;
CalendarButton[] CB;
int i;
int thisyear;
int thismonth;
int thisday;
int thisweek;
MainFrame = new JFrame();
MainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
MainFrame.setSize(800, 600);
MainFrame.setTitle("CalenderGrid");
c = MainFrame.getContentPane();
// c.setLayout(new FlowLayout());
CalendarGrid = new GridLayout(5,7);
// c.setLayout(CalendarGrid);
/*
// MainPanel = new JPanel();
//MainFrame.setLayout(CalenderGrid);