예제 #1
0
 public void unGreyTable() {
   sitesTable.setSelectionBackground(oldSelectionBackground);
   sitesTable.setSelectionForeground(oldSelectionForeground);
   sitesTable.setForeground(Color.BLACK);
   sitesTable.setBackground(Color.WHITE);
   sitesTable.setEnabled(true);
 }
 /**
  * Sets a specified highlight on a specified location in the script.
  *
  * @param startLine the line to start the highlight on
  * @param endLine the line to end the highlight
  * @param backgroundColor the background color to use for the highlight
  */
 private void setLineSelectionHighlight(int startLine, int endLine, Color backgroundColor) {
   int lineNumbers = m_sourceModel.getLineNumbers();
   if ((startLine >= 0) && (endLine < lineNumbers) && (startLine <= endLine)) {
     m_sourceCode.setSelectionBackground(backgroundColor);
     m_sourceCode.addRowSelectionInterval(startLine, endLine);
   }
 }
예제 #3
0
  public Component getTableCellRendererComponent(
      JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    if (row % 2 == 0) {
      // 设置偶数行的背景颜色
      setBackground(new Color(236, 246, 248));
    } else {
      // 基数行的背景颜色
      setBackground(new Color(255, 255, 255));
    }

    if (row == MyJTable.current) {
      // 鼠标悬浮行的颜色
      setBackground(new Color(154, 221, 151));
    }

    /* 继承Label类的方法, 设置table的单元格对齐方式 */
    setHorizontalAlignment((int) Component.CENTER_ALIGNMENT); // 水平居中
    setHorizontalTextPosition((int) Component.CENTER_ALIGNMENT); // 垂直居中

    // table.getTableHeader().setBackground(new Color(206, 231,
    // 255));//设置表头的字体色
    table.setSelectionBackground(new Color(213, 235, 243)); // 设置选中行的背景色
    table.setSelectionForeground(new Color(247, 81, 53)); // 设置选中行的前景色
    return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
  }
예제 #4
0
 void greyOutTable() {
   sitesTable.setEnabled(false);
   oldSelectionBackground = sitesTable.getSelectionBackground();
   oldSelectionForeground = sitesTable.getSelectionForeground();
   sitesTable.setSelectionBackground(Color.GRAY);
   sitesTable.setSelectionForeground(Color.DARK_GRAY);
   sitesTable.setForeground(Color.GRAY);
   sitesTable.setBackground(null);
 }
예제 #5
0
 public static void main(String[] args) {
   /*
   构造函数有很多下面先介绍几个:
   JTable()
   JTable(int numRows, int numColumns)
   JTable(Object[][] rowData, Object[] columnNames)
   */
   JTable example1 = new JTable(); // 看不到但存在
   JTable example2 = new JTable(8, 6);
   final Object[] columnNames = {
     "姓名", "性别", "家庭地址", // 列名最好用final修饰
     "电话号码", "生日", "工作", "收入", "婚姻状况", "恋爱状况"
   };
   Object[][] rowData = {
     {"ddd", "男", "江苏南京", "1378313210", "03/24/1985", "学生", "寄生中", "未婚", "没"},
     {"eee", "女", "江苏南京", "13645181705", "xx/xx/1985", "家教", "未知", "未婚", "好象没"},
     {"fff", "男", "江苏南京", "13585331486", "12/08/1985", "汽车推销员", "不确定", "未婚", "有"},
     {"ggg", "女", "江苏南京", "81513779", "xx/xx/1986", "宾馆服务员", "确定但未知", "未婚", "有"},
     {"hhh", "男", "江苏南京", "13651545936", "xx/xx/1985", "学生", "流放中", "未婚", "无数次分手后没有"}
   };
   JTable friends = new JTable(rowData, columnNames);
   friends.setPreferredScrollableViewportSize(new Dimension(600, 100)); // 设置表格的大小
   friends.setRowHeight(30); // 设置每行的高度为20
   friends.setRowHeight(0, 20); // 设置第1行的高度为15
   friends.setRowMargin(5); // 设置相邻两行单元格的距离
   friends.setRowSelectionAllowed(true); // 设置可否被选择.默认为false
   friends.setSelectionBackground(Color.white); // 设置所选择行的背景色
   friends.setSelectionForeground(Color.red); // 设置所选择行的前景色
   friends.setGridColor(Color.black); // 设置网格线的颜色
   friends.selectAll(); // 选择所有行
   friends.setRowSelectionInterval(0, 2); // 设置初始的选择行,这里是1到3行都处于选择状态
   friends.clearSelection(); // 取消选择
   friends.setDragEnabled(false); // 不懂这个
   friends.setShowGrid(false); // 是否显示网格线
   friends.setShowHorizontalLines(false); // 是否显示水平的网格线
   friends.setShowVerticalLines(true); // 是否显示垂直的网格线
   friends.setValueAt("tt", 0, 0); // 设置某个单元格的值,这个值是一个对象
   friends.doLayout();
   friends.setBackground(Color.lightGray);
   JScrollPane pane1 = new JScrollPane(example1); // JTable最好加在JScrollPane上
   JScrollPane pane2 = new JScrollPane(example2);
   JScrollPane pane3 = new JScrollPane(friends);
   JPanel panel = new JPanel(new GridLayout(0, 1));
   panel.setPreferredSize(new Dimension(600, 400));
   panel.setBackground(Color.black);
   panel.add(pane1);
   panel.add(pane2);
   panel.add(pane3);
   JFrame frame = new JFrame("JTableDemo");
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.setContentPane(panel);
   frame.pack();
   frame.show();
 }
예제 #6
0
 @Override
 public void resetColorMouse() {
   listS = sotfwareBN.selectAll();
   Color color =
       new Color(
           listS.get(0).getColorMouseClick().getRed(),
           listS.get(0).getColorMouseClick().getGreen(),
           listS.get(0).getColorMouseClick().getBlue());
   tableSB32.setSelectionBackground(color);
   tableSB32.repaint();
 }
예제 #7
0
  public void createviewPanel() {

    viewPanel = new JPanel();
    viewPanel.setLayout(new BorderLayout());
    // viewPanel.setPreferredSize( new Dimension(500,500 ));
    // viewPanel.setMinimumSize( new Dimension(100,50));
    // viewPanel.add( new JLabel("Notes:"),BorderLayout.NORTH );
    //		viewPanel.add( new JTextArea(), BorderLayout.CENTER );
    viewPanel.setPreferredSize(new Dimension(200, 520));
    viewPanel.setMinimumSize(new Dimension(100, 100));
    // Create columns
    CreateColumns(colcnt);
    CreateData(rowcnt, colcnt);
    setSize(300, 200);

    table =
        new JTable(dataValues, columnNames) {

          public boolean isCellEditable(int rowIndex, int vColIndex) {
            return false;
          }
        };

    table
        .getModel()
        .addTableModelListener(
            new TableModelListener() {

              public void tableChanged(TableModelEvent e) {
                System.out.println("........" + e);
              }
            });
    // table.setValueAt("1,2",0,0);

    System.out.println("Row   :" + rowcnt);
    System.out.println("Col  :" + colcnt);

    // Configure some of JTable's paramters
    table.setShowHorizontalLines(false);
    table.setShowVerticalLines(false);
    table.setRowSelectionAllowed(false);
    table.setColumnSelectionAllowed(false);

    // Change the selection colour
    table.setSelectionForeground(Color.white);
    table.setSelectionBackground(Color.red);

    // Add the table to a scrolling pane
    scrollPaneTable = JTable.createScrollPaneForTable(table);
    viewPanel.add(scrollPaneTable, BorderLayout.CENTER);
    viewPanel.add(table, BorderLayout.CENTER);
  }
  /**
   * Constructs a Panel with a line-number, breakpoint, source-text
   *
   * @param dataComm the datacomm object for interaction with the ToolBus
   * @param scriptName the name of the script that is used by the ToolBus
   * @param source the source of an toolbus file
   */
  public SourceFilePanel(DataComm dataComm, String scriptName, String source) {
    super();

    m_dataComm = dataComm;
    setLayout(new BorderLayout());
    m_scriptName = scriptName;
    m_sourceModel = new SourceFileTableModel(source);
    m_sourceCode = new JTable(m_sourceModel);
    m_sourceCode.setSelectionBackground(SELECTED_ROW_COLOR);
    m_sourceCode.setSelectionForeground(Color.BLACK);
    m_sourceCode.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    // to set the background color back to default
    m_sourceCode.addMouseListener(
        new MouseAdapter() {
          public void mousePressed(MouseEvent e) {
            if (e.getClickCount() == MouseEvent.BUTTON1) {
              m_sourceCode.setSelectionBackground(SELECTED_ROW_COLOR);
            }
          }
        });

    m_sourceCode.getModel().addTableModelListener(this);
    m_sourceCode.setShowGrid(false);
    m_sourceCode.setColumnSelectionAllowed(false);
    m_sourceCode.setRowSelectionAllowed(true);

    m_sourceCode.getColumnModel().getColumn(0).setCellRenderer(new CheckBoxCellRenderer());
    m_sourceCode.getColumnModel().getColumn(0).setCellEditor(new CheckBoxCellRenderer());

    TableColumn firstColumn = m_sourceCode.getColumnModel().getColumn(FIRST_COLUMN_INDEX);
    firstColumn.setMaxWidth(FIRST_COLUMN_WIDTH);

    TableColumn secondColumn = m_sourceCode.getColumnModel().getColumn(SECOND_COLUMN_INDEX);
    DefaultTableCellRenderer tcrColumn = new DefaultTableCellRenderer();
    tcrColumn.setHorizontalAlignment(SwingConstants.LEFT);
    secondColumn.setCellRenderer(tcrColumn);
    secondColumn.setMaxWidth(SECOND_COLUMN_WIDTH);

    JScrollPane sourceScrollPane = new JScrollPane(m_sourceCode);
    sourceScrollPane.getViewport().setBackground(Color.WHITE);
    add(sourceScrollPane, BorderLayout.CENTER);
    setVisible(true);
  }
예제 #9
0
  private JScrollPane getTable() {
    if (clustInfo == null) {
      clustInfo =
          new JTable(
              new clustTableModel(infos.infoCluster[clustList.getSelectedIndex()].statClust)) {
            /** */
            private static final long serialVersionUID = 1L;

            {
              setAutoResizeMode(AUTO_RESIZE_OFF);
              getColumnModel().getColumn(1).setPreferredWidth(130);
              getColumnModel().getColumn(2).setPreferredWidth(75);
              getColumnModel().getColumn(0).setPreferredWidth(30);
              getColumnModel().getColumn(3).setPreferredWidth(75);
              getColumnModel().getColumn(4).setPreferredWidth(75);
              getColumnModel().getColumn(5).setPreferredWidth(75);
              ColumnHeaderToolTips tips = new ColumnHeaderToolTips();
              tips.setToolTip(getColumnModel().getColumn(0), "Considered in the clustering");
              getTableHeader().addMouseMotionListener(tips);
            }

            @Override
            public TableCellRenderer getCellRenderer(int row, int column) {
              if (column == 0) {
                return getDefaultRenderer(Boolean.class);
              }
              return getDefaultRenderer(String.class);
            }
          };
      ;
      clustInfo.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
      clustInfo.setSelectionBackground(new Color(83, 126, 126));
      clustInfo.setSelectionForeground(Color.BLACK);
    }

    JScrollPane p = new JScrollPane(clustInfo);
    return p;
  }
예제 #10
0
파일: UI.java 프로젝트: bkdwei/DBViewer
  // 设置UI元素的属性
  public void compose() {
    frame.setSize(954, 750);
    frame.setLocation(200, 50);
    frame.setResizable(true);

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLayout(new BorderLayout());

    // 工具栏
    toolBar.add(btDeleteTableData);
    toolBar.add(tfSqlCommand);
    toolBar.add(btExecuteSql);
    toolBar.add(btAbout);
    frame.add("North", toolBar);

    // 数据管理层

    westJPanel.setLayout(new BorderLayout());
    westJPanel.add("North", search);
    westJPanel.add("Center", awtList);
    frame.add("West", westJPanel);

    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    table.setShowGrid(true);
    table.setAutoscrolls(true);
    table.setDragEnabled(true);
    table.setCellSelectionEnabled(true);
    table.setSelectionBackground(new Color(233, 223, 233));
    scrollPane.setViewportView(table);

    frame.add("Center", scrollPane);

    statusBar.setAlignmentX(JLabel.RIGHT);
    frame.add("South", statusBar);

    frame.setVisible(true);
  }
예제 #11
0
  public JComponent createContestantList() {
    JPanel contListPanel = new JPanel();

    MyTableModel contTable = new MyTableModel();

    JTable table = new JTable(contTable);

    table.setPreferredScrollableViewportSize(new Dimension(WIDTH, HEIGHT));
    table.setFillsViewportHeight(true);
    table.setAutoCreateRowSorter(true);
    table.setRowHeight(77);

    table.setFont(new Font("Viner Hand ITC", Font.PLAIN, 18));
    table.setForeground(Color.BLUE);
    table.setSelectionForeground(Color.RED);
    table.setSelectionBackground(
        new Color(0, 0, 0, 64)); // When a cell is selected, this entire row is highlighted.

    // Create the scroll pane and add the table to it.
    JScrollPane scrollPane = new JScrollPane(table);
    contListPanel.add(scrollPane);

    return contListPanel;
  }
예제 #12
0
  /**
   * Create a new, empty, not-visible TaxRef window. Really just activates the setup frame and setup
   * memory monitor components, then starts things off.
   */
  public MainFrame() {
    setupMemoryMonitor();

    // Set up the main frame.
    mainFrame = new JFrame(basicTitle);
    mainFrame.setJMenuBar(setupMenuBar());
    mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Set up the JTable.
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.setSelectionBackground(COLOR_SELECTION_BACKGROUND);
    table.setShowGrid(true);

    // Add a blank table model so that the component renders properly on
    // startup.
    table.setModel(blankDataModel);

    // Add a list selection listener so we can tell the matchInfoPanel
    // that a new name was selected.
    table
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              @Override
              public void valueChanged(ListSelectionEvent e) {
                if (currentCSV == null) return;

                int row = table.getSelectedRow();
                int column = table.getSelectedColumn();

                columnInfoPanel.columnChanged(column);

                Object o = table.getModel().getValueAt(row, column);
                if (Name.class.isAssignableFrom(o.getClass())) {
                  matchInfoPanel.nameSelected(currentCSV.getRowIndex(), (Name) o, row, column);
                } else {
                  matchInfoPanel.nameSelected(currentCSV.getRowIndex(), null, -1, -1);
                }
              }
            });

    // Set up the left panel (table + matchInfoPanel)
    JPanel leftPanel = new JPanel();

    matchInfoPanel = new MatchInformationPanel(this);
    leftPanel.setLayout(new BorderLayout());
    leftPanel.add(matchInfoPanel, BorderLayout.SOUTH);
    leftPanel.add(new JScrollPane(table));

    // Set up the right panel (columnInfoPanel)
    JPanel rightPanel = new JPanel();

    columnInfoPanel = new ColumnInformationPanel(this);

    progressBar.setStringPainted(true);

    rightPanel.setLayout(new BorderLayout());
    rightPanel.add(columnInfoPanel);
    rightPanel.add(progressBar, BorderLayout.SOUTH);

    // Set up a JSplitPane to split the panels up.
    JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, false, leftPanel, rightPanel);
    split.setResizeWeight(1);
    mainFrame.add(split);
    mainFrame.pack();

    // Set up a drop target so we can pick up files
    mainFrame.setDropTarget(
        new DropTarget(
            mainFrame,
            new DropTargetAdapter() {
              @Override
              public void dragEnter(DropTargetDragEvent dtde) {
                // Accept any drags.
                dtde.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE);
              }

              @Override
              public void dragOver(DropTargetDragEvent dtde) {}

              @Override
              public void dropActionChanged(DropTargetDragEvent dtde) {}

              @Override
              public void dragExit(DropTargetEvent dte) {}

              @Override
              public void drop(DropTargetDropEvent dtde) {
                // Accept a drop as long as its File List.

                if (dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
                  dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);

                  Transferable t = dtde.getTransferable();

                  try {
                    java.util.List<File> files =
                        (java.util.List<File>) t.getTransferData(DataFlavor.javaFileListFlavor);

                    // If we're given multiple files, pick up only the last file and load that.
                    File f = files.get(files.size() - 1);
                    loadFile(f, DarwinCSV.FILE_CSV_DELIMITED);

                  } catch (UnsupportedFlavorException ex) {
                    dtde.dropComplete(false);

                  } catch (IOException ex) {
                    dtde.dropComplete(false);
                  }
                }
              }
            }));
  }
예제 #13
0
  public TelaVerLegislacao() {

    setIconImage(
        Toolkit.getDefaultToolkit()
            .getImage(TelaDefinirParametro.class.getResource("/face/vidro.png")));
    setTitle("Par\u00E2metros da legisla\u00E7\u00E3o");
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    setBounds(100, 100, 530, 358);

    tabbedPane = new JTabbedPane();

    getContentPane().add(tabbedPane);

    final amostraDAO amostraDAO = new DAO.amostraDAO();

    BasicComboBoxRenderer.UIResource UIResource = new BasicComboBoxRenderer.UIResource();
    UIResource.setHorizontalAlignment(SwingConstants.CENTER);

    // ATÉ AQUI TA CERTO!

    panelParametros = new JPanel();

    panelParametros.setBorder(
        new TitledBorder(
            UIManager.getBorder("TitledBorder.border"),
            "Par\u00E2metros da legisla\u00E7\u00E3o",
            TitledBorder.CENTER,
            TitledBorder.TOP,
            null,
            new Color(0, 0, 0)));

    panelParametros.setLayout(null);

    tabbedPane.add("Legislação", panelParametros);
    final parametroDAO p = new parametroDAO();

    scrollPaneParametro.setViewportBorder(
        new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    scrollPaneParametro.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPaneParametro.setBounds(10, 22, 489, 221);
    panelParametros.add(scrollPaneParametro);

    // FUNCIONA!

    colunas = new String[] {"PARAMETRO"};
    dados = new ArrayList();
    ModeloTable modelo = new ModeloTable(dados, colunas);
    tableParametro.setModel(modelo);

    final int idlegislacao = TelaManutencao.leg;

    p.PreencherTabelaLegislacao(
        "select pa.descricao from legislacao as le, parametro as pa, legislacao_parametro as lp "
            + "where le.idlegislacao = "
            + idlegislacao
            + " and le.idlegislacao = lp.legislacao and pa.idparametro = lp.parametro",
        dados);

    tableParametro.setAutoCreateRowSorter(true);

    tableParametro.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {

            linha = tableParametro.getSelectedRow();
            parametroTable = (String) tableParametro.getValueAt(linha, 0);
          }
        });

    btnExcluir = new JButton("Excluir");
    btnExcluir.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {

            int dialogButton = JOptionPane.YES_NO_OPTION;
            int DialogButton =
                JOptionPane.showConfirmDialog(
                    null,
                    "Deseja excluir o parametro " + parametroTable + " da legislação ?",
                    parametroTable,
                    dialogButton);
            if (DialogButton == JOptionPane.YES_OPTION) {

              p.ExcluirParametroLegislacao(
                  TelaManutencao.leg, p.obterCodigoParametro(parametroTable));

              p.PreencherTabelaLegislacao(
                  "select pa.descricao from legislacao as le, parametro as pa, legislacao_parametro as lp "
                      + "where le.idlegislacao = "
                      + idlegislacao
                      + " and le.idlegislacao = lp.legislacao and pa.idparametro = lp.parametro",
                  dados);

              tableParametro.setAutoCreateRowSorter(true);
            }
          }
        });
    btnExcluir.setBounds(410, 254, 89, 23);
    panelParametros.add(btnExcluir);
    try {

      tableParametro.setSurrendersFocusOnKeystroke(true);
      tableParametro.setFocusTraversalPolicyProvider(true);
      tableParametro.setFocusCycleRoot(true);
      tableParametro.setForeground(new Color(0, 0, 0));
      tableParametro.setSelectionForeground(new Color(0, 0, 0));
      tableParametro.setFillsViewportHeight(true);
      tableParametro.setSelectionBackground(new Color(135, 206, 235));
      tableParametro.setAutoCreateRowSorter(true);
      scrollPaneParametro.setViewportView(tableParametro);

      tableParametro.getColumnModel().getColumn(0).setPreferredWidth(100);

      tableParametro.getTableHeader().setReorderingAllowed(false);
      tableParametro.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN);
      tableParametro.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

      tableParametro.setDefaultRenderer(
          Object.class,
          new DefaultTableCellRenderer() {

            public Component getTableCellRendererComponent(
                JTable table,
                Object value,
                boolean isSelected,
                boolean hasFocus,
                int row,
                int column) {
              super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
              this.setHorizontalAlignment(CENTER);

              return this;
            }
          });
    } finally {

    }
  }
  public checkAccount(JFrame main, LoginPO loginPO) {
    accountBL = new AccountBL();
    checkAccount checkAccountframe = this;
    setBounds(100, 100, 750, 600);
    setVisible(true);

    setLayout(null);

    JButton button = new JButton("");
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            checkStatics_Analysis newcheckStatics_Analysis =
                new checkStatics_Analysis(main, loginPO);
            main.remove(checkAccountframe);
            main.getContentPane().add(newcheckStatics_Analysis);
            main.invalidate();
            main.repaint();
            main.setVisible(true);
          }
        });
    button.setBounds(13, -9, 63, 63);
    button.setContentAreaFilled(false);
    button.setBorderPainted(false);
    button.setIcon(new ImageIcon("image/transparent_circle.png"));
    button.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mousePressed(MouseEvent e) {
            button.setIcon(new ImageIcon("image/mask_circle.png"));
          }
        });
    add(button);

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBounds(158, 141, 427, 271);
    add(scrollPane);

    table = new JTable();
    table.setRowHeight(25);
    table.setSelectionBackground(new Color(88, 93, 103, 230));
    table.setSelectionForeground(new Color(255, 255, 255, 200));

    // 使表格居中
    DefaultTableCellRenderer r = new DefaultTableCellRenderer();
    r.setHorizontalAlignment(JLabel.CENTER);
    table.setDefaultRenderer(Object.class, r);

    // 选取行
    table.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            Point mousepoint;
            mousepoint = e.getPoint();
            rowpos = table.rowAtPoint(mousepoint);
            table.setRowSelectionInterval(rowpos, rowpos);
          }
        });

    tableModel =
        new DefaultTableModel(
            new Object[][] {
              {null, null}, {null, null}, {null, null}, {null, null}, {null, null},
              {null, null}, {null, null}, {null, null}, {null, null}, {null, null},
              {null, null}, {null, null}, {null, null}, {null, null}, {null, null},
            },
            new String[] {"\u8D26\u6237\u540D\u79F0", "\u8D26\u6237\u4F59\u989D"});
    table.setEnabled(false);
    table.setModel(tableModel);
    table.getColumnModel().getColumn(0).setPreferredWidth(130);
    table.getColumnModel().getColumn(1).setPreferredWidth(130);
    scrollPane.setViewportView(table);

    // 显示表格
    showTable(accountBL.check());
  }
  public CheckBillPanel(LoginPO loginPO, JFrame main) {
    setLayout(null);
    setSize(750, 600);

    CheckBillPanel cbp = this;

    JLabel lblHello = new JLabel("Hello! " + loginPO.getName());
    lblHello.setForeground(Color.WHITE);
    lblHello.setBounds(655, 12, 100, 15);
    add(lblHello);

    JButton button_4 = new JButton();
    button_4.setBounds(13, -9, 63, 63);
    button_4.setContentAreaFilled(false);
    button_4.setBorderPainted(false);
    button_4.setIcon(new ImageIcon("image/transparent_circle.png"));
    button_4.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            main.remove(cbp);
            BillPanel bpanel = new BillPanel(loginPO, main);
            main.getContentPane().add(bpanel);
            main.invalidate();
            main.repaint();
            main.setVisible(true);
          }
        });
    button_4.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mousePressed(MouseEvent e) {
            button_4.setIcon(new ImageIcon("image/mask_circle.png"));
          }
        });
    add(button_4);

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBounds(46, 151, 658, 322);
    add(scrollPane);

    table = new JTable();
    table.setRowHeight(25);
    // 使表格居中
    DefaultTableCellRenderer r = new DefaultTableCellRenderer();
    r.setHorizontalAlignment(JLabel.CENTER);
    table.setDefaultRenderer(Object.class, r);

    // 选取行
    table.addMouseListener(
        new java.awt.event.MouseAdapter() {
          public void mouseClicked(java.awt.event.MouseEvent e) {
            Point mousepoint;
            mousepoint = e.getPoint();
            rowpos = table.rowAtPoint(mousepoint);
            table.setRowSelectionInterval(rowpos, rowpos);
          }
        });

    scrollPane.setViewportView(table);
    table.setBorder(new LineBorder(new Color(0, 0, 0), 0, true));
    table.setEnabled(false);
    table.setSelectionBackground(new Color(88, 93, 103, 230));
    table.setSelectionForeground(new Color(255, 255, 255, 200));
    tableModel =
        new DefaultTableModel(
            new Object[][] {
              {"", "", "", "", "", ""},
              {null, null, null, null, null, null},
              {null, null, null, null, null, null},
              {null, null, null, null, null, null},
              {null, null, null, null, null, null},
              {null, null, null, null, null, null},
              {null, null, null, null, null, null},
              {null, null, null, null, null, null},
              {null, null, null, null, null, null},
              {null, null, null, null, null, null},
              {null, null, null, null, null, null},
              {null, null, null, null, null, null},
              {null, null, null, null, null, null},
              {null, null, null, null, null, null},
              {null, null, null, null, null, null},
            },
            new String[] {
              "\u8D26\u540D\u79F0",
              "\u94F6\u884C\u8D26\u6237",
              "\u673A\u6784",
              "\u4EBA\u5458",
              "\u8F66\u8F86",
              "\u5E93\u5B58"
            });
    table.setModel(tableModel);
    table.getColumnModel().getColumn(0).setPreferredWidth(70);
    table.getColumnModel().getColumn(1).setPreferredWidth(70);
    table.getColumnModel().getColumn(2).setPreferredWidth(120);
    table.getColumnModel().getColumn(2).setMinWidth(20);
    table.getColumnModel().getColumn(3).setPreferredWidth(120);
    table.getColumnModel().getColumn(3).setMinWidth(20);
    table.getColumnModel().getColumn(4).setPreferredWidth(120);
    table.getColumnModel().getColumn(5).setPreferredWidth(120);

    showTable(bbl.checkBill());
  }
예제 #16
0
  public LibraryApp() {
    super("Ambient Library");

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    bookTable_.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    contentPane_.setBorder(new EmptyBorder(10, 5, 10, 5));
    contentPane_.setLayout(new BorderLayout(0, 0));
    setContentPane(contentPane_);

    contentPane_.add(bookTableScrollPane_);

    contentPane_.add(keywordPanel_, BorderLayout.SOUTH);
    keywordPanel_.setBorder(new EmptyBorder(5, 0, 0, 0));
    keywordPanel_.setLayout(new BorderLayout(5, 0));
    keywordPanel_.add(keywordField_);
    keywordPanel_.add(keywordLabel_, BorderLayout.WEST);

    // bookTable_.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    bookTable_.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);

    bookTable_.setDefaultRenderer(String.class, bookTableCellRenderer_);
    bookTable_.setDefaultRenderer(Icon.class, statusCellRenderer_);
    bookTable_.setDefaultRenderer(ImageIcon.class, statusCellRenderer_);
    bookTable_.setCellSelectionEnabled(false);
    bookTable_.setRowSelectionAllowed(true);
    bookTable_.setSelectionBackground(Color.blue);

    JMenuItem addReviewMenuItem = new JMenuItem(ADD_REVIEW_CMD);
    JMenuItem clearReviewsMenuItem = new JMenuItem(CLR_REVIEW_CMD);
    JMenuItem editKeywordsMenuItem = new JMenuItem(EDIT_KEYWS_CMD);
    addReviewMenuItem.addActionListener(new AddReviewActionAdapter(this));
    clearReviewsMenuItem.addActionListener(new ClearReviewsActionAdapter(this));
    editKeywordsMenuItem.addActionListener(new EditKeywordsActionAdapter(this));
    popupMenu_.add(addReviewMenuItem);
    popupMenu_.add(clearReviewsMenuItem);
    popupMenu_.add(editKeywordsMenuItem);

    MouseListener popupListener = new PopupListener();
    bookTable_.addMouseListener(popupListener);

    TableColumn statusColumn = bookTable_.getColumnModel().getColumn(0);
    statusColumn.setMaxWidth(40);
    statusColumn.setMaxWidth(40);
    statusColumn.setPreferredWidth(40);

    TableColumn ratingColumn = bookTable_.getColumnModel().getColumn(3);
    ratingColumn.setMaxWidth(60);
    ratingColumn.setMaxWidth(60);
    ratingColumn.setPreferredWidth(60);

    TableColumn favorColumn = bookTable_.getColumnModel().getColumn(4);
    favorColumn.setMaxWidth(60);
    favorColumn.setMaxWidth(60);
    favorColumn.setPreferredWidth(60);

    sorter_ = new TableRowSorter<BookTableModel>(bookTableModel_);
    bookTable_.setRowSorter(sorter_);
    sorter_.setSortsOnUpdates(true);

    ImageIcon starIcon = new ImageIcon(LibraryApp.class.getResource("../icons/flatstar.png"));
    JLabel ratingLabel = new JLabel("", starIcon, JLabel.CENTER);
    TableCellRenderer ratingRenderer = new HeaderRenderer();
    ratingColumn.setHeaderRenderer(ratingRenderer);
    ratingColumn.setHeaderValue(ratingLabel);

    ImageIcon heartIcon = new ImageIcon(LibraryApp.class.getResource("../icons/flatheart.png"));
    JLabel favorLabel = new JLabel("", heartIcon, JLabel.CENTER);
    TableCellRenderer favorRenderer = new HeaderRenderer();
    favorColumn.setHeaderRenderer(favorRenderer);
    favorColumn.setHeaderValue(favorLabel);

    keywordLabel_.setIcon(heartIcon);
    keywordField_.addActionListener(new KeywordActionListener());
    keywordField_.getDocument().addDocumentListener(new KeywordDocumentListener());
    keywordField_.getDocument().putProperty("name", "Keyword Field");

    keywordField_.setText("a,e,i,o,u,y");

    this.pack();
    this.setVisible(true);
  }
  public AttributesEditionPanel(
      final Component parent,
      final DiagramManager diagramManager,
      final ClassElement classElement,
      final Classifier element) {
    this.diagramManager = diagramManager;
    this.classElement = classElement;
    this.element = element;
    this.parent = parent;

    attributesTableModel = new AttributeTableModel(element);

    panel = new JPanel();
    panel.setBorder(BorderFactory.createTitledBorder(""));

    GroupLayout groupLayout = new GroupLayout(this);
    groupLayout.setHorizontalGroup(
        groupLayout
            .createParallelGroup(Alignment.LEADING)
            .addComponent(panel, GroupLayout.DEFAULT_SIZE, 450, Short.MAX_VALUE));
    groupLayout.setVerticalGroup(
        groupLayout
            .createParallelGroup(Alignment.LEADING)
            .addComponent(panel, GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE));

    scrollpane = new JScrollPane();
    scrollpane.setMinimumSize(new Dimension(0, 0));
    scrollpane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    scrollpane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    scrollpane.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));

    table = new JTable();
    scrollpane.setViewportView(table);
    table.setModel(attributesTableModel);

    table.setBorder(new EmptyBorder(0, 0, 0, 0));
    table.setFillsViewportHeight(true);
    table.setGridColor(Color.LIGHT_GRAY);
    table.setSelectionBackground(ColorPalette.getInstance().getColor(ThemeColor.GREEN_MEDIUM));
    table.setSelectionForeground(Color.BLACK);
    table.setFocusable(false);
    table.setRowHeight(23);

    btnCreate = new JButton("");
    btnCreate.setFocusable(false);
    btnCreate.setToolTipText("Add new attribute to this class");
    btnCreate.setIcon(
        new ImageIcon(AttributesEditionPanel.class.getResource("/resources/icons/x16/new.png")));
    btnCreate.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            addAttribute(arg0);
          }
        });

    btnDelete = new JButton("");
    btnDelete.setFocusable(false);
    btnDelete.setToolTipText("Delete selected attribute");
    btnDelete.setIcon(
        new ImageIcon(AttributesEditionPanel.class.getResource("/resources/icons/x16/cross.png")));
    btnDelete.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            deleteAttribute(arg0);
          }
        });

    btnUp = new JButton("");
    btnUp.setFocusable(false);
    btnUp.setToolTipText("Move up selected attribute");
    btnUp.setIcon(
        new ImageIcon(
            AttributesEditionPanel.class.getResource("/resources/icons/x16/arrow_up.png")));
    btnUp.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            moveUpAttribute();
          }
        });

    btnDown = new JButton("");
    btnDown.setFocusable(false);
    btnDown.setToolTipText("Move down selected attribute");
    btnDown.setIcon(
        new ImageIcon(
            AttributesEditionPanel.class.getResource("/resources/icons/x16/arrow_down.png")));
    btnDown.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            moveDownAttribute();
          }
        });

    btnEdit = new JButton("");
    btnEdit.setEnabled(true);
    btnEdit.setFocusable(false);
    btnEdit.setToolTipText("Edit selected attribute");
    btnEdit.setIcon(
        new ImageIcon(AttributesEditionPanel.class.getResource("/resources/icons/x16/pencil.png")));
    btnEdit.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            int row = table.getSelectedRow();
            if (row >= 0) {
              Property p = attributesTableModel.getEntry(row);
              if (parent instanceof JFrame) {
                AttributeDialog dialog =
                    new AttributeDialog(
                        (JFrame) parent, diagramManager, classElement, element, p, false);
                dialog.setLocationRelativeTo(parent);
                dialog.setVisible(true);
              } else if (parent instanceof JDialog) {
                AttributeDialog dialog =
                    new AttributeDialog(
                        (JDialog) parent, diagramManager, classElement, element, p, false);
                dialog.setLocationRelativeTo(parent);
                dialog.setVisible(true);
              }
            }
          }
        });

    cbxVisible = new JCheckBox("Turn attributes visible");
    cbxVisible.setPreferredSize(new Dimension(140, 20));
    cbxVisible.setHorizontalAlignment(SwingConstants.LEFT);

    GroupLayout gl_panel = new GroupLayout(panel);
    gl_panel.setHorizontalGroup(
        gl_panel
            .createParallelGroup(Alignment.LEADING)
            .addGroup(
                Alignment.TRAILING,
                gl_panel
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        gl_panel
                            .createParallelGroup(Alignment.TRAILING)
                            .addComponent(
                                scrollpane,
                                Alignment.LEADING,
                                GroupLayout.DEFAULT_SIZE,
                                426,
                                Short.MAX_VALUE)
                            .addGroup(
                                gl_panel
                                    .createSequentialGroup()
                                    .addComponent(
                                        btnUp,
                                        GroupLayout.PREFERRED_SIZE,
                                        32,
                                        GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(ComponentPlacement.RELATED)
                                    .addComponent(
                                        btnDown,
                                        GroupLayout.PREFERRED_SIZE,
                                        32,
                                        GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(ComponentPlacement.RELATED)
                                    .addComponent(
                                        cbxVisible, GroupLayout.DEFAULT_SIZE, 236, Short.MAX_VALUE)
                                    .addGap(10)
                                    .addComponent(
                                        btnCreate,
                                        GroupLayout.PREFERRED_SIZE,
                                        32,
                                        GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(ComponentPlacement.RELATED)
                                    .addComponent(
                                        btnDelete,
                                        GroupLayout.PREFERRED_SIZE,
                                        32,
                                        GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(ComponentPlacement.RELATED)
                                    .addComponent(
                                        btnEdit,
                                        GroupLayout.PREFERRED_SIZE,
                                        32,
                                        GroupLayout.PREFERRED_SIZE)))
                    .addContainerGap()));
    gl_panel.setVerticalGroup(
        gl_panel
            .createParallelGroup(Alignment.LEADING)
            .addGroup(
                gl_panel
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        gl_panel
                            .createParallelGroup(Alignment.LEADING)
                            .addComponent(
                                btnDown, GroupLayout.PREFERRED_SIZE, 32, GroupLayout.PREFERRED_SIZE)
                            .addComponent(
                                btnUp, GroupLayout.PREFERRED_SIZE, 32, GroupLayout.PREFERRED_SIZE)
                            .addComponent(
                                cbxVisible,
                                GroupLayout.PREFERRED_SIZE,
                                32,
                                GroupLayout.PREFERRED_SIZE)
                            .addComponent(
                                btnCreate,
                                GroupLayout.PREFERRED_SIZE,
                                32,
                                GroupLayout.PREFERRED_SIZE)
                            .addComponent(
                                btnDelete,
                                GroupLayout.PREFERRED_SIZE,
                                32,
                                GroupLayout.PREFERRED_SIZE)
                            .addComponent(
                                btnEdit,
                                GroupLayout.PREFERRED_SIZE,
                                32,
                                GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(scrollpane, GroupLayout.DEFAULT_SIZE, 169, Short.MAX_VALUE)
                    .addGap(10)));
    panel.setLayout(gl_panel);
    this.setLayout(groupLayout);

    setSize(450, 221);

    if (classElement != null) {
      cbxVisible.setSelected(classElement.showAttributes());
      cbxVisible.setEnabled(true);
    } else {
      cbxVisible.setSelected(false);
      cbxVisible.setEnabled(false);
    }

    myPostInit();
  }