Границы таблицы - Java

Узнай цену своей работы

Формулировка задачи:

Есть таблица с прозрачным фоном, но рамка не у всей таблицы, точнее нет верхней и левой линии границы, а хотелось бы что бы они были, это решаемо ?
Листинг программы
  1. jTable.setRowHeight(30);
  2. jTable.setGridColor(Color.white);
  3. jTable.setBounds(5, 90, 210, 210);
  4. jTable.setSelectionBackground(new Color(0,0,0,0));
  5. jTable.setBackground(new Color(0,0,0,70));

Решение задачи: «Границы таблицы»

textual
Листинг программы
  1.     private void panel_calendar()
  2.     {
  3.         String day_week[] = {"Пн", "Вт", "Ср", "Чт", "Пт", "Сб", "Вс"};
  4.         String year_month[] = {"Январь", "Февраль", "Март", "Апрель", "Май", "Июнь", "Июль", "Август", "Сентябрь", "Октябрь", "Ноябрь", "Декабрь"};
  5.         int hw = 30;
  6.         int week_day, full_day, day_date, month_date, year_date;
  7.         int days = 0;
  8.         int start_day = 0;
  9.        
  10.         JPanel container = new JPanel();
  11.         container.setLayout(new BorderLayout());
  12.         container.setBounds(4, 90, hw*day_week.length, hw*day_week.length + hw);
  13.         container.setBackground(new Color(0,0,0,70));
  14.         container.setLayout(null);
  15.        
  16.         Calendar calendar = Calendar.getInstance();
  17.         day_date = calendar.get(Calendar.DAY_OF_MONTH);
  18.         month_date = calendar.get(Calendar.MONTH);
  19.         year_date = calendar.get(Calendar.YEAR);
  20.         full_day = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
  21.  
  22.         calendar.set(year_date, month_date, 1);
  23.         week_day = calendar.get(Calendar.DAY_OF_WEEK);
  24.        
  25.         JLabel jlabel = new JLabel(year_month[month_date] + " " + year_date, SwingConstants.CENTER);
  26.         jlabel.setForeground(Color.white);
  27.         jlabel.setBounds(0, 0, day_week.length * hw, hw);
  28.         container.add(jlabel);
  29.        
  30.         for (int i = 0; i < day_week.length; i++)
  31.         {
  32.             JLabel jlabels = new JLabel(day_week[i], SwingConstants.CENTER);
  33.             jlabels.setForeground(Color.white);
  34.             jlabels.setBounds(hw * i, hw, hw, hw);
  35.             container.add(jlabels);
  36.         }
  37.        
  38.         for (int j = 0; j < 6; j++)
  39.         {
  40.             if(j == 0)
  41.             {
  42.                 start_day = week_day-2;
  43.             }
  44.             else
  45.             {
  46.                 start_day = 0;
  47.             }
  48.             for (int f = start_day; f < 7; f++)
  49.             {
  50.                 if (days < full_day)
  51.                 {
  52.                     days++;
  53.                 }
  54.                 else
  55.                 {
  56.                     break;
  57.                 }
  58.                
  59.                 JLabel jlabel_day = new JLabel("" + days, SwingConstants.CENTER);
  60.                 jlabel_day.setForeground(Color.white);
  61.                 if (days == day_date)
  62.                 {
  63.                     jlabel_day.setBorder(BorderFactory.createLineBorder(Color.WHITE, 3));
  64.                 }
  65.                 jlabel_day.setBounds(hw * f, (hw * 2) + (hw * j), hw, hw);
  66.                 container.add(jlabel_day);
  67.             }
  68.         }
  69.         window.add(container);
  70.     }

ИИ поможет Вам:


  • решить любую задачу по программированию
  • объяснить код
  • расставить комментарии в коде
  • и т.д
Попробуйте бесплатно

Оцени полезность:

15   голосов , оценка 4.133 из 5

Нужна аналогичная работа?

Оформи быстрый заказ и узнай стоимость

Бесплатно
Оформите заказ и авторы начнут откликаться уже через 10 минут