コード例 #1
0
 private void initTable() {
   tableModel.addColumn("已有单号列表");
   jtable.setFont(new Font("宋体", Font.PLAIN, 15));
   jtable.getTableHeader().setReorderingAllowed(false);
   jtable.getTableHeader().setResizingAllowed(false);
   jtable.getColumnModel().getColumn(0).setCellRenderer(dtc);
 }
コード例 #2
0
  // Initializes this component.
  private void jbInit() {
    segmentTable.addFocusListener(
        new FocusListener() {
          public void focusGained(FocusEvent e) {
            segmentTable_focusGained(e);
          }

          public void focusLost(FocusEvent e) {
            segmentTable_focusLost(e);
          }
        });
    segmentTable.setTableHeader(null);
    scrollPane = new JScrollPane(segmentTable);
    scrollPane.setMinimumSize(new Dimension(getTableWidth(), 0));

    setLayout(new BorderLayout(0, 0));

    determineColumnWidth();
    nameLbl.setPreferredSize(new Dimension(getTableWidth(), 25));
    nameLbl.setMinimumSize(new Dimension(getTableWidth(), 0));
    nameLbl.setFont(Utilities.labelsFont);

    segmentTable.setFont(Utilities.valueFont);
    setBorder(BorderFactory.createEtchedBorder());

    setMinimumSize(new Dimension(getTableWidth(), 0));

    this.add(nameLbl, BorderLayout.NORTH);
    this.add(scrollPane, BorderLayout.CENTER);
  }
  /** Erzeugt die Tabelle für die Anzeige der Medien. */
  private void erzeugeMedienTable() {
    JScrollPane medienAuflisterScrollPane = new JScrollPane();
    medienAuflisterScrollPane.setBorder(
        BorderFactory.createTitledBorder(
            null,
            "Medien",
            TitledBorder.LEADING,
            TitledBorder.DEFAULT_POSITION,
            UIConstants.HEADER_FONT));
    medienAuflisterScrollPane.setBackground(UIConstants.BACKGROUND_COLOR);
    medienAuflisterScrollPane.getVerticalScrollBar().setBackground(UIConstants.BACKGROUND_COLOR);
    medienAuflisterScrollPane.getHorizontalScrollBar().setBackground(UIConstants.BACKGROUND_COLOR);

    _ausleiheMedienTableModel = new MedienverwaltungMedienTableModel();
    _medienTable = new JTable();
    _medienTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    medienAuflisterScrollPane.setViewportView(_medienTable);
    _medienTable.setModel(_ausleiheMedienTableModel);
    JTableHeader tableHeader = _medienTable.getTableHeader();
    tableHeader.setFont(UIConstants.HEADER_FONT);
    tableHeader.setReorderingAllowed(false);
    tableHeader.setResizingAllowed(false);
    _medienTable.setFont(UIConstants.TEXT_FONT);

    _hauptPanel.add(medienAuflisterScrollPane, BorderLayout.CENTER);
  }
コード例 #4
0
ファイル: Dlg_chat.java プロジェクト: yespickmeup/Synsoftech
 private void init_tbl_chats() {
   tbl_chats_ALM = new ArrayListModel();
   tbl_chats_M = new TblchatsModel(tbl_chats_ALM);
   tbl_chats.setModel(tbl_chats_M);
   tbl_chats.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
   int[] tbl_widths_chats = {58, 100, 0, 0, 0};
   for (int i = 0, n = tbl_widths_chats.length; i < n; i++) {
     if (i == 1) {
       continue;
     }
     TableWidthUtilities.setColumnWidth(tbl_chats, i, tbl_widths_chats[i]);
   }
   Dimension d = tbl_chats.getTableHeader().getPreferredSize();
   d.height = 0;
   tbl_chats.getTableHeader().setPreferredSize(d);
   tbl_chats.getTableHeader().setFont(new java.awt.Font("Arial", 0, 12));
   tbl_chats.setRowHeight(65);
   tbl_chats.setFont(new java.awt.Font("Arial", 0, 12));
   tbl_chats.getColumnModel().getColumn(0).setCellRenderer(new TableRender.set2());
   tbl_chats.getColumnModel().getColumn(1).setCellRenderer(new TableRender.set3());
   tbl_chats.getTableHeader().setResizingAllowed(true);
   tbl_chats.setShowGrid(false);
   tbl_chats.setShowHorizontalLines(true);
   tbl_chats.setShowVerticalLines(false);
   tbl_chats.getColumnModel().getColumn(1).setCellRenderer(new Html());
 }
コード例 #5
0
ファイル: GUI.java プロジェクト: inter6/pknu-ect-htc
  /**
   * This method initializes tb_result
   *
   * @return javax.swing.JTable
   */
  private JTable getTb_result() {
    if (tb_result == null) {
      TableColumn tc_press = new TableColumn();
      tc_press.setModelIndex(2);
      tc_press.setHeaderValue("출판사");
      TableColumn tc_author = new TableColumn();
      tc_author.setModelIndex(1);
      tc_author.setHeaderValue("저자");
      TableColumn tc_title = new TableColumn();
      tc_title.setHeaderValue("제목");
      tb_result = new JTable();
      tb_result.setAutoCreateColumnsFromModel(false);
      tb_result.setFont(new Font("Dialog", Font.PLAIN, 14));
      tb_result.setRowHeight(30);
      tb_result.addColumn(tc_title);
      tb_result.addColumn(tc_author);
      tb_result.addColumn(tc_press);
      tb_result.addMouseListener(
          new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent e) {
              if (tableMouseClickedCount == 0) {
                tableMouseClickedCount++;
                return;
              }

              Const.goToDetailPage(detailBrowser, getTb_result().getSelectedRow());

              tableMouseClickedCount = 0;
            }
          });
    }
    return tb_result;
  }
コード例 #6
0
 public CenterPanel(RegisterPanel rp) {
   super();
   setLayout(new BorderLayout());
   this.rp = rp;
   rp.setJT(jt);
   JScrollPane jsp = new JScrollPane(jt);
   setBackground(Color.BLACK);
   add(jsp, BorderLayout.CENTER);
   tm = (DefaultTableModel) jt.getModel();
   tm.addColumn("ID");
   tm.addColumn("Barcode");
   tm.addColumn("Name");
   tm.addColumn("Qty");
   tm.addColumn("Price");
   tm.addColumn("Tax");
   tm.addColumn("Total");
   // tm.setRowCount(50);
   // jt.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
   jt.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
   jt.getColumnModel().getColumn(0).setPreferredWidth(20);
   jt.getColumnModel().getColumn(1).setPreferredWidth(150);
   jt.getColumnModel().getColumn(2).setPreferredWidth(300);
   jt.getColumnModel().getColumn(3).setPreferredWidth(20);
   jt.setFont(new Font("Arial", Font.BOLD, 18));
   jt.setRowHeight(30);
 }
コード例 #7
0
 @Override
 public void resetSize() {
   listS = sotfwareBN.selectAll();
   font = tableSB32.getFont().getFontName();
   size = listS.get(0).getSizeWord();
   tableSB32.setFont(new Font(font, 0, size));
 }
コード例 #8
0
  /**
   * Fügt einem Container eine JTable mit den Daten, der Beschriftung und dem Titel hinzu.
   *
   * @param tabs JTabbedPane
   * @param daten Daten
   * @param kopfZeile Beschriftung
   * @param s Titel
   */
  protected static void fuegeJTabelleHinzu(
      Container tabs, Object[][] daten, Object[] kopfZeile, String s) {

    TableModel model =
        new DefaultTableModel(daten, kopfZeile) {
          private static final long serialVersionUID = 1L;

          @SuppressWarnings({"rawtypes", "unchecked"})
          @Override
          public Class getColumnClass(int column) {
            return getValueAt(0, column).getClass();
          }
        };

    JTable jTabelle = new JTable(model);
    jTabelle.getTableHeader().setFont(DiagrammeErsteller.STANDARD2);
    jTabelle.setFont(DiagrammeErsteller.STANDARD3);
    jTabelle.setEnabled(false);
    jTabelle.getTableHeader().setReorderingAllowed(false);
    RowSorter<TableModel> sorter = new TableRowSorter<TableModel>(model);
    jTabelle.setRowSorter(sorter);
    if (tabs.getClass() == JTabbedPane.class) {
      JTabbedPane t = (JTabbedPane) tabs;
      t.addTab(
          s,
          new JScrollPane(
              jTabelle,
              JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
              JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED));
    } else {
      tabs.add(new JScrollPane(jTabelle));
    }
  }
  @SuppressWarnings("static-access")
  public void componentesListaUsuario() {
    dados = new Vector<String>();
    dados.add("Código");
    dados.add("Nome do Serviço");
    dados.add("Valor");
    dtmListaTipoServico = new DefaultTableModel();
    dtmListaTipoServico.setColumnIdentifiers(dados);
    jttListaTipoServico = new JTable();
    jttListaTipoServico.setFont(new Font("Tahoma", Font.PLAIN, 12));
    jttListaTipoServico.setModel(dtmListaTipoServico);
    jttListaTipoServico.getColumnModel().getColumn(0).setResizable(false);
    jttListaTipoServico.getColumnModel().getColumn(0).setPreferredWidth(60);
    jttListaTipoServico.getColumnModel().getColumn(1).setResizable(false);
    jttListaTipoServico.getColumnModel().getColumn(1).setPreferredWidth(337);
    jttListaTipoServico.getColumnModel().getColumn(2).setResizable(false);
    jttListaTipoServico.getColumnModel().getColumn(2).setPreferredWidth(100);
    jspListaTipoServico = new JScrollPane(jttListaTipoServico);
    jttListaTipoServico.setAutoResizeMode(jttListaTipoServico.AUTO_RESIZE_OFF);
    jspListaTipoServico.setBounds(10, 10, 500, 300);
    jpnListaTipoServico.add(jspListaTipoServico);

    jbtSelecionarTipoServico = new JButton("Selecionar");
    jbtSelecionarTipoServico.setFont(new Font("Tahoma", Font.PLAIN, 12));
    jbtSelecionarTipoServico.setBounds(10, 338, 110, 23);
    jpnListaTipoServico.add(jbtSelecionarTipoServico);

    jbtCancelarPesquisa = new JButton("Cancelar");
    jbtCancelarPesquisa.setFont(new Font("Tahoma", Font.PLAIN, 12));
    jbtCancelarPesquisa.setBounds(130, 339, 110, 23);
    jpnListaTipoServico.add(jbtCancelarPesquisa);
  }
コード例 #10
0
  /**
   * Generates a JTable using results from Assessment data
   *
   * @param assessment - Assessment object
   */
  public void makeTable(Assessment assessment) {
    DefaultTableModel model =
        new DefaultTableModel() {
          @Override
          public boolean isCellEditable(int row, int column) {
            // Disables all cells from being editable
            return false;
          }
        };

    // Assigns column headings
    boolean isAnonymised = !assessment.getResults().get(0).getCandKey().contains("#");
    if (isAnonymised) {
      model.addColumn("Name");
      model.addColumn("Student Number");
    } else {
      model.addColumn("Anon Codes");
    }

    model.addColumn("#Ass");
    model.addColumn("Module Code");
    model.addColumn("Mark");
    model.addColumn("Grade");

    table = new JTable(model);
    table.setFont(new Font("Calibri", Font.BOLD, 14));

    // Sets column header look
    JTableHeader header = table.getTableHeader();
    header.setFont(new Font("Calibri", Font.BOLD, 16));
    header.setBackground(Color.black);
    header.setForeground(Color.WHITE);

    // Sets cell selection to single so only one cell is selected
    table.setCellSelectionEnabled(true);
    System.out.println("Making JTable");
    // Fetches first assessment and adds results data to model
    for (Result r : assessment.getResults()) {
      String name = r.getName();
      if (r.getName().equals("")) {
        name = r.getCandKey();
      }
      if (isAnonymised) {
        model.addRow(
            new Object[] {
              name, r.getCandKey(), r.getAssessment(), r.getModuleCode(), r.getMark(), r.getGrade()
            });
      } else {
        model.addRow(
            new Object[] {
              r.getCandKey(), r.getAssessment(), r.getModuleCode(), r.getMark(), r.getGrade()
            });
      }
    }

    table.setPreferredScrollableViewportSize(new Dimension(200, 300));
    table.setFillsViewportHeight(true);
    table.setShowGrid(false);
  }
コード例 #11
0
ファイル: FriendList.java プロジェクト: Fsig/Underground-IM
  /** Constructor. */
  public FriendList() {
    this.setIconImage(Constants.icon);
    this.setTitle("Underground IM");
    this.setSize(300, 400);
    this.setLocationRelativeTo(null);
    this.setResizable(true);
    this.setJMenuBar(menuBar.getMenuBar());

    // Friend List
    friendListData =
        new DefaultTableModel(new Object[0][0], new String[] {"Status", "Friends"}) {
          private static final long serialVersionUID = -3666163903937562582L;

          @Override
          public boolean isCellEditable(int a, int b) {
            return false;
          }
        };

    friendList = new JTable(friendListData);
    friendList.setBounds(0, 0, getWidth() - 15, getHeight() - 60);
    friendList.setFont(new Font("Arial", Font.PLAIN, 12));
    friendList.getColumnModel().getColumn(0).setCellRenderer(new ImageRenderer());

    friendListContainer =
        new JScrollPane(
            friendList,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    friendListContainer.setBounds(0, 0, getWidth() - 15, getHeight() - 90);

    // Add components
    this.add(friendListContainer);

    popupMenu = new PopupMenu(null, friendList);

    TrayIcon trayIcon = null;
    if (SystemTray.isSupported()) {
      this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
      SystemTray tray = SystemTray.getSystemTray();
      Image image = Constants.iconTray;

      ActionListener listener =
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {}
          };

      trayIcon = new TrayIcon(image, "Underground IM", popupMenu.getTrayMenu());
      trayIcon.addActionListener(listener);

      try {
        tray.add(trayIcon);
      } catch (AWTException e) {
        System.err.println(e);
      }
    } else {
      this.setDefaultCloseOperation(EXIT_ON_CLOSE);
    }
  }
コード例 #12
0
  private JPanel createPanel() {
    table.setFillsViewportHeight(true);
    table.setFont(getMonospacedFont());

    table.addMouseListener(
        new MouseAdapter() {

          public void mouseClicked(java.awt.event.MouseEvent e) {

            if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) {

              final int viewRow = table.rowAtPoint(e.getPoint());
              if (viewRow != -1) {
                final int modelRow = table.convertRowIndexToModel(viewRow);
                final Breakpoint breakPoint = tableModel.getBreakpoint(modelRow);

                disView.setViewStartingAddress(breakPoint.getAddress());
                if (sourceLevelDebugView
                    != null) { // may be NULL when debugging a plain object file without attached
                               // source
                  sourceLevelDebugView.scrollToVisible(breakPoint.getAddress());
                }
              }
            }
          };
        });

    table
        .getActionMap()
        .put(
            "deleteRow",
            new AbstractAction("deleteRow") {

              public void actionPerformed(ActionEvent e) {
                final int viewRow = table.getSelectedRow();
                final int modelRow = table.convertRowIndexToModel(viewRow);
                Breakpoint bp = tableModel.getBreakpoint(modelRow);
                emulator.deleteBreakpoint(bp);
              }
            });

    final KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0);
    table.getInputMap().put(stroke, "deleteRow");

    setColors(table);

    // setup scrollpane
    final JScrollPane pane = new JScrollPane(table);
    setColors(pane);

    // setup result panel
    final JPanel panel = new JPanel();
    setColors(panel);
    panel.setLayout(new GridBagLayout());
    final GridBagConstraints cnstrs = constraints(0, 0, true, true, GridBagConstraints.BOTH);
    panel.add(pane, cnstrs);
    return panel;
  }
コード例 #13
0
  public hostelStatus() {
    setTitle("Hostel");
    connect();
    updateRecord();

    JFrame fr = new JFrame();
    Toolkit tkt = fr.getToolkit();
    Dimension frsize = tkt.getScreenSize();
    setBounds(frsize.width / 4, frsize.height / 12, frsize.width / 2, frsize.height / 8);
    setLayout(null);

    cn = getContentPane();
    cn.setBackground(new Color(190, 180, 170));

    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    tl = new JLabel("Current Hostels Status");
    tl.setFont(new Font("Engravers MT", 1, 25));
    tl.setForeground(new Color(247, 251, 249));

    p1 = new JPanel();
    p1.setBounds(0, 0, 600, 50);
    p1.add(tl);
    p1.setBackground(new Color(31, 88, 166));
    cn.add(p1);

    b1 = new JButton("LOAD");
    b1.setMnemonic('L');
    b1.addActionListener(new dispListener());
    b1.setBounds(230, 320, 120, 30);

    b2 = new JButton("EXIT");
    b2.setMnemonic('X');
    b2.addActionListener(new exitListener());
    b2.setBounds(350, 320, 100, 30);

    cn.add(b1);
    cn.add(b2);

    table = new JTable(data, col);
    table.setFont(new Font("Serif", Font.BOLD, 16));
    table.setBackground(new Color(250, 250, 250));
    table.setEnabled(false);

    JScrollPane jsp = new JScrollPane(table);
    jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    jsp.setBounds(5, 100, 590, 200);
    cn.add(jsp);

    screensize = Toolkit.getDefaultToolkit().getScreenSize();

    setSize(600, 400);
    setVisible(true);
    setVisible(true);
    setResizable(true);
    connect();
  }
コード例 #14
0
 @Override
 public void setFont(Font font) {
   super.setFont(font);
   calculateSizes(font);
   if (cellRenderer
       != null) { // check for NPE prevent, because constructor of JTable calls setFont()
     cellRenderer.setFont(font);
   }
 }
コード例 #15
0
  public TeacherManagePasswords() {
    super(new BorderLayout());
    setBackground(FWCConfigurator.bgColor);

    // Build title and north panel
    pnNorth = new JPanel(new FlowLayout(FlowLayout.CENTER));
    pnNorth.setBackground(FWCConfigurator.bgColor);
    lblTitle = new TitleLabel("Reset Passwords", FWCConfigurator.RESET_PASSW_TITLE_IMG);
    pnNorth.add(lblTitle);

    // Build center panel
    pnCenter = new JPanel(new BorderLayout());
    pnCenter.setBackground(FWCConfigurator.bgColor);

    // Build table of students
    tableModel = new DisabledTableModel();
    tableModel.setColumnIdentifiers(
        new String[] {"First Name", " Last " + "Name", "Username", "Class"});

    studentsTable = new JTable(tableModel);
    studentsTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    studentsTable.setFillsViewportHeight(true);
    studentsTable.getTableHeader().setFont(new Font("Calibri", Font.PLAIN, 18));
    studentsTable.setFont(new Font("Calibri", Font.PLAIN, 18));
    studentsTable.setRowHeight(studentsTable.getRowHeight() + 12);

    // Populate the table only with students that need a password reset
    students = FWCConfigurator.getTeacher().getStudentsRequestedReset();
    populateTable();

    tableScroll =
        new JScrollPane(
            studentsTable,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    tableScroll.setBackground(FWCConfigurator.bgColor);
    tableScroll.setBorder(
        BorderFactory.createCompoundBorder(
            new EmptyBorder(10, 100, 10, 100), new LineBorder(Color.black, 1)));

    pnCenter.add(tableScroll, BorderLayout.CENTER);

    // Build south panel
    pnButtons = new JPanel(new FlowLayout(FlowLayout.CENTER));
    pnButtons.setBackground(FWCConfigurator.bgColor);
    pnButtons.setBorder(BorderFactory.createEmptyBorder(0, 100, 20, 100));
    btnReset = new ImageButton("Reset Selected", FWCConfigurator.RESET_SELECTED_IMG, 150, 50);
    btnReset.addActionListener(new ResetListener());
    btnResetAll = new ImageButton("Reset All", FWCConfigurator.RESET_ALL_IMG, 150, 50);
    btnResetAll.addActionListener(new ResetListener());
    pnButtons.add(btnReset);
    pnButtons.add(btnResetAll);

    this.add(pnNorth, BorderLayout.NORTH);
    this.add(pnCenter, BorderLayout.CENTER);
    this.add(pnButtons, BorderLayout.SOUTH);
  }
コード例 #16
0
ファイル: GUI.java プロジェクト: kryukov/jimm-multi
 /**
  * This method initializes compareTable
  *
  * @return javax.swing.JTable
  */
 private JTable getCompareTable() {
   if (compareTable == null) {
     compareTable = new JTable();
     compareTable.setBackground(java.awt.Color.white);
     compareTable.setFont(new Font("DialogInput", Font.PLAIN, 12));
     compareTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
     compareTable.setModel(getDefaultTableModel(false));
     setTableProps();
   }
   return compareTable;
 }
コード例 #17
0
  /** Create the frame. */
  public SearchTable() {
    addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowActivated(WindowEvent e) {
            do_this_windowActivated(e);
          }
        });
    setTitle("\u652F\u6301\u67E5\u627E\u529F\u80FD\u7684\u8868\u683C");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 450, 300);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    contentPane.setLayout(new BorderLayout(0, 0));
    setContentPane(contentPane);

    JPanel panel = new JPanel();
    contentPane.add(panel, BorderLayout.NORTH);

    JLabel label = new JLabel("\u5173\u952E\u5B57\uFF1A");
    label.setFont(new Font("微软雅黑", Font.PLAIN, 16));
    panel.add(label);

    textField = new JTextField();
    textField.setFont(new Font("微软雅黑", Font.PLAIN, 16));
    panel.add(textField);
    textField.setColumns(20);

    JPanel buttonPanel = new JPanel();
    contentPane.add(buttonPanel, BorderLayout.SOUTH);

    JButton button = new JButton("\u67E5\u627E");
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            do_button_actionPerformed(e);
          }
        });
    button.setFont(new Font("微软雅黑", Font.PLAIN, 16));
    buttonPanel.add(button);

    JScrollPane scrollPane = new JScrollPane();
    contentPane.add(scrollPane, BorderLayout.CENTER);

    table = new JTable();
    table.setFont(new Font("微软雅黑", Font.PLAIN, 14));
    table.setRowHeight(30);
    JTableHeader header = table.getTableHeader();
    header.setFont(new Font("微软雅黑", Font.PLAIN, 16));
    header.setPreferredSize(new Dimension(header.getWidth(), 35));
    scrollPane.setViewportView(table);
  }
コード例 #18
0
ファイル: MyTablePanel.java プロジェクト: sc89703312-org/-
  private void initTable() {
    JTableHeader header = table.getTableHeader();
    table.setRowHeight(ROW_HEIGHT);
    table.setFont(font);

    header.setFont(font);
    header.setPreferredSize(new Dimension(header.getWidth(), ROW_HEIGHT));

    table.setCellSelectionEnabled(false);
    table.setOpaque(false);
    //		table.setShowGrid(false);
    //		table.setShowVerticalLines(false);
    table.setGridColor(gridColor);

    // 设置表格颜色
    setForeground(foreColor);
    header.setForeground(foreColor);
    //		header.setBackground(headerColor);
    header.setBorder(new LineBorder(gridColor, 1));

    DefaultTableCellRenderer dtr =
        new DefaultTableCellRenderer() {
          private static final long serialVersionUID = 1L;

          @Override
          public Component getTableCellRendererComponent(
              JTable table,
              Object value,
              boolean isSelected,
              boolean hasFocus,
              int row,
              int column) {
            if (row % 2 == 0) {
              setBackground(backColor1);
            } else if (row % 2 == 1) {
              setBackground(backColor2);
            } else setBackground(backColor2);
            setForeground(foreColor);

            return super.getTableCellRendererComponent(
                table, value, isSelected, hasFocus, row, column);
          }
        };
    dtr.setHorizontalAlignment(JLabel.CENTER);
    for (int i = 0; i < headerStr.length; i++) {
      table.getColumn(headerStr[i]).setCellRenderer(dtr);
    }
    header.setDefaultRenderer(dtr);
  }
コード例 #19
0
 private void jbInit() throws Exception {
   setTitle("DIARIO CONTADO");
   frmDatosVenta = new FrmDatosVenta(engine);
   frmDatosVenta.setLocationRelativeTo(this);
   getContentPane().setLayout(borderLayout1);
   jLabel1.setFont(new java.awt.Font("Arial", Font.PLAIN, 18));
   jLabel1.setToolTipText("");
   jLabel1.setText("DIARIO DE ENTRADAS");
   pnlCentro.setLayout(borderLayout2);
   cmdCerrar.setText("CERRAR");
   cmdCerrar.addActionListener(new FrmDiarioDeEntradas_cmdCerrar_actionAdapter(this));
   cmdImprimir.setText("IMPRIMIR");
   tblDiario.setBackground(new Color(255, 240, 255));
   tblDiario.setFont(new java.awt.Font("Arial", Font.PLAIN, 12));
   tblDiario.setModel(modelDiarioVentasDeContado1);
   tblDiario.addMouseListener(new FrmDiarioDeEntradas_tblDiario_mouseAdapter(this));
   this.addWindowListener(new FrmDiarioDeEntradas_this_windowAdapter(this));
   jLabel2.setFont(new java.awt.Font("Arial", Font.BOLD, 20));
   jLabel2.setText("Total:");
   lblTotal.setFont(new java.awt.Font("Arial", Font.BOLD, 20));
   lblTotal.setText("");
   this.getContentPane().setBackground(Color.white);
   this.addKeyListener(new FrmDiarioDeEntradas_this_keyAdapter(this));
   pnlCentro.setBackground(Color.white);
   pnlNorte.setBackground(Color.white);
   pnlNorte.setLayout(borderLayout4);
   scrollDiario.getViewport().setBackground(Color.white);
   scrollDiario.setPreferredSize(new Dimension(800, 600));
   lblFecha.setFont(new java.awt.Font("Arial", Font.BOLD, 16));
   lblFecha.setText("");
   jPanel1.setLayout(borderLayout3);
   pnlSur.setMaximumSize(new Dimension(4000, 200));
   jPanel1.setBackground(Color.white);
   jPanel2.setBackground(Color.white);
   this.getContentPane().add(pnlCentro, java.awt.BorderLayout.CENTER);
   pnlCentro.add(pnlNorte, java.awt.BorderLayout.CENTER);
   pnlCentro.add(scrollDiario, java.awt.BorderLayout.NORTH);
   scrollDiario.getViewport().add(tblDiario);
   this.getContentPane().add(pnlSur, java.awt.BorderLayout.SOUTH);
   pnlSur.add(cmdImprimir);
   pnlSur.add(cmdCerrar);
   this.getContentPane().add(jPanel1, java.awt.BorderLayout.NORTH);
   jPanel1.add(lblFecha, java.awt.BorderLayout.EAST);
   jPanel1.add(jLabel1, java.awt.BorderLayout.WEST);
   pnlNorte.add(jPanel2, java.awt.BorderLayout.EAST);
   jPanel2.add(jLabel2);
   jPanel2.add(lblTotal);
   this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
 }
コード例 #20
0
 /** inits GUI with labels of current language */
 public void initGUI() {
   // setTitle(app.getPlain("ConstructionProtocol"));
   scrollPane.setFont(((AppD) app).getPlainFont());
   // setMenuBar();
   getStyleBar().setLabels();
   // set header values (language may have changed)
   for (int k = 0; k < tableColumns.length; k++) {
     tableColumns[k].setHeaderValue(data.columns[k].getTranslatedTitle());
   }
   table.updateUI();
   table.setFont(((AppD) app).getPlainFont());
   ((ConstructionTableData) data).updateAll();
   getStyleBar().reinit();
   // protNavBar.updateIcons();
 }
コード例 #21
0
  @SuppressWarnings("serial")
  public void GegevensTabel(int i) {
    String[] header = {"Spelernaam", "Pnt", "Res", "Krt"};
    String[][] data = null;
    data = oc.VulTabelRonde(i);
    spKaarten = new JScrollPane();
    getContentPane().add(spKaarten);
    spKaarten.setBounds(14, 168, 308, 126);
    spKaarten.setBorder(new LineBorder(new java.awt.Color(0, 0, 0), 0, false));
    spKaarten.setFont(new java.awt.Font("Arial", 0, 12));
    {
      tKaarten =
          new JTable(data, header) {

            public Component prepareRenderer(
                TableCellRenderer renderer, int rowIndex, int vColIndex) {
              Component c = super.prepareRenderer(renderer, rowIndex, vColIndex);
              if (rowIndex % 2 == 0 && !isCellSelected(rowIndex, vColIndex)) {
                c.setBackground(new java.awt.Color(202, 240, 202));
              } else {
                // If not shaded, match the table's
                // background
                c.setBackground(getBackground());
              }

              return c;
            }
          };

      naamKolom = tKaarten.getColumn(header[0]);
      naamKolom.setPreferredWidth(150);
      inzetKolom = tKaarten.getColumn(header[1]);
      inzetKolom.setPreferredWidth(30);
      resKolom = tKaarten.getColumn(header[2]);
      resKolom.setPreferredWidth(50);
      kaartKolom = tKaarten.getColumn(header[3]);
      kaartKolom.setPreferredWidth(30);
      spKaarten.setViewportView(tKaarten);
      tKaarten.setPreferredSize(new java.awt.Dimension(301, 126));
      tKaarten.setGridColor(new java.awt.Color(255, 255, 255));
      tKaarten.setBorder(new LineBorder(new java.awt.Color(90, 90, 90), 1, false));
      FlowLayout tKaartenLayout = new FlowLayout();
      tKaartenLayout.setAlignment(FlowLayout.LEFT);
      tKaarten.setLayout(tKaartenLayout);
      tKaarten.setFont(new java.awt.Font("Tahoma", 0, 12));
    }
  } // public void GegevensTabel(int i)
コード例 #22
0
  private void atualizaTabela(Usuario usu) {

    try {
      remove(scroller);

    } catch (NullPointerException e) {
    }
    fa = new Facade();
    tabela = fa.consultaTodos_Fornecedor(usu);
    tabela.setFont(new Font("Times New Roman", Font.BOLD, 14));
    scroller =
        new JScrollPane(
            tabela,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scroller.setBounds(30, 30, 700, 300);
    tela.add(scroller);
  }
コード例 #23
0
ファイル: EmpMain.java プロジェクト: mjsung/FirstProject
  public EmpMain() {
    String[] col = {"사번", "이름", "직위", "입사일", "부서번호"};
    String[][] row = new String[0][5];
    model =
        new DefaultTableModel(row, col) {
          public boolean isCellEditable(int r, int c) {
            return false;
          }
        };
    table = new JTable(model);
    JScrollPane js = new JScrollPane(table);
    la = new JLabel("사원목록");
    la.setFont(new Font("나눔스퀘어", Font.BOLD, 30));
    table.setFont(new Font("나눔스퀘어", Font.PLAIN, 12));
    JPanel p = new JPanel();
    p.add(la);

    la1 = new JLabel("Search");
    tf = new JTextField(10);
    box = new JComboBox();
    box.addItem("이름");
    box.addItem("입사일");
    box.addItem("부서");
    b1 = new JButton("찾기");
    b2 = new JButton("목록");
    JPanel p1 = new JPanel();
    p1.add(la1);
    p1.add(box);
    p1.add(tf);
    p1.add(b1);
    p1.add(b2);
    add("South", p1);
    add("Center", js);
    add("North", p);
    setSize(640, 480);
    setVisible(true);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    getData();
    table.addMouseListener(this);
    b1.addActionListener(this);
    b2.addActionListener(this);
  }
コード例 #24
0
 private void init_tbl_delivery_trucks() {
   tbl_delivery_trucks_ALM = new ArrayListModel();
   tbl_delivery_trucks_M = new Tbldelivery_trucksModel(tbl_delivery_trucks_ALM);
   tbl_delivery_trucks.getTableHeader().setPreferredSize(new Dimension(100, 40));
   tbl_delivery_trucks.setModel(tbl_delivery_trucks_M);
   tbl_delivery_trucks.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
   tbl_delivery_trucks.setRowHeight(25);
   int[] tbl_widths_delivery_trucks = {100, 100, 0};
   for (int i = 0, n = tbl_widths_delivery_trucks.length; i < n; i++) {
     if (i == 1) {
       continue;
     }
     TableWidthUtilities.setColumnWidth(tbl_delivery_trucks, i, tbl_widths_delivery_trucks[i]);
   }
   Dimension d = tbl_delivery_trucks.getTableHeader().getPreferredSize();
   d.height = 25;
   tbl_delivery_trucks.getTableHeader().setPreferredSize(d);
   tbl_delivery_trucks.getTableHeader().setFont(new java.awt.Font("Arial", 0, 11));
   tbl_delivery_trucks.setRowHeight(35);
   tbl_delivery_trucks.setFont(new java.awt.Font("Arial", 0, 11));
 }
コード例 #25
0
  public static void setModel(
      JTable tbl, Object[][] obj, String[] col_names, int[] tbl_widths_customers1) {
    tbl.setModel(
        new javax.swing.table.DefaultTableModel(obj, col_names) {

          boolean[] canEdit = new boolean[] {false, false, false, false, false, false};

          @Override
          public boolean isCellEditable(int rowIndex, int columnIndex) {
            return canEdit[columnIndex];
          }
        });
    int[] tbl_widths_customers = tbl_widths_customers1;
    for (int i = 0, n = tbl_widths_customers.length; i < n; i++) {
      if (i == 1) {
        continue;
      }
      TableWidthUtilities.setColumnWidth(tbl, i, tbl_widths_customers[i]);
    }
    tbl.setRowHeight(30);
    tbl.setFont(new java.awt.Font("Arial", 0, 11));
  }
コード例 #26
0
 public static void init_tbl_disbursement_categories(JTable tbl_disbursement_categories) {
   tbl_disbursement_categories_ALM = new ArrayListModel();
   tbl_disbursement_categories_M =
       new Tbldisbursement_categoriesModel(tbl_disbursement_categories_ALM);
   tbl_disbursement_categories.setModel(tbl_disbursement_categories_M);
   tbl_disbursement_categories.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
   tbl_disbursement_categories.setRowHeight(25);
   int[] tbl_widths_disbursement_categories = {100, 0};
   for (int i = 0, n = tbl_widths_disbursement_categories.length; i < n; i++) {
     if (i == 0) {
       continue;
     }
     TableWidthUtilities.setColumnWidth(
         tbl_disbursement_categories, i, tbl_widths_disbursement_categories[i]);
   }
   Dimension d = tbl_disbursement_categories.getTableHeader().getPreferredSize();
   d.height = 25;
   tbl_disbursement_categories.getTableHeader().setPreferredSize(d);
   tbl_disbursement_categories.getTableHeader().setFont(new java.awt.Font("Arial", 0, 12));
   tbl_disbursement_categories.setRowHeight(25);
   tbl_disbursement_categories.setFont(new java.awt.Font("Arial", 0, 12));
 }
コード例 #27
0
ファイル: RueckgabeUI.java プロジェクト: sdft/se2
  /** Erzeuge das Tabellen-Panel, in dem die Verleihkarten angezeigt werden. */
  private void erzeugeVerleihkartenauflister() {
    JPanel verleihkartenAuflisterPanel = new JPanel();
    _hauptPanel.add(verleihkartenAuflisterPanel, BorderLayout.CENTER);
    verleihkartenAuflisterPanel.setLayout(new BorderLayout());
    verleihkartenAuflisterPanel.setPreferredSize(new java.awt.Dimension(-1, -1));
    verleihkartenAuflisterPanel.setSize(-1, -1);
    verleihkartenAuflisterPanel.setBackground(UIConstants.BACKGROUND_COLOR);

    JScrollPane verleihkartenAuflisterScrollPane = new JScrollPane();
    verleihkartenAuflisterPanel.add(verleihkartenAuflisterScrollPane, BorderLayout.CENTER);
    verleihkartenAuflisterScrollPane.setPreferredSize(new java.awt.Dimension(-1, -1));
    verleihkartenAuflisterScrollPane.setSize(-1, -1);
    verleihkartenAuflisterScrollPane.setBorder(
        BorderFactory.createTitledBorder(
            null,
            "Verleihkarten",
            TitledBorder.LEADING,
            TitledBorder.DEFAULT_POSITION,
            UIConstants.HEADER_FONT));
    verleihkartenAuflisterScrollPane.setBackground(UIConstants.BACKGROUND_COLOR);
    verleihkartenAuflisterScrollPane
        .getVerticalScrollBar()
        .setBackground(UIConstants.BACKGROUND_COLOR);
    verleihkartenAuflisterScrollPane
        .getHorizontalScrollBar()
        .setBackground(UIConstants.BACKGROUND_COLOR);

    _verleihkartenAuflisterTableModel = new VerleihkartenTableModel();
    _verleihkartenAuflisterTable = new JTable();
    verleihkartenAuflisterScrollPane.setViewportView(_verleihkartenAuflisterTable);
    _verleihkartenAuflisterTable.setModel(_verleihkartenAuflisterTableModel);
    JTableHeader tableHeader = _verleihkartenAuflisterTable.getTableHeader();
    tableHeader.setFont(UIConstants.HEADER_FONT);
    tableHeader.setReorderingAllowed(false);
    tableHeader.setResizingAllowed(false);
    _verleihkartenAuflisterTable.setFont(UIConstants.TEXT_FONT);
  }
コード例 #28
0
  void tableInitialise(JTable table) {

    JScrollPane scroll;
    TableColumn column = null;

    int colunms = table.getColumnCount();
    for (int y = 0; y < colunms; y++) {
      column = table.getColumnModel().getColumn(y);
      /*将每一列的默认宽度设置为100*/
      column.setPreferredWidth(100);
    }
    /*
     * 设置JTable自动调整列表的状态,此处设置为关闭
     */
    table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);

    table.setFont(new Font("Menu.font", Font.PLAIN, 14));
    table.getTableHeader().setFont(new Font("Menu.font", Font.BOLD, 15));
    /*用JScrollPane装载JTable,这样超出范围的列就可以通过滚动条来查看*/

    scroll = new JScrollPane(table);
    TablePanel.removeAll();

    TablePanel.setLayout(new BoxLayout(TablePanel, BoxLayout.Y_AXIS));
    TablePanel.add(scroll);

    TablePanel.revalidate();

    table.setRowSelectionAllowed(true); // 设置JTable可被选择
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // 设置JTable为单行选择
    table.getTableHeader().setBackground(new Color(206, 231, 255)); // 设置JTable表头颜色
    table.getTableHeader().setReorderingAllowed(false); // 设置JTable每个字段的顺序不可以改变
    table.getTableHeader().setResizingAllowed(false); // 设置JTable每个表头的大小不可以改变
    makeFace(table); // 设置JTable 颜色

    table.setVisible(true);
  }
コード例 #29
0
  /**
   * Create the panel
   *
   * @throws Exception if error occures during creation of the panel
   */
  private void init() throws Exception {

    // create objects to display
    this.setLayout(new BorderLayout());
    model = new MyTableModel();
    table = new JTable(model);
    table.setShowGrid(true);
    table.setAutoscrolls(true);
    table.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION);
    JScrollPane scrollpane = new JScrollPane(table);
    table.setPreferredScrollableViewportSize(new Dimension(800, 200));
    table.setFont(GuiFactory.defaultTableFont);
    table.getTableHeader().setFont(GuiFactory.defaultTableHeaderFont);

    table.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent event) {
            if (event.getClickCount() == 2) {
              try {
                ExplorerUtil.getSyncAdminController()
                    .getPrincipalsController()
                    .startLastTimestampsProcess(getSelectedPrincipal());

              } catch (AdminException e) {
                String description = Bundle.getMessage(Bundle.EDITING);
                Log.error(
                    MessageFormat.format(
                        Bundle.getMessage(Bundle.ERROR_HANDLING_PRINCIPAL),
                        new String[] {description}),
                    e);
              }
            }
          }
        });

    this.add(scrollpane, BorderLayout.CENTER);
  }
コード例 #30
0
ファイル: DataPanel.java プロジェクト: Serabe/geogebra
  public void setFont(Font font) {
    super.setFont(font);

    if (dataTable != null && dataTable.getRowCount() > 0 && dataTable.getColumnCount() > 0) {

      // set the font for each component
      dataTable.setFont(font);
      if (dataTable.getTableHeader() != null) dataTable.getTableHeader().setFont(font);
      rowHeader.setFont(font);

      // get row height needed to draw an "X" character
      int h =
          dataTable
              .getCellRenderer(0, 0)
              .getTableCellRendererComponent(dataTable, "X", false, false, 0, 0)
              .getPreferredSize()
              .height;

      // use this height to set the table and row header heights
      dataTable.setRowHeight(h);
      rowHeader.setFixedCellHeight(h);

      // set the column width
      int size = font.getSize();
      if (size < 12) size = 12; // minimum size
      double multiplier = (size) / 12.0;
      preferredColumnWidth = (int) (SpreadsheetSettings.TABLE_CELL_WIDTH * multiplier);

      // columnHeader.setPreferredSize(new Dimension(preferredColumnWidth,
      // (int)(MyTable.TABLE_CELL_HEIGHT * multiplier)));
      // this.validate();
      // dataTable.repaint();
    }

    if (dataTable != null)
      dataTable.setPreferredScrollableViewportSize(dataTable.getPreferredSize());
  }