private void rebuildModel() { myModel.clear(); myList.setFixedCellWidth(myList.getWidth()); List<IMessage> messagesToAdd = new ArrayList<IMessage>(); int width = 0; for (IMessage m : myMessages) { if (isVisible(m)) { width = Math.max(width, getMessageWidth(m)); messagesToAdd.add(m); } } myList.setFixedCellWidth(width); myModel.addAll(messagesToAdd); }
public void setRowHeader() { listRowHeader = new JList(); listRowHeader.setListData(rowHeader); listRowHeader.setFixedCellWidth(60); listRowHeader.setFixedCellHeight(20); listRowHeader.setBackground(new java.awt.Color(214, 217, 223)); listRowHeader.setCellRenderer(new RowTable(table)); Scroll.setRowHeaderView(listRowHeader); // System.out.println(table.getTableHeader().getBackground()); }
@SuppressWarnings("unchecked") public CommandView() { JLabel jlabel = new JLabel("Clients Commands :"); jlabel.setAlignmentX(0); add(jlabel); entries = new DefaultListModel(); sampleJList = new JList(entries); setBackground(Color.white); sampleJList.setFixedCellWidth(900); sampleJList.setVisibleRowCount(10); JScrollPane listPane = new JScrollPane(sampleJList); add(listPane); }
public TeamPanel(int teamSize, GameDTO game, List<Participant> players) { super(); setOpaque(false); list = new JList(); list.setVisibleRowCount(teamSize); list.setOpaque(false); list.setCellRenderer(new ChampSelectCellRenderer()); list.setFixedCellHeight(90); list.setFixedCellWidth(130); updateGame(game, players); JScrollPane scroll = new JScrollPane(list); // scroll.setMinimumSize(new Dimension(160, scroll.getPreferredSize().height)); add(scroll, BorderLayout.CENTER); }
public void init() { keyboard = new Keyboard(); CheckBoxChange checkBoxChange = new CheckBoxChange(); // build input begin ------------------ sendStringsCheckBox = new JCheckBox(); sendStringsCheckBox.setName("send strings"); JButton keyboardButton = new JButton( "<html><body><table><tr><td align=\"center\">click here</td></tr><tr><td align=\"center\">for keyboard</td></tr><tr><td align=\"center\">control.</td></tr></table></body></html>"); display.add(keyboardButton, gc); keyboardButton.addKeyListener(keyboard); ++gc.gridx; display.add(sendStringsCheckBox, gc); ++gc.gridx; display.add(new JLabel("send strings"), gc); currentLog = new JList(logModel); currentLog.setFixedCellWidth(400); currentLog.addListSelectionListener(this); currentLog.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); currentLog.setVisibleRowCount(10); TitledBorder title; JPanel logPanel = new JPanel(); JScrollPane logScrollPane = new JScrollPane(currentPlayers); title = BorderFactory.createTitledBorder("key log"); logPanel.setBorder(title); logPanel.add(logScrollPane); gc.gridx = 0; gc.gridwidth = 3; ++gc.gridy; display.add(logPanel, gc); JScrollPane currentFiltersScrollPane2 = new JScrollPane(currentLog); logPanel.add(currentFiltersScrollPane2); sendStringsCheckBox.addChangeListener(checkBoxChange); }
public EdgeStyleManager(MapCanvas canvas) { setTitle("Edge Style Manager"); this.canvas = canvas; this.styles = canvas.getModel().edgeStyles; jlistModel = new DefaultListModel(); for (int i = 0; i < styles.size(); i++) jlistModel.addElement(((LineStyle) styles.get(i)).getId()); jlist = new JList(jlistModel); jlist.addListSelectionListener(this); jlist.setFixedCellWidth(100); JScrollPane sp = new JScrollPane(jlist); setLayout(new GridLayout(1, 2)); JPanel p1 = new JPanel(new BorderLayout(5, 5)); JPanel p2 = new JPanel(); JPanel p3 = new JPanel(new GridLayout(1, 3)); btnAdd = new JButton("Add"); btnAdd.addActionListener(this); btnEdit = new JButton("Edit"); btnEdit.addActionListener(this); btnDel = new JButton("Del"); btnDel.addActionListener(this); p3.add(btnAdd); p3.add(btnEdit); p3.add(btnDel); p2.add(p3); p1.add(p2, BorderLayout.SOUTH); p1.add(sp, BorderLayout.CENTER); add(p1); preview = new EdgeStylePreview(); JPanel p4 = new JPanel(new BorderLayout()); p4.setBorder(BorderFactory.createLoweredBevelBorder()); p4.add(preview); add(p4); }
public LinearRegressionPanel(Application app, StatDialog statDialog) { this.app = app; kernel = app.getKernel(); this.statDialog = statDialog; this.setOpaque(true); this.setBackground(Color.WHITE); this.setLayout(new BorderLayout()); // north panel with regression equation Box northPanel = Box.createVerticalBox(); northPanel.add(new JLabel(" ---- regresion equation ----")); northPanel.add(new JLabel(" ----------------------------")); // south panel with additional statistics Box southPanel = Box.createVerticalBox(); southPanel.add(new JLabel(" ---- regresion equation ----")); southPanel.add(new JLabel(" ----------------------------")); // set up table model = new DefaultTableModel(); headerModel = new DefaultListModel(); JTable table = new JTable(model); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); table.setGridColor(GeoGebraColorConstants.TABLE_GRID_COLOR); table.setShowGrid(true); // table row header JList rowHeader = new JList(headerModel); rowHeader.setFixedCellWidth(50); rowHeader.setFixedCellHeight(table.getRowHeight() + table.getRowMargin()); rowHeader.setCellRenderer(new RowHeaderRenderer(table)); // add table to scroll pane JScrollPane scroll = new JScrollPane(table); scroll.setRowHeaderView(rowHeader); this.add(scroll, BorderLayout.CENTER); }
public EchoAWT() throws UnknownHostException { super("채팅 프로그램"); // 각종 정의 h = new JPanel(new GridLayout(2, 3)); m = new JPanel(new BorderLayout()); f = new JPanel(new BorderLayout()); s = new JPanel(new BorderLayout()); login = new JPanel(new BorderLayout()); // name = new JLabel(" 사용자 이름 "); name = new JLabel(" 메세지 입력 "); jta = new JTextArea(); // clientList = new JTextArea(0, 10); clientList = new JList(); jsp = new JScrollPane(jta); list = new JScrollPane(clientList); jtf = new JTextField("입력하세요."); hi = new JTextField("HOST IP 입력"); pi = new JTextField("PORT 입력"); localport = new JTextField("원하는 PORT 입력"); lid = new JTextField("ID를 입력하세요."); lpw = new JTextField("PW를 입력하세요."); serveropen = new JButton("서버 오픈"); textin = new JButton("입력"); clientin = new JButton("서버 접속"); conf = new JButton("로그인"); join = new JButton("회원가입"); addr = InetAddress.getLocalHost(); // 사용자 해상도 및 창 크기 설정 및 가져오기. Toolkit tk = Toolkit.getDefaultToolkit(); Dimension screenSize = tk.getScreenSize(); setSize(500, 500); Dimension d = getSize(); // 각종 버튼 및 텍스트 필드 리스너 jtf.addActionListener(this); hi.addActionListener(this); pi.addActionListener(this); localport.addActionListener(this); lid.addActionListener(this); lpw.addActionListener(this); conf.addActionListener(this); join.addActionListener(this); serveropen.addActionListener(this); clientin.addActionListener(this); textin.addActionListener(this); jtf.addFocusListener(this); hi.addFocusListener(this); pi.addFocusListener(this); localport.addFocusListener(this); lid.addFocusListener(this); lpw.addFocusListener(this); // 서버 접속 h.add(hi); h.add(pi); h.add(clientin); // 서버 생성 h.add(new JLabel("IP : " + addr.getHostAddress(), (int) CENTER_ALIGNMENT)); h.add(localport); h.add(serveropen); // 채팅글창 글 작성 막기 jta.setEditable(false); // 접속자 리스트 width 제한 clientList.setFixedCellWidth(d.width / 3); // 입력 창 f.add(name, "West"); f.add(jtf, "Center"); f.add(textin, "East"); // 접속자 확인창 s.add(new JLabel("접속자", (int) CENTER_ALIGNMENT), "North"); s.add(list, "Center"); // clientList.setEditable(false); // 메인 창 m.add(jsp, "Center"); m.add(s, "East"); // 프레임 설정 add(h, "North"); add(m, "Center"); add(f, "South"); // 로그인 다이얼로그 jd = new JDialog(); jd.setTitle("채팅 로그인"); jd.add(login); jd.setSize(200, 200); Dimension dd = jd.getSize(); jd.setLocation(screenSize.width / 2 - (dd.width / 2), screenSize.height / 2 - (dd.height / 2)); jd.setVisible(true); // 로그인창 JPanel lm = new JPanel(new GridLayout(4, 1)); lm.add(lid); lm.add(new Label()); lm.add(lpw); lm.add(new Label()); JPanel bt = new JPanel(); bt.add(conf); bt.add(join); login.add(new Label(), "North"); login.add(new Label(), "West"); login.add(new Label(), "East"); login.add(lm, "Center"); login.add(bt, "South"); // 창의 위치, 보임, EXIT 단추 활성화. setLocation(screenSize.width / 2 - (d.width / 2), screenSize.height / 2 - (d.height / 2)); setVisible(false); setDefaultCloseOperation(EXIT_ON_CLOSE); }
public SQLiteDataBrowser() { SQLiteDbManager dbManager = new SQLiteDbManager(); setLayout(new BorderLayout()); showTablesList = new JList(); showTablesList.setLayoutOrientation(JList.VERTICAL_WRAP); showTablesList.setSelectedIndex(ListSelectionModel.SINGLE_SELECTION); showTablesList.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); showTablesList.setFont(new Font("Times New Roman", Font.PLAIN, 13)); showTablesList.setDragEnabled(false); showTablesList.setFixedCellWidth(150); showTablesList.setVisibleRowCount(-1); showTablesList.setEnabled(false); showTablesListScroller = new JScrollPane(showTablesList); showTablesListScroller.setBorder( BorderFactory.createTitledBorder(new LineBorder(Color.BLACK), "List of Tables")); showTablesListScroller.setPreferredSize(new Dimension(160, this.getHeight())); add(showTablesListScroller, BorderLayout.EAST); loadDbPanel = new JPanel(new FlowLayout()); loadDbPanel.setBackground(new Color(0xe8e8e8)); loadDbPanel.setPreferredSize(new Dimension(getWidth(), 40)); loadDbLabel = new JLabel("Load SQLite Database: "); loadDbLabel.setToolTipText("Possible extensions being .sqlite|.sqlite3|.db|.db3"); loadedDbPath = new JTextField("Click browse to choose the database file.", 60); loadedDbPath.setForeground(Color.GRAY); loadedDbPath.setFont(new Font("Times New Roman", Font.ITALIC, 13)); loadedDbPath.setEditable(false); lastFolderLocation = new File(Utils.getUserHome()); fc = new JFileChooser(lastFolderLocation); browseDb = new JButton("Browse"); browseDb.addActionListener( actionEvent -> { int retVal = fc.showOpenDialog(SQLiteDataBrowser.this); if (retVal == JFileChooser.APPROVE_OPTION) { File dbPath = fc.getSelectedFile(); if (Utils.checkIfSQLiteDb(dbPath)) { loadedDbPath.setText(dbPath.toString()); lastFolderLocation = fc.getCurrentDirectory(); new SwingWorker<Void, Void>() { @Override protected Void doInBackground() throws Exception { try { dbManager.setDbPath(dbPath.toString()); dbManager.initialize(); showTablesList.setListData(dbManager.getTables().toArray()); showTablesList.setEnabled(true); } catch (SQLException e) { e.printStackTrace(); } return null; } }.execute(); } else { JOptionPane.showMessageDialog( SQLiteDataBrowser.this, "The Selected file is not in SQLite Format", "File Format Error", JOptionPane.ERROR_MESSAGE); loadedDbPath.setText("Click browse to choose the database file."); } } }); loadDbPanel.add(loadDbLabel); loadDbPanel.add(loadedDbPath); loadDbPanel.add(browseDb); loadDbRecords = new JLabel("Records Fetched (Rows x Cols): "); loadDbRecords.setFont(new Font("Times New Roman", Font.ITALIC, 12)); loadDbPanel.add(loadDbRecords); loadDbRecordsCount = new JLabel(); loadDbRecordsCount.setFont(new Font("Times New Roman", Font.ITALIC, 12)); loadDbPanel.add(loadDbRecordsCount); final class DataBrowserTableModal extends DefaultTableModel { public DataBrowserTableModal() {} public DataBrowserTableModal(Object[][] tableData, Object[] colNames) { super(tableData, colNames); } @Override public void setDataVector(Object[][] tableData, Object[] colNames) { super.setDataVector(tableData, colNames); } @Override public boolean isCellEditable(int row, int column) { return false; } } DataBrowserTableModal tableModal = new DataBrowserTableModal(); defaultTableModel = tableModal; table = new JTable(); table.setModel(defaultTableModel); showTablesList.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { JList list = (JList) evt.getSource(); if (evt.getClickCount() == 2) { String tableName = list.getSelectedValue().toString(); new SwingWorker<Void, Void>() { @Override protected Void doInBackground() throws Exception { try { ResultSet rs = dbManager.executeQuery("SELECT * from " + tableName); Vector<String> columnNames = dbManager.getColumnNames(rs); Vector<Vector<Object>> tableData = new Vector<>(); while (rs.next()) { Vector<Object> vector = new Vector<>(); for (int i = 1; i <= columnNames.size(); i++) { vector.add(rs.getObject(i)); } tableData.add(vector); } defaultTableModel.setDataVector(tableData, columnNames); } catch (SQLException e) { e.printStackTrace(); } loadDbRecordsCount.setText( defaultTableModel.getRowCount() + " x " + defaultTableModel.getColumnCount()); if (defaultTableModel.getColumnCount() < 5) { table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); } else { table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); } return null; } }.execute(); } } }); tableScrollPane = new JScrollPane(table); tableScrollPane.setHorizontalScrollBarPolicy( ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); tableScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); tableScrollPane.setPreferredSize(new Dimension(getWidth(), getHeight())); add(tableScrollPane, BorderLayout.CENTER); add(loadDbPanel, BorderLayout.NORTH); }
/** * The main method that runs when the program is launched. * * @param args command line arguments. Unused. */ public static void main(String[] args) { // Sets up the Font used for title try { titleFont = Font.createFont(Font.TRUETYPE_FONT, new File("EXPLETUSSANS-BOLD.ttf")); } catch (FontFormatException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } titleFont = titleFont.deriveFont(Font.BOLD, 28f); // Creates main window and icon frame = new JFrame("quickCheck"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setResizable(false); ImageIcon frameIcon = new ImageIcon(QuickCheck.class.getResource("/logo.png")); frame.setIconImage(frameIcon.getImage()); /*Required to instantiate an inner class*/ QuickCheck thisProgram = new QuickCheck(); // Sets up upper panel JPanel upperPanel = new JPanel(); upperPanel.setBackground(TOP_COLOR); upperPanel.setPreferredSize(new Dimension(WINDOW_WIDTH, 44)); upperPanel.add(upperLabel); QuickCheck.ContentFrame lowerPanel = thisProgram.new ContentFrame(); // Sets up title bar (upperPanel) and actual content pane (lowerPanel) frame.getContentPane().add(upperPanel, "North"); frame.getContentPane().add(lowerPanel, "South"); // Sets up font of title bar upperLabel.setFont(titleFont); // Creates the scroll bar for the text on the left JScrollPane textScrollHolder = new JScrollPane(text); textScrollHolder.setBorder(BorderFactory.createEmptyBorder()); // Creates the text field on the left side text.setCaretPosition(0); lowerPanel.getLeft().add(textScrollHolder); text.setLineWrap(true); text.setWrapStyleWord(true); // Adds text field errorsListener QuickCheck.TypeListener lstn = thisProgram.new TypeListener(); text.getDocument().addDocumentListener(lstn); // Creates upper-right panel JPanel rightNestedUpper = new JPanel(); rightNestedUpper.setLayout(new FlowLayout(FlowLayout.CENTER, 20, 20)); rightNestedUpper.setBackground(RIGHT_COLOR); // Creates lower-right panel JPanel rightNestedLower = new JPanel(); rightNestedLower.setLayout(new FlowLayout(FlowLayout.CENTER, 20, 20)); rightNestedLower.setBackground(RIGHT_COLOR); BorderLayout rightLayout = new BorderLayout(); lowerPanel.getRight().setLayout(rightLayout); lowerPanel.getRight().add(rightNestedUpper); // Creates middle-right panel JPanel rightNestedInner = new JPanel(); BoxLayout rightNestedInnerLayout = new BoxLayout(rightNestedInner, BoxLayout.Y_AXIS); rightNestedInner.setLayout(rightNestedInnerLayout); // Adds middle-right panel to right side, then error text to it. lowerPanel.getRight().add(rightNestedInner, BorderLayout.CENTER); /*Error Word List Label Setup */ // Creates Error JLabel and sets up its font Font errorFont = titleFont.deriveFont(Font.BOLD, 22f); JLabel errorLabel = new JLabel("Errors"); errorLabel.setFont(errorFont); // Creates wrapper to center JLabel JPanel errorLabelPanel = new JPanel(); errorLabelPanel.add(errorLabel); Box box = new Box(BoxLayout.Y_AXIS); box.setAlignmentX(Component.CENTER_ALIGNMENT); box.add(Box.createVerticalGlue()); box.add(errorLabelPanel); box.add(Box.createVerticalGlue()); // Adds first the JLabel wrapper, then the JLabel lowerPanel.getRight().add(box, BorderLayout.NORTH); box.add(errorLabelPanel); /*Error Word List Setup*/ // Error words List creation errorsList = new JList<String>(errListModel); errorsList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); errorsList.setLayoutOrientation(JList.VERTICAL); errorsList.setVisibleRowCount(10); errorsList.setFixedCellHeight(15); errorsList.setFixedCellWidth(100); // Error words List scroll bar JScrollPane errorsListScroller = new JScrollPane(errorsList); errorsListScroller.setPreferredSize(new Dimension(250, 80)); errorsListScroller.setBorder(BorderFactory.createEmptyBorder()); // Adding both the List and the Scroll bar to the right inner panel rightNestedInner.add(errorsListScroller); /*Correction Word List Label Setup */ // Creates Correction JLabel and sets up its font Font correctionFont = titleFont.deriveFont(Font.BOLD, 22f); JLabel correctionLabel = new JLabel("Corrections"); correctionLabel.setFont(correctionFont); // Creates wrapper to center JLabel JPanel correctionLabelPanel = new JPanel(); correctionLabelPanel.add(correctionLabel); Box box2 = new Box(BoxLayout.Y_AXIS); box2.setAlignmentX(Component.CENTER_ALIGNMENT); box2.add(Box.createVerticalGlue()); box2.add(correctionLabelPanel); box2.add(Box.createVerticalGlue()); // Adds first the JLabel wrapper, then the JLabel rightNestedLower.add(box2); box2.add(correctionLabelPanel); /*Correction Word List Setup*/ // Correction words List creation correctionsList = new JList<String>(correctionsListModel); correctionsList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); correctionsList.setLayoutOrientation(JList.VERTICAL); correctionsList.setVisibleRowCount(10); correctionsList.setFixedCellHeight(15); correctionsList.setFixedCellWidth(100); // Error words List scroll bar JScrollPane correctionsListScroller = new JScrollPane(correctionsList); correctionsListScroller.setPreferredSize(new Dimension(250, 80)); correctionsListScroller.setBorder(BorderFactory.createEmptyBorder()); // Creates wrapper JPanel for both corrections title and contents JPanel correctionsWrapper = new JPanel(); BoxLayout correctionsWrapperLayout = new BoxLayout(correctionsWrapper, BoxLayout.Y_AXIS); correctionsWrapper.setLayout(correctionsWrapperLayout); correctionsWrapper.add(correctionLabelPanel); correctionsWrapper.add(correctionsListScroller); JPanel buttonHolder = new JPanel(); BoxLayout buttonHolderLayout = new BoxLayout(buttonHolder, BoxLayout.Y_AXIS); buttonHolder.setLayout(buttonHolderLayout); correctionsWrapper.add(buttonHolder); // Creates wrapper to center JLabel JPanel btnHold1 = new JPanel(); btnHold1.setBackground(RIGHT_COLOR); JPanel btnHold2 = new JPanel(); btnHold2.setBackground(RIGHT_COLOR); JPanel btnHold3 = new JPanel(); btnHold3.setBackground(RIGHT_COLOR); Box box3 = new Box(BoxLayout.Y_AXIS); box3.setAlignmentX(Component.CENTER_ALIGNMENT); box3.add(btnHold1); box3.add(Box.createVerticalGlue()); box3.add(btnHold2); box3.add(Box.createVerticalGlue()); box3.add(btnHold3); box3.add(Box.createVerticalGlue()); // Adding both the List and the Scroll bar to the right inner panel rightNestedLower.add(correctionsWrapper); // Sets colors for panels rightNestedInner.setBackground(RIGHT_COLOR); errorLabelPanel.setBackground(RIGHT_COLOR); correctionLabelPanel.setBackground(RIGHT_COLOR); // Adds lower-right panel lowerPanel.getRight().add(rightNestedLower, BorderLayout.SOUTH); rightNestedLower.setPreferredSize(new Dimension(300, 350)); rightNestedInner.setMaximumSize(new Dimension(300, 0)); rightNestedUpper.setPreferredSize(new Dimension(300, 0)); lowerPanel.getLeft().setMaximumSize(new Dimension(WINDOW_WIDTH, WINDOW_HEIGHT)); // errorsList listeners and setup errorsList.addListSelectionListener(selectClickListener); errorsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); ImageIcon corBtnIcon = new ImageIcon(QuickCheck.class.getResource("/bt1def.png")); ImageIcon corAllBtnIcon = new ImageIcon(QuickCheck.class.getResource("/bt2def.png")); ImageIcon ignoreBtnIcon = new ImageIcon(QuickCheck.class.getResource("/bt3def.png")); b1 = new JButton("", corBtnIcon); b2 = new JButton("", corAllBtnIcon); b3 = new JButton("", ignoreBtnIcon); b1.setActionCommand("disable"); b1.setBorderPainted(false); b1.setFocusPainted(false); b1.setContentAreaFilled(false); b2.setActionCommand("disable"); b2.setBorderPainted(false); b2.setFocusPainted(false); b2.setContentAreaFilled(false); b3.setActionCommand("disable"); b3.setBorderPainted(false); b3.setFocusPainted(false); b3.setContentAreaFilled(false); // QuickCheck.btnListener listen = thisProgram.new btnListener(b1); // b1.addActionListener(listen); // b1.setPreferredSize(new Dimension(100,50)); // b2.setPreferredSize(new Dimension(100,50)); // b3.setPreferredSize(new Dimension(100,50)); buttonHolder.add(box3); btnHold1.add(b1); btnHold2.add(b2); btnHold3.add(b3); CorrBtnListener mouseListen = thisProgram.new CorrBtnListener(); b1.addMouseListener(mouseListen); CorrAllBtnListener corAllListen = thisProgram.new CorrAllBtnListener(); b2.addMouseListener(corAllListen); IgnoreBtnListener ignoreListen = thisProgram.new IgnoreBtnListener(); b3.addMouseListener(ignoreListen); frame.pack(); frame.setVisible(true); }
/** GUI element creating and arrangment. Partially generated using NetBeans IDE GUI utilities. */ @SuppressWarnings("unchecked") private void initComponents() { jButtonOldPackages = new JButton(); jTextDate = new JTextField(); jButtonSetLost = new JButton(); jButtonSetFound = new JButton(); jButtonShowLost = new JButton(); jButtonExit = new JButton(); jButtonReset = new JButton(); jScrollPane1 = new JScrollPane(); jListScans = new JList(); jScrollPane2 = new JScrollPane(); jListPackages = new JList(); jButtonSetFound.setEnabled(false); jButtonSetLost.setEnabled(false); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jButtonOldPackages.setText("Timed out packages"); jButtonOldPackages.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { buttonOldPackagesActionPerformed(event); } }); ListSelectionListener listSelectionListener = new ListSelectionListener() { public void valueChanged(ListSelectionEvent event) { jListPackagesActionPertformed(event); } }; jButtonExit.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { System.exit(0); } }); jButtonSetLost.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { buttonSetLostActionPerformed(event); } }); jButtonSetFound.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { buttonSetFoundActionPerformed(event); } }); jButtonShowLost.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { buttonShowLostActionPerformed(event); } }); jButtonReset.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { reset(event); } }); jListPackages.addListSelectionListener(listSelectionListener); jButtonSetLost.setText("List as Lost"); jButtonShowLost.setText("Lost Packages"); jButtonSetFound.setText("List as Found"); jButtonExit.setText("Logout"); jButtonReset.setText("Reset"); jScrollPane2.setViewportView(jListPackages); jScrollPane2.setPreferredSize(new Dimension(200, 200)); jListPackages.setFixedCellWidth(400); jScrollPane1.setViewportView(jListScans); // Layout javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addContainerGap() .addComponent( jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(111, 111, 111) .addComponent( jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(111, 111, 111) .addGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent( jTextDate, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( jButtonSetLost, javax.swing.GroupLayout.Alignment.TRAILING) .addComponent( jButtonOldPackages, javax.swing.GroupLayout.Alignment.TRAILING) .addComponent( jButtonShowLost, javax.swing.GroupLayout.Alignment.TRAILING) .addComponent( jButtonSetFound, javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jButtonReset, javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jButtonExit, javax.swing.GroupLayout.Alignment.TRAILING)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); layout.setVerticalGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addGap(42, 42, 42) .addComponent( jTextDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButtonOldPackages) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButtonSetLost) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButtonSetFound) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButtonShowLost) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButtonReset) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButtonExit)) .addGroup( layout .createSequentialGroup() .addContainerGap() .addComponent( jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 258, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent( jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 289, Short.MAX_VALUE)) .addContainerGap())); pack(); }
public EditPackageDialog(JFrame frame) { super(frame, "Package Management- Edit a TV Package", true); label1 = new JLabel("Package Code: "); label2 = new JLabel("Package Name: "); error3 = new JLabel("Blank input occured! Please reenter it."); label3 = new JLabel("Charge Price(RM): "); error4 = new JLabel("Blank input occured! Please reenter it."); error6 = new JLabel("Wrong input format. Please enter in numeric format!"); label4 = new JLabel("Charge Type: "); error5 = new JLabel("Blank input occured! Please reenter it."); error7 = new JLabel("You must have at least one programme added to your package."); label5 = new JLabel("Programmes: "); label6 = new JLabel("Programmes inside this Package: "); textfield1 = new JTextField(15); textfield2 = new JTextField(15); textfield3 = new JTextField(15); textfield3.setEditable(false); combobox1 = new JComboBox(); button1 = new JButton("Submit"); button2 = new JButton("Cancel"); addBut = new JButton("", new ImageIcon(getClass().getResource("/resources/addtoright.png"))); rmvBut = new JButton("", new ImageIcon(getClass().getResource("/resources/removetoleft.png"))); addBut.setBackground(new Color(23, 28, 31)); rmvBut.setBackground(new Color(23, 28, 31)); color = new Color(23, 28, 30); color1 = new Color(244, 219, 234); color2 = new Color(239, 237, 237); textfield3.setBackground(color2); selPrgList = new LinkedList<>(); leftModel = new DefaultListModel(); rightModel = new DefaultListModel(); for (int i = 0; i < App.prgList.size(); i++) { for (int j = 0; j < App.pckgingList.size(); j++) { if (PackagePanel.pkgtemp[0].equalsIgnoreCase(App.pckgingList.get(j).getPkgCode())) { if (App.pckgingList .get(j) .getProgCode() .equalsIgnoreCase(App.prgList.get(i).getProgCode())) { selPrgList.add(App.pckgingList.get(j).getProgCode()); ((DefaultListModel) rightModel) .addElement( App.pckgingList.get(j).getProgCode() + "-" + App.prgList.get(i).getProgTitle()); } } } } selPrg = selPrgList.toArray(new String[selPrgList.size()]); for (int i = 0; i < App.prgList.size(); i++) { boolean check = false; for (int j = 0; j < selPrg.length; j++) { if (selPrg[j].equalsIgnoreCase(App.prgList.get(i).getProgCode())) { check = true; break; } } if (check == false) { if (!(App.prgList.get(i).getPrgStatus().equalsIgnoreCase("TERMINATED"))) { ((DefaultListModel) leftModel) .addElement( App.prgList.get(i).getProgCode() + "-" + App.prgList.get(i).getProgTitle()); } } } leftList = new JList(leftModel); leftList.setModel(leftModel); leftList.setVisibleRowCount(13); leftList.setFixedCellWidth(210); leftList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); rightList = new JList(rightModel); rightList.setModel(rightModel); rightList.setVisibleRowCount(13); rightList.setFixedCellWidth(210); rightList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); leftListScroll = new JScrollPane(leftList); leftListScroll.setViewportView(leftList); rightListScroll = new JScrollPane(rightList); rightListScroll.setViewportView(rightList); Container container = getContentPane(); container.setBackground(color); SpringLayout spring = new SpringLayout(); String[] string1 = { "<-----Please Choose a charge type----->", "Monthly", "Quarterly", "Annually" }; combobox1.setModel(new DefaultComboBoxModel(string1)); error3.setForeground(Color.RED); error4.setForeground(Color.RED); error5.setForeground(Color.RED); error6.setForeground(Color.RED); error7.setForeground(Color.RED); error3.setVisible(false); error4.setVisible(false); error5.setVisible(false); error6.setVisible(false); error7.setVisible(false); label1.setForeground(color1); label2.setForeground(color1); label3.setForeground(color1); label4.setForeground(color1); label5.setForeground(color1); label6.setForeground(color1); textfield3.setText(PackagePanel.pkgtemp[0]); textfield1.setText(PackagePanel.pkgtemp[1]); textfield2.setText(PackagePanel.pkgtemp[2]); combobox1.setSelectedItem((String) (PackagePanel.pkgtemp[3])); addBut.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { int leftIndex = leftList.getSelectedIndex(); String toBeAdded = ((String) leftList.getModel().getElementAt(leftIndex)); LinkedList<String> leftElements = new LinkedList<>(); for (int p = 0; p < leftList.getModel().getSize(); p++) { leftElements.add((String) leftList.getModel().getElementAt(p)); } for (int i = 0; i < leftElements.size(); i++) { if ((leftElements.get(i)).equals(toBeAdded)) { leftElements.remove(i); break; } } String[] leftElArr = leftElements.toArray(new String[leftElements.size()]); leftList.setListData(leftElArr); leftList.revalidate(); leftList.repaint(); rightElements = new LinkedList<>(); for (int z = 0; z < rightList.getModel().getSize(); z++) { rightElements.add((String) rightList.getModel().getElementAt(z)); } rightElements.add(toBeAdded); rightElArr = rightElements.toArray(new String[rightElements.size()]); rightList.setListData(rightElArr); rightList.repaint(); rightList.revalidate(); } catch (Exception ex) { JOptionPane.showMessageDialog( null, "You can only add a TV Programme from the left list.", "Adding error", JOptionPane.INFORMATION_MESSAGE); } } }); rmvBut.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { int rightIndex = rightList.getSelectedIndex(); String toBeRemoved = ((String) rightList.getModel().getElementAt(rightIndex)); LinkedList<String> rightElements = new LinkedList<>(); for (int p = 0; p < rightList.getModel().getSize(); p++) { rightElements.add((String) rightList.getModel().getElementAt(p)); } for (int i = 0; i < rightElements.size(); i++) { if ((rightElements.get(i)).equals(toBeRemoved)) { rightElements.remove(i); break; } } rightElArr = rightElements.toArray(new String[rightElements.size()]); rightList.setListData(rightElArr); rightList.revalidate(); rightList.repaint(); LinkedList<String> leftElements = new LinkedList<>(); for (int z = 0; z < leftList.getModel().getSize(); z++) { leftElements.add((String) leftList.getModel().getElementAt(z)); } leftElements.add(toBeRemoved); String[] leftElArr = leftElements.toArray(new String[leftElements.size()]); leftList.setListData(leftElArr); leftList.repaint(); leftList.revalidate(); } catch (Exception ex) { JOptionPane.showMessageDialog( null, "You can only remove a TV Programme from the right list when right list is filled in with TV Programme.", "Remove error", JOptionPane.INFORMATION_MESSAGE); } } }); button1.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean flag1 = false, flag2 = false, flag3 = false, flag4 = false; if ((textfield1.getText().trim() == null) || (textfield1.getText().trim().equalsIgnoreCase(""))) { error3.setVisible(true); flag1 = false; } else { flag1 = true; error3.setVisible(false); } if ((textfield2.getText().trim() == null) || (textfield2.getText().trim().equalsIgnoreCase(""))) { error4.setVisible(true); error6.setVisible(false); flag2 = false; } else { try { flag2 = true; error4.setVisible(false); error6.setVisible(false); double a = Double.valueOf(textfield2.getText().trim()).doubleValue(); } catch (NumberFormatException ex) { error4.setVisible(false); error6.setVisible(true); flag2 = false; } } if ((((String) combobox1.getSelectedItem())) .equals("<-----Please Choose a charge type----->")) { error5.setVisible(true); flag3 = false; } else { flag3 = true; error5.setVisible(false); } try { if (rightElArr.length >= 1) { flag4 = true; error7.setVisible(false); } else { flag4 = false; error7.setVisible(true); } } catch (NullPointerException npe) { flag4 = true; } if ((flag1 == true) && (flag2 == true) && (flag3 == true) && (flag4 == true)) { for (int i = 0; i < App.pkgList.size(); i++) { if (App.pkgList.get(i).getPkgCode().equalsIgnoreCase(PackagePanel.pkgtemp[0])) { App.pkgList.get(i).setPkgName(textfield1.getText()); break; } } for (int i = 0; i < App.pkgList.size(); i++) { if (App.pkgList.get(i).getPkgCode().equalsIgnoreCase(PackagePanel.pkgtemp[0])) { App.pkgList .get(i) .setChargePrice(Double.valueOf(textfield2.getText().trim()).doubleValue()); break; } } for (int i = 0; i < App.pkgList.size(); i++) { if (App.pkgList.get(i).getPkgCode().equalsIgnoreCase(PackagePanel.pkgtemp[0])) { App.pkgList.get(i).setChargeType(combobox1.getSelectedItem().toString()); break; } } if (rightElArr != null) { for (int i = 0; i < App.pckgingList.size(); i++) { if (App.pckgingList .get(i) .getPkgCode() .equalsIgnoreCase(PackagePanel.pkgtemp[0])) { App.pckgingList.remove(i); i--; } } for (int i = 0; i < rightElArr.length; i++) { App.pckgingList.addLast( new Packaging(PackagePanel.pkgtemp[0], (rightElArr[i]).substring(0, 4))); } } else { for (int i = 0; i < App.prgList.size(); i++) { for (int j = 0; j < App.pckgingList.size(); j++) { if (PackagePanel.pkgtemp[0].equalsIgnoreCase( App.pckgingList.get(j).getPkgCode())) { if (App.pckgingList .get(j) .getProgCode() .equalsIgnoreCase(App.prgList.get(i).getProgCode())) { selPrgList.add(App.pckgingList.get(j).getProgCode()); ((DefaultListModel) rightModel) .addElement( App.pckgingList.get(j).getProgCode() + "-" + App.prgList.get(i).getProgTitle()); } } } } } JOptionPane.showMessageDialog( null, "You have successfully changed the details of TV Package " + PackagePanel.pkgtemp[0] + " !", PackagePanel.pkgtemp[0] + " edited", JOptionPane.PLAIN_MESSAGE); LogFile log = new LogFile( App.user, "has edited a TV Package '" + PackagePanel.pkgtemp[0] + "'."); App.logList.add(log); dispose(); } } }); button2.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int closeCf = JOptionPane.showConfirmDialog( null, "Stop Adding? All the changes will not be saved.", "Cancel Adding", JOptionPane.WARNING_MESSAGE); if (closeCf == JOptionPane.YES_OPTION) { dispose(); } } }); container.setLayout(spring); container.add(label1); container.add(textfield3); spring.putConstraint(SpringLayout.WEST, label1, 20, SpringLayout.WEST, container); spring.putConstraint(SpringLayout.NORTH, label1, 15, SpringLayout.NORTH, container); spring.putConstraint(SpringLayout.WEST, textfield3, 80, SpringLayout.EAST, label1); spring.putConstraint(SpringLayout.NORTH, textfield3, 15, SpringLayout.NORTH, container); container.add(label2); container.add(textfield1); container.add(error3); spring.putConstraint(SpringLayout.WEST, label2, 20, SpringLayout.WEST, container); spring.putConstraint(SpringLayout.NORTH, label2, 40, SpringLayout.SOUTH, label1); spring.putConstraint(SpringLayout.WEST, textfield1, 80, SpringLayout.EAST, label1); spring.putConstraint(SpringLayout.NORTH, textfield1, 30, SpringLayout.SOUTH, textfield3); spring.putConstraint(SpringLayout.NORTH, error3, -27, SpringLayout.SOUTH, textfield1); spring.putConstraint(SpringLayout.WEST, error3, 260, SpringLayout.EAST, label2); container.add(label3); container.add(textfield2); container.add(error4); container.add(error6); spring.putConstraint(SpringLayout.WEST, label3, 20, SpringLayout.WEST, container); spring.putConstraint(SpringLayout.NORTH, label3, 45, SpringLayout.SOUTH, label2); spring.putConstraint(SpringLayout.WEST, textfield2, 80, SpringLayout.EAST, label1); spring.putConstraint(SpringLayout.NORTH, textfield2, 30, SpringLayout.SOUTH, textfield1); spring.putConstraint(SpringLayout.NORTH, error4, -26, SpringLayout.SOUTH, textfield2); spring.putConstraint(SpringLayout.WEST, error4, 251, SpringLayout.EAST, label3); spring.putConstraint(SpringLayout.NORTH, error6, -26, SpringLayout.SOUTH, textfield2); spring.putConstraint(SpringLayout.WEST, error6, 251, SpringLayout.EAST, label3); container.add(label4); container.add(combobox1); container.add(error5); spring.putConstraint(SpringLayout.WEST, label4, 20, SpringLayout.WEST, container); spring.putConstraint(SpringLayout.NORTH, label4, 40, SpringLayout.SOUTH, label3); spring.putConstraint(SpringLayout.WEST, combobox1, 80, SpringLayout.EAST, label1); spring.putConstraint(SpringLayout.NORTH, combobox1, 30, SpringLayout.SOUTH, textfield2); spring.putConstraint(SpringLayout.NORTH, error5, -26, SpringLayout.SOUTH, combobox1); spring.putConstraint(SpringLayout.WEST, error5, 320, SpringLayout.EAST, label3); container.add(label5); container.add(label6); spring.putConstraint(SpringLayout.WEST, label5, 20, SpringLayout.WEST, container); spring.putConstraint(SpringLayout.NORTH, label5, 20, SpringLayout.SOUTH, label4); spring.putConstraint(SpringLayout.WEST, label6, 280, SpringLayout.EAST, label5); spring.putConstraint(SpringLayout.NORTH, label6, 20, SpringLayout.SOUTH, label4); container.add(leftListScroll); container.add(addBut); container.add(rmvBut); container.add(rightListScroll); container.add(error7); spring.putConstraint(SpringLayout.WEST, leftListScroll, 20, SpringLayout.WEST, container); spring.putConstraint(SpringLayout.NORTH, leftListScroll, 45, SpringLayout.SOUTH, label4); spring.putConstraint(SpringLayout.WEST, addBut, 35, SpringLayout.EAST, leftListScroll); spring.putConstraint(SpringLayout.NORTH, addBut, 52, SpringLayout.SOUTH, label4); spring.putConstraint(SpringLayout.WEST, rmvBut, 25, SpringLayout.EAST, leftListScroll); spring.putConstraint(SpringLayout.NORTH, rmvBut, 10, SpringLayout.SOUTH, addBut); spring.putConstraint(SpringLayout.WEST, rightListScroll, 24, SpringLayout.EAST, rmvBut); spring.putConstraint(SpringLayout.NORTH, rightListScroll, 45, SpringLayout.SOUTH, label4); spring.putConstraint(SpringLayout.WEST, error7, 40, SpringLayout.EAST, label4); spring.putConstraint(SpringLayout.NORTH, error7, 345, SpringLayout.SOUTH, label4); container.add(button1); container.add(button2); spring.putConstraint(SpringLayout.WEST, button1, 222, SpringLayout.WEST, container); spring.putConstraint(SpringLayout.NORTH, button1, 362, SpringLayout.SOUTH, combobox1); spring.putConstraint(SpringLayout.WEST, button2, 222, SpringLayout.EAST, label2); spring.putConstraint(SpringLayout.NORTH, button2, 362, SpringLayout.SOUTH, combobox1); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setSize(690, 680); setLocation(300, 60); setVisible(true); PackagePanel.defaultButtonSet(); }
public ExampleField(ExampleOption option) { super(option); model = new DefaultListModel(); model.addListDataListener( new ListDataListener() { @Override public void intervalAdded(ListDataEvent e) { fireChangeEvent(); } @Override public void intervalRemoved(ListDataEvent e) { fireChangeEvent(); } @Override public void contentsChanged(ListDataEvent e) { fireChangeEvent(); } }); final JList list = new JList(model) { @Override public Dimension getPreferredScrollableViewportSize() { return new Dimension(3 * CELL_SIZE, 2 * CELL_SIZE); } }; list.setLayoutOrientation(JList.HORIZONTAL_WRAP); list.setVisibleRowCount(0); list.setFixedCellHeight(CELL_SIZE); list.setFixedCellWidth(CELL_SIZE); list.setTransferHandler( new URIImportTransferHandler() { @Override public boolean canImport(TransferSupport support) { support.setShowDropLocation(false); return super.canImport(support); } @Override public boolean importData(TransferSupport support) { try { List<BufferedImage> images = new ArrayList<BufferedImage>(); for (URI u : getURIs(support)) { try { images.add(ImageIO.read(u.toURL())); } catch (IOException e) { } } addExamples(images); return true; } catch (IOException e) { return false; } catch (UnsupportedFlavorException e) { return false; } catch (URISyntaxException e) { return false; } } }); list.setCellRenderer( new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); Example example = (Example) value; setHorizontalAlignment(SwingConstants.CENTER); setText(null); setIcon(example.getIcon()); setBorder(BorderFactory.createEmptyBorder()); return this; } }); JScrollPane jsp = new JScrollPane(list); jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); jsp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); final JButton remove = new JButton("Remove"); remove.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int[] indices = list.getSelectedIndices(); for (int i = indices.length - 1; i >= 0; i--) { model.remove(indices[i]); } } }); list.addListSelectionListener( new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { remove.setEnabled(list.getSelectedIndex() != -1); } }); remove.setEnabled(false); panel = new JPanel(new GridBagLayout()); // Add list GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.weightx = 1; c.weighty = 1; c.fill = GridBagConstraints.BOTH; panel.add(jsp, c); // Add remove button c = new GridBagConstraints(); c.gridx = 0; c.anchor = GridBagConstraints.WEST; panel.add(remove, c); }
public JunctionLinkDataFrame(final JunctionLink jl) { super( jl.getCurrName() + " properties", false, // resizable false, // closable false, // maximizable true); // iconifiable // PSRender.onHold(); super.setBackground(back_color); super.addInternalFrameListener( new InternalFrameAdapter() { public void internalFrameActivated(InternalFrameEvent e) { reload(); SelectedObject.setSelectedObject(jl); } }); PSRender.moveToTop(jl.getBound(), 0.5); ml = jl; setLocation(50, 50); dataModelMain = new HeadTable(jl); tableMain = new JTable(dataModelMain); tableMain.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN); tableMain.setPreferredScrollableViewportSize(new Dimension(500, 20)); // tableMain.setBackground(back_color); // code TableColumn column_code = tableMain.getColumn("Code"); DefaultTableCellRenderer rendererCode = new DefaultTableCellRenderer(); rendererCode.setToolTipText("Enter new code for this path"); column_code.setCellRenderer(rendererCode); column_code.setCellEditor(new TextFieldEditor()); // name TableColumn column_name = tableMain.getColumn("Name"); LanguageButtonRender render_name = new LanguageButtonRender(); render_name.setToolTipText("Path name. Press for change name"); column_name.setCellRenderer(render_name); LanguageButtonEditor editor_name = new LanguageButtonEditor(new JCheckBox()); column_name.setCellEditor(editor_name); // junction 1 TableColumn column_junc_1 = tableMain.getColumn("Junction 1"); MLButtonRenderer rendererJunc_1 = new MLButtonRenderer(); rendererJunc_1.setToolTipText("Code of first Junction, click for open properties"); column_junc_1.setCellRenderer(rendererJunc_1); MLButtonEditor editorJunc = new MLButtonEditor(new JCheckBox()); column_junc_1.setCellEditor(editorJunc); // junction 2 TableColumn column_junc_2 = tableMain.getColumn("Junction 2"); MLButtonRenderer rendererJunc_2 = new MLButtonRenderer(); rendererJunc_2.setToolTipText("Code of second Junction, click for open properties"); column_junc_2.setCellRenderer(rendererJunc_2); column_junc_2.setCellEditor(editorJunc); // type JComboBox comboBoxType = new JComboBox(); String roadNames[] = jl.getTypeNames(); for (int i = 0, len = roadNames.length; i < len; i++) { comboBoxType.addItem(roadNames[i]); } TableColumn column_type = tableMain.getColumn("Type"); DefaultTableCellRenderer rendererType = new DefaultTableCellRenderer(); rendererType.setToolTipText("To change road type click for combo box"); column_type.setCellRenderer(rendererType); column_type.setCellEditor(new DefaultCellEditor(comboBoxType)); // legth TableColumn column_length = tableMain.getColumn("Length"); DefaultTableCellRenderer rendererLen = new DefaultTableCellRenderer(); rendererLen.setToolTipText("The path length in meters"); column_length.setCellRenderer(rendererLen); scrollpaneMain = new JScrollPane(tableMain); scrollpaneMain.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scrollpaneMain.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER); scrollpaneMain.setPreferredSize(new Dimension(500, 50)); Container contentPane = super.getContentPane(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); contentPane.setLayout(gridbag); c.ipady = 0; // make this component tall c.weightx = 0.5; c.gridwidth = 4; c.gridx = 0; c.gridy = 0; gridbag.setConstraints(scrollpaneMain, c); // scrollpaneMain.setBackground(back_color); // scrollpaneMain.setForeground(back_color); contentPane.add(scrollpaneMain); TableModel dataModelPoints = new PointTableModel(jl); tablePoints = new JTable(dataModelPoints); tablePoints.setPreferredScrollableViewportSize( new Dimension(200, dataModelPoints.getRowCount() * tablePoints.getRowHeight())); ListModel lm = new AbstractListModel() { public int getSize() { return 1000; } public Object getElementAt(int index) { return "" + index; } }; JList rowHeader = new JList(lm); rowHeader.setFixedCellWidth(20); rowHeader.setFixedCellHeight(tablePoints.getRowHeight()); // + tablePoints.getRowMargin()); rowHeader.setCellRenderer(new RowHeaderRenderer(tablePoints)); scrollPanePoints = new JScrollPane(tablePoints); scrollPanePoints.setWheelScrollingEnabled(true); scrollPanePoints.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scrollPanePoints.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); int mh; if (dataModelPoints.getRowCount() * tablePoints.getRowHeight() > 100) { mh = 100; } else { mh = dataModelPoints.getRowCount() * tablePoints.getRowHeight(); } scrollPanePoints.setPreferredSize(new Dimension(200, mh)); scrollPanePoints.setRowHeaderView(rowHeader); c.ipadx = 200; c.weightx = 0.5; c.gridwidth = 3; c.gridx = 1; c.gridy = 1; gridbag.setConstraints(scrollPanePoints, c); // scrollPanePoints.setBackground(back_color); contentPane.add(scrollPanePoints); button_ok = new JButton("Ok"); button_ok.addActionListener(this); JPanel buttonPane = new JPanel(null); buttonPane.setPreferredSize(new Dimension(500, 100)); button_ok.setBounds(205, 40, 90, 40); buttonPane.add(button_ok); c.ipady = 10; // make this component tall c.ipadx = 10; c.weightx = 0.5; c.gridwidth = 4; c.gridx = 2; c.gridy = 2; gridbag.setConstraints(buttonPane, c); buttonPane.setBackground(back_color); contentPane.add(buttonPane); super.pack(); super.setVisible(true); // MapApplication.getDesktop().setSelectedFrame(this); }