public static void main(String[] args) { Frame frame = new Frame("Test"); ScrollPane scrollPane = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS); scrollPane.add(new TextField(20)); scrollPane.add(new Button("hit me")); frame.add(scrollPane); frame.setBounds(100, 100, 250, 250); frame.setVisible(true); }
private Component getScrollChild() { ScrollPane sp = (ScrollPane) target; Component child = null; try { child = sp.getComponent(0); } catch (ArrayIndexOutOfBoundsException e) { // do nothing. in this case we return null } return child; }
public ImageFrame(int width, int height) throws HeadlessException { main = new JPanel(); main.setLayout(new BoxLayout(main, BoxLayout.X_AXIS)); ScrollPane scroll = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED); getContentPane().add(scroll); scroll.add(main); setPreferredSize(new Dimension(width, height)); pack(); setVisible(true); setLocationRelativeTo(null); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
@SuppressWarnings("nls") public void addGroup(final String groupName) { groupNames.add(groupName); final ScrollPane scrollArea = new ScrollPane(); final Panel scrollPanel = new Panel(new GridLayout(0, 1)); parts.add(scrollPanel); scrollArea.add(scrollPanel); scrollPanel.add(new PartsEntry(null, "delete", partsType, 0)); if (parts.size() == 1) { add(scrollArea, BorderLayout.CENTER); displayedPane = scrollArea; } validate(); }
public void doLayout() { super.doLayout(); if (getScrollbarDisplayPolicy() == SCROLLBARS_NEVER) { // Use this class's calculateChildSize() and re-do layout of child Component c = getComponent(0); Dimension cs = calculateChildSize(); Insets i = getInsets(); c.setBounds(i.left, i.top, cs.width, cs.height); } }
/** Creates new form CompIssuesWireFrame */ public CompIssuesListWindow() { initComponents(); this.setTitle(FRAME_TITLE); // initialize class variables sql = new SQL_Commands(DBConnection.getConnection()); rwFiles = new ReadWriteFiles(); map = new HashMap<>(); // initialize all combo boxes initComboBoxes(); textAreaList = new TextAreaList(); setTextAreaListListener(textAreaList); // text area item array compIssueItems = new ArrayList<>(); // add textAreaList to a scrollpane ScrollPane scroll = new ScrollPane(); scroll.add(textAreaList); scroll.setPreferredSize(panelOutputDisplay.getPreferredSize()); panelOutputDisplay.setLayout(new BorderLayout()); panelOutputDisplay.add(scroll, BorderLayout.CENTER); // JFileChooser for choosing a file or directory fc = new JFileChooser(); fc.setCurrentDirectory(new File(".")); fc.setDialogTitle("File Chooser"); fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); if (!DIR.exists()) DIR.mkdirs(); // make directory if does not exist fc.setCurrentDirectory(DIR); fc.setSelectedFile(new File(path)); }
public void initComponents() { jPanel = new javax.swing.JPanel(); inputLabel1 = new javax.swing.JLabel(); inputText1 = new javax.swing.JTextField("CS DEMO"); inputLabel2 = new javax.swing.JLabel(); // inputText2 = new javax.swing.JTextField("yyyy/MM/dd hh:mm:ss"); inputText2 = new javax.swing.JTextField("2015/02/02 11:00:00"); inputLabel3 = new javax.swing.JLabel(); inputText3 = new javax.swing.JTextField("30"); inputLabel4 = new javax.swing.JLabel(); inputText4 = new javax.swing.JTextField(); inputLabel5 = new javax.swing.JLabel(); inputText5 = new javax.swing.JTextField(); inputLabel6 = new javax.swing.JLabel(); inputText6 = new javax.swing.JTextField(); inputLabel7 = new javax.swing.JLabel(); inputText7 = new javax.swing.JTextField("0"); inputLabel8 = new javax.swing.JLabel(); inputText8 = new javax.swing.JTextField(); inputLabel9 = new javax.swing.JLabel(); inputText9 = new javax.swing.JTextField(); inputLabel10 = new javax.swing.JLabel(); inputText10 = new javax.swing.JTextField("0"); inputLabel11 = new javax.swing.JLabel(); inputText11 = new javax.swing.JTextField(); inputLabel12 = new javax.swing.JLabel(); inputText12 = new javax.swing.JTextField("0"); inputLabel13 = new javax.swing.JLabel(); inputText13 = new javax.swing.JTextField("0"); inputLabel14 = new javax.swing.JLabel(); inputText14 = new javax.swing.JTextField(); inputLabel15 = new javax.swing.JLabel(); inputText15 = new javax.swing.JTextField(); inputLabel16 = new javax.swing.JLabel(); inputText16 = new javax.swing.JTextField(); inputLabel17 = new javax.swing.JLabel(); inputText17 = new javax.swing.JTextField(); inputLabel18 = new javax.swing.JLabel(); inputText18 = new javax.swing.JTextField(); jTable1 = new javax.swing.JTable(); tableMode1 = new DefaultTableModel(); tableJscroll = new JScrollPane(); addUser = new JButton(); deleteUser = new JButton(); jSeparator1 = new javax.swing.JSeparator(); statusPanel = new javax.swing.JLabel(); jSeparator2 = new javax.swing.JSeparator(); outputLabel2 = new javax.swing.JLabel(); outputText2 = new javax.swing.JTextField(); outputLabel1 = new javax.swing.JLabel(); outputText1 = new javax.swing.JTextField(); descEditPane.setContentType("text/html;charset=utf-8"); descEditPane.setEditable(false); descEditPane.setPreferredSize(new Dimension(getWidth(), 2750)); descEditPaneJscroll.add(descEditPane); this.setPreferredSize(getSize()); this.addTab("说明", descEditPaneJscroll); statusPanel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); statusPanel.setText(""); // 输入框 inputPanel = new JPanel(); inputPanel.setBorder(BorderFactory.createTitledBorder("输入")); // 用户列表 // 查询条件列表 JPanel inputPanel2 = new JPanel(); jTable1.setEnabled(true); // tableJscroll.setBounds(20, 130, 500, 100); tableJscroll.setBorder(BorderFactory.createTitledBorder("成员列表")); tableJscroll.add(jTable1); tableJscroll.setViewportView(jTable1); // 初始化查询条件列表 // initConditionTableMode(); jTable1.setModel(tableMode1); tableMode1.fireTableDataChanged(); javax.swing.GroupLayout table1Layout = new javax.swing.GroupLayout(inputPanel2); inputPanel2.setLayout(table1Layout); table1Layout.setHorizontalGroup( table1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER, true) .addComponent( tableJscroll, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup( table1Layout .createSequentialGroup() .addGap(10, 10, 20) .addComponent(addUser) .addGap(20, 20, 100) .addComponent(deleteUser) .addGap(20, 20, 100) .addComponent(actionBtn))); table1Layout.setVerticalGroup( table1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, true) .addGroup( table1Layout .createSequentialGroup() .addGap(10, 10, 10) .addComponent(tableJscroll, 120, 120, Short.MAX_VALUE) .addGap(10, 10, 10) .addGroup( table1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(addUser) .addComponent(deleteUser) .addComponent(actionBtn)))); // 用户列表结束 JPanel inputPanel1 = new JPanel(); GroupLayout jPanel2Layout = new GroupLayout(inputPanel1); inputPanel1.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup( jPanel2Layout .createSequentialGroup() .addGap(10, 10, 10) .addGroup( jPanel2Layout .createParallelGroup(GroupLayout.Alignment.CENTER, false) .addComponent(inputLabel1, 130, 130, Short.MAX_VALUE) .addComponent(inputLabel2, 130, 130, Short.MAX_VALUE) .addComponent(inputLabel3, 130, 130, Short.MAX_VALUE) .addComponent(inputLabel4, 130, 130, Short.MAX_VALUE) .addComponent(inputLabel9, 130, 130, Short.MAX_VALUE) .addComponent(inputLabel11, 130, 130, Short.MAX_VALUE) .addComponent(inputLabel12, 130, 130, Short.MAX_VALUE) .addComponent(inputLabel15, 130, 130, Short.MAX_VALUE) .addComponent(inputLabel17, 130, 130, Short.MAX_VALUE)) .addGap(10, 10, 10) .addGroup( jPanel2Layout .createParallelGroup(GroupLayout.Alignment.CENTER, true) .addComponent(inputText1, 100, 100, Short.MAX_VALUE) .addComponent(inputText2, 100, 100, Short.MAX_VALUE) .addComponent(inputText3, 100, 100, Short.MAX_VALUE) .addComponent(inputText4, 100, 100, Short.MAX_VALUE) .addComponent(inputText9, 100, 100, Short.MAX_VALUE) .addComponent(inputText11, 100, 100, Short.MAX_VALUE) .addComponent(inputText12, 100, 100, Short.MAX_VALUE) .addComponent(inputText15, 100, 100, Short.MAX_VALUE) .addComponent(inputText17, 100, 100, Short.MAX_VALUE)) .addGap(20, 20, 50) .addGroup( jPanel2Layout .createParallelGroup(GroupLayout.Alignment.CENTER, false) .addComponent(inputLabel5, 130, 130, Short.MAX_VALUE) .addComponent(inputLabel6, 130, 130, Short.MAX_VALUE) .addComponent(inputLabel7, 130, 130, Short.MAX_VALUE) .addComponent(inputLabel8, 130, 130, Short.MAX_VALUE) .addComponent(inputLabel10, 130, 130, Short.MAX_VALUE) .addComponent(inputLabel13, 130, 130, Short.MAX_VALUE) .addComponent(inputLabel14, 130, 130, Short.MAX_VALUE) .addComponent(inputLabel16, 130, 130, Short.MAX_VALUE) .addComponent(inputLabel18, 130, 130, Short.MAX_VALUE)) .addGap(10, 10, 10) .addGroup( jPanel2Layout .createParallelGroup(GroupLayout.Alignment.CENTER, true) .addComponent(inputText5, 100, 100, Short.MAX_VALUE) .addComponent(inputText6, 100, 100, Short.MAX_VALUE) .addComponent(inputText7, 100, 100, Short.MAX_VALUE) .addComponent(inputText8, 100, 100, Short.MAX_VALUE) .addComponent(inputText10, 100, 100, Short.MAX_VALUE) .addComponent(inputText13, 100, 100, Short.MAX_VALUE) .addComponent(inputText14, 100, 100, Short.MAX_VALUE) .addComponent(inputText16, 100, 100, Short.MAX_VALUE) .addComponent(inputText18, 100, 100, Short.MAX_VALUE)) .addContainerGap(10, 10))); jPanel2Layout.setVerticalGroup( jPanel2Layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup( jPanel2Layout .createSequentialGroup() .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup( jPanel2Layout .createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent( inputLabel1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent( inputText1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent( inputLabel5, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent( inputText5, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup( jPanel2Layout .createParallelGroup(GroupLayout.Alignment.TRAILING) .addComponent( inputLabel2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent( inputText2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent( inputLabel6, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent( inputText6, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup( jPanel2Layout .createParallelGroup(GroupLayout.Alignment.TRAILING) .addComponent( inputLabel3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent( inputText3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent( inputLabel7, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent( inputText7, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup( jPanel2Layout .createParallelGroup(GroupLayout.Alignment.TRAILING) .addComponent( inputLabel4, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent( inputText4, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent( inputLabel8, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent( inputText8, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup( jPanel2Layout .createParallelGroup(GroupLayout.Alignment.TRAILING) .addComponent( inputLabel9, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent( inputText9, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent( inputLabel10, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent( inputText10, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup( jPanel2Layout .createParallelGroup(GroupLayout.Alignment.TRAILING) .addComponent( inputLabel11, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent( inputText11, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent( inputLabel13, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent( inputText13, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup( jPanel2Layout .createParallelGroup(GroupLayout.Alignment.TRAILING) .addComponent( inputLabel12, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent( inputText12, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent( inputLabel14, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent( inputText14, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGroup( jPanel2Layout .createParallelGroup(GroupLayout.Alignment.TRAILING) .addComponent( inputLabel15, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent( inputText15, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent( inputLabel16, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent( inputText16, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup( jPanel2Layout .createParallelGroup(GroupLayout.Alignment.TRAILING) .addComponent( inputLabel17, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent( inputText17, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent( inputLabel18, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent( inputText18, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addContainerGap(30, Short.MAX_VALUE))); javax.swing.GroupLayout layout1 = new javax.swing.GroupLayout(inputPanel); inputPanel.setLayout(layout1); layout1.setHorizontalGroup( layout1 .createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER, true) .addComponent( inputPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent( inputPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); layout1.setVerticalGroup( layout1 .createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER, true) .addGroup( layout1 .createSequentialGroup() .addComponent(inputPanel1, 250, 250, 250) .addComponent(inputPanel2, 180, 180, 180))); // 输出框 outputPanel = new JPanel(); outputPanel.setBorder(BorderFactory.createTitledBorder("输出")); GroupLayout jPanel3Layout = new GroupLayout(outputPanel); outputPanel.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup( jPanel3Layout .createParallelGroup(GroupLayout.Alignment.CENTER, true) .addComponent(jSeparator1) .addGroup( jPanel3Layout .createSequentialGroup() .addGap(10, 10, 10) .addGroup( jPanel3Layout .createParallelGroup(GroupLayout.Alignment.LEADING, false) .addComponent(outputLabel1, 140, 140, Short.MAX_VALUE) .addComponent(outputLabel2, 140, 140, Short.MAX_VALUE)) .addGap(0, 0, 0) .addGroup( jPanel3Layout .createParallelGroup(GroupLayout.Alignment.LEADING, false) .addComponent(outputText1, 208, 208, Short.MAX_VALUE) .addComponent(outputText2, 208, 208, Short.MAX_VALUE)) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addComponent( statusPanel, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); jPanel3Layout.setVerticalGroup( jPanel3Layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup( jPanel3Layout .createSequentialGroup() .addGap(22, 22, 22) .addGroup( jPanel3Layout .createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent( outputLabel1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent( outputText1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup( jPanel3Layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent( outputLabel2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent( outputText2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGap(32, 32, 32) .addComponent( jSeparator1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap( LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent( statusPanel, GroupLayout.PREFERRED_SIZE, 32, GroupLayout.PREFERRED_SIZE) .addContainerGap())); JPanel jPanel1 = new JPanel(); GroupLayout jPanel1Layout = new GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout .createParallelGroup(GroupLayout.Alignment.CENTER, true) .addGroup( jPanel1Layout .createSequentialGroup() .addGap(10, 10, 10) .addGroup( jPanel1Layout .createParallelGroup(GroupLayout.Alignment.CENTER, true) .addComponent(outputPanel, 540, 540, Short.MAX_VALUE) .addComponent(inputPanel, 540, 540, Short.MAX_VALUE)) .addContainerGap(10, 10))); jPanel1Layout.setVerticalGroup( jPanel1Layout .createParallelGroup(GroupLayout.Alignment.LEADING, true) .addGroup( jPanel1Layout .createSequentialGroup() .addGap(10, 10, 10) .addComponent(inputPanel, 470, 470, GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(outputPanel, 170, 170, GroupLayout.PREFERRED_SIZE) .addContainerGap(10, Short.MAX_VALUE))); paneJscroll.add(jPanel1); paneJscroll.setBorder(BorderFactory.createEtchedBorder()); paneJscroll.setViewportView(jPanel1); JPanel mainPanelContent = new JPanel(); GroupLayout layout = new GroupLayout(mainPanelContent); mainPanelContent.setLayout(layout); layout.setHorizontalGroup( layout .createParallelGroup(GroupLayout.Alignment.CENTER, true) .addGroup( layout .createSequentialGroup() .addComponent(paneJscroll, 580, 580, Short.MAX_VALUE))); layout.setVerticalGroup( layout .createParallelGroup(GroupLayout.Alignment.LEADING, true) .addGroup( layout .createSequentialGroup() .addComponent(paneJscroll, 400, 400, Short.MAX_VALUE))); this.addTab("执行", mainPanelContent); codeEditPane.setContentType("text/html;charset=utf-8"); codeEditPane.setEditable(false); codeEditPaneJscroll.add(codeEditPane); this.addTab("源码", codeEditPaneJscroll); International(0); addUser.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { tableMode1.addRow(new String[] {"", "", "", "", "", "", "", "", "", ""}); } }); deleteUser.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { int selectRow = jTable1.getSelectionModel().getMaxSelectionIndex(); if (-1 < selectRow) { tableMode1.removeRow(selectRow); } } }); }
/** This is the main method for configuring the <it>MyScreenAbout</it>. */ public MyScreenAbout() { // constructor setSize(470, 600); setTitle("informació sobre el MAGNUS"); setResizable(false); Toolkit toolkit = Toolkit.getDefaultToolkit(); URL url = getClass().getResource("icon.png"); Image image = toolkit.getImage(url); setIconImage(image); ScrollPane scrollPane = new ScrollPane(ScrollPane.SCROLLBARS_NEVER); scrollPane.setSize(470, 148); scrollPane.setBackground(new Color(0, 128, 0)); Canvas canvas = new MyCanvasAbout(); canvas.setSize(470, 148); scrollPane.add(canvas); add(scrollPane, BorderLayout.NORTH); ScrollPane infoscroll = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED); infoscroll.setSize(470, 400); infoscroll.setBackground(new Color(255, 255, 255)); Panel info = new Panel(); info.setLayout(new GridLayout(56, 1)); infoscroll.add(info); Label ts1 = new Label("MAGNUS 0.1.1"); ts1.setFont(new Font("SansSerif", Font.BOLD, 10)); ts1.setForeground(new Color(0, 0, 0)); ts1.setBackground(new Color(255, 255, 255)); info.add(ts1); Label ts2 = new Label("http://magnusproject.wordpress.com"); ts2.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts2.setForeground(new Color(0, 0, 255)); ts2.setBackground(new Color(255, 255, 255)); info.add(ts2); Label ts3 = new Label(" "); ts3.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts3.setForeground(new Color(0, 0, 255)); ts3.setBackground(new Color(255, 255, 255)); info.add(ts3); Label ts4 = new Label("Alexandre Trilla Castelló"); ts4.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts4.setForeground(new Color(0, 0, 0)); ts4.setBackground(new Color(255, 255, 255)); info.add(ts4); Label ts5 = new Label(" http://www.salle.url.edu/~atrilla/"); ts5.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts5.setForeground(new Color(0, 0, 255)); ts5.setBackground(new Color(255, 255, 255)); info.add(ts5); Label ts7 = new Label("Departament d'Educació de la Generalitat de Catalunya"); ts7.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts7.setForeground(new Color(0, 0, 0)); ts7.setBackground(new Color(255, 255, 255)); info.add(ts7); Label ts8 = new Label(" http://www.xtec.cat"); ts8.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts8.setForeground(new Color(0, 0, 255)); ts8.setBackground(new Color(255, 255, 255)); info.add(ts8); Label ts9 = new Label("Universitat Ramon Llull La Salle Enginyeria de Telecomunicació"); ts9.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts9.setForeground(new Color(0, 0, 0)); ts9.setBackground(new Color(255, 255, 255)); info.add(ts9); Label ts10 = new Label(" http://www.salle.url.edu"); ts10.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts10.setForeground(new Color(0, 0, 255)); ts10.setBackground(new Color(255, 255, 255)); info.add(ts10); Label ts11 = new Label(" "); ts11.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts11.setForeground(new Color(0, 0, 0)); ts11.setBackground(new Color(255, 255, 255)); info.add(ts11); Label ts111 = new Label(" "); ts111.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts111.setForeground(new Color(0, 0, 255)); ts111.setBackground(new Color(255, 255, 255)); info.add(ts111); DesenvCanvas dc = new DesenvCanvas(); info.add(dc); Label ts17 = new Label("MAGNUS ha estat desenvolupat per Alexandre Trilla"); ts17.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts17.setForeground(new Color(0, 0, 0)); ts17.setBackground(new Color(255, 255, 255)); info.add(ts17); Label ts18 = new Label("pel Servei de Tecnologies per l'Aprenentatge i el"); ts18.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts18.setForeground(new Color(0, 0, 0)); ts18.setBackground(new Color(255, 255, 255)); info.add(ts18); Label ts19 = new Label("Coneixement del Departament d'Educació de la"); ts19.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts19.setForeground(new Color(0, 0, 0)); ts19.setBackground(new Color(255, 255, 255)); info.add(ts19); Label ts20 = new Label("Generalitat de Catalunya."); ts20.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts20.setForeground(new Color(0, 0, 0)); ts20.setBackground(new Color(255, 255, 255)); info.add(ts20); Label ts21 = new Label(" "); ts21.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts21.setForeground(new Color(0, 0, 0)); ts21.setBackground(new Color(255, 255, 255)); info.add(ts21); Label ts22 = new Label("Alhora, MAGNUS ha constituït el Projecte Final de"); ts22.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts22.setForeground(new Color(0, 0, 0)); ts22.setBackground(new Color(255, 255, 255)); info.add(ts22); Label ts23 = new Label("Carrera de l'autor, havent cursat d'Enginyeria"); ts23.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts23.setForeground(new Color(0, 0, 0)); ts23.setBackground(new Color(255, 255, 255)); info.add(ts23); Label ts24 = new Label("Superior de Telecomunicacions a la Universitat"); ts24.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts24.setForeground(new Color(0, 0, 0)); ts24.setBackground(new Color(255, 255, 255)); info.add(ts24); Label ts25 = new Label("Ramon Llull La Salle de Barcelona."); ts25.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts25.setForeground(new Color(0, 0, 0)); ts25.setBackground(new Color(255, 255, 255)); info.add(ts25); Label ts26 = new Label(" "); ts26.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts26.setForeground(new Color(0, 0, 0)); ts26.setBackground(new Color(255, 255, 255)); info.add(ts26); Label ts261 = new Label(" "); ts261.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts261.setForeground(new Color(0, 0, 0)); ts261.setBackground(new Color(255, 255, 255)); info.add(ts261); CredenCanvas cc = new CredenCanvas(); info.add(cc); Label ts12 = new Label("Aquest producte inclou programari desenvolupat per:"); ts12.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts12.setForeground(new Color(0, 0, 0)); ts12.setBackground(new Color(255, 255, 255)); info.add(ts12); Label ts121 = new Label(" "); ts121.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts121.setForeground(new Color(0, 0, 0)); ts121.setBackground(new Color(255, 255, 255)); info.add(ts121); Label ts13 = new Label("Sphinx-4"); ts13.setFont(new Font("SansSerif", Font.BOLD, 10)); ts13.setForeground(new Color(0, 0, 0)); ts13.setBackground(new Color(255, 255, 255)); info.add(ts13); Label ts14 = new Label("Carnegie Mellon University"); ts14.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts14.setForeground(new Color(0, 0, 0)); ts14.setBackground(new Color(255, 255, 255)); info.add(ts14); Label ts142 = new Label(" http://cmusphinx.sourceforge.net/sphinx4/"); ts142.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts142.setForeground(new Color(0, 0, 255)); ts142.setBackground(new Color(255, 255, 255)); info.add(ts142); Label ts141 = new Label(" "); ts141.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts141.setForeground(new Color(0, 0, 0)); ts141.setBackground(new Color(255, 255, 255)); info.add(ts141); Label ts15 = new Label("Jdom"); ts15.setFont(new Font("SansSerif", Font.BOLD, 10)); ts15.setForeground(new Color(0, 0, 0)); ts15.setBackground(new Color(255, 255, 255)); info.add(ts15); Label ts16 = new Label("The JDOM Project"); ts16.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts16.setForeground(new Color(0, 0, 0)); ts16.setBackground(new Color(255, 255, 255)); info.add(ts16); Label ts162 = new Label(" http://www.jdom.org"); ts162.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts162.setForeground(new Color(0, 0, 255)); ts162.setBackground(new Color(255, 255, 255)); info.add(ts162); Label ts161 = new Label(" "); ts161.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts161.setForeground(new Color(0, 0, 0)); ts161.setBackground(new Color(255, 255, 255)); info.add(ts161); Label ts163 = new Label(" "); ts163.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts163.setForeground(new Color(0, 0, 0)); ts163.setBackground(new Color(255, 255, 255)); info.add(ts163); LicCanvas lc = new LicCanvas(); info.add(lc); Label ts64 = new Label("Copyright (C) 2007 Alexandre Trilla &"); ts64.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts64.setForeground(new Color(0, 0, 0)); ts64.setBackground(new Color(255, 255, 255)); info.add(ts64); Label ts65 = new Label("Departament d'Educació de la Generalitat de Catalunya &"); ts65.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts65.setForeground(new Color(0, 0, 0)); ts65.setBackground(new Color(255, 255, 255)); info.add(ts65); Label ts66 = new Label("Universitat Ramon Llull La Salle Enginyeria de Telecomunicació"); ts66.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts66.setForeground(new Color(0, 0, 0)); ts66.setBackground(new Color(255, 255, 255)); info.add(ts66); Label ts67 = new Label(" "); ts67.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts67.setForeground(new Color(0, 0, 0)); ts67.setBackground(new Color(255, 255, 255)); info.add(ts67); Label ts68 = new Label("Aquest programa és lliure. Podeu distribuir-lo i/o modificar-"); ts68.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts68.setForeground(new Color(0, 0, 0)); ts68.setBackground(new Color(255, 255, 255)); info.add(ts68); Label ts69 = new Label("lo conforme a les disposicions de la Llicència Pública General"); ts69.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts69.setForeground(new Color(0, 0, 0)); ts69.setBackground(new Color(255, 255, 255)); info.add(ts69); Label ts70 = new Label("de GNU (GPL), publicada per la Free Software Foundation, ja"); ts70.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts70.setForeground(new Color(0, 0, 0)); ts70.setBackground(new Color(255, 255, 255)); info.add(ts70); Label ts71 = new Label("sigui la versió 3 de la llicència o qualsevol versió posterior."); ts71.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts71.setForeground(new Color(0, 0, 0)); ts71.setBackground(new Color(255, 255, 255)); info.add(ts71); Label ts711 = new Label(" "); ts711.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts711.setForeground(new Color(0, 0, 0)); ts711.setBackground(new Color(255, 255, 255)); info.add(ts711); Label ts72 = new Label("Aquest programa es distribueix amb la intenció de resultar"); ts72.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts72.setForeground(new Color(0, 0, 0)); ts72.setBackground(new Color(255, 255, 255)); info.add(ts72); Label ts73 = new Label("útil, però SENSE CAP GARANTIA, fins i tot sense la garantia"); ts73.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts73.setForeground(new Color(0, 0, 0)); ts73.setBackground(new Color(255, 255, 255)); info.add(ts73); Label ts74 = new Label("implícita de COMERCIABILITAT o CONVENIÈNCIA PER A UN"); ts74.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts74.setForeground(new Color(0, 0, 0)); ts74.setBackground(new Color(255, 255, 255)); info.add(ts74); Label ts75 = new Label("PROPÒSIT PARTICULAR. Per a més detalls, vegeu la Llicència"); ts75.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts75.setForeground(new Color(0, 0, 0)); ts75.setBackground(new Color(255, 255, 255)); info.add(ts75); Label ts76 = new Label("Pública General de GNU."); ts76.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts76.setForeground(new Color(0, 0, 0)); ts76.setBackground(new Color(255, 255, 255)); info.add(ts76); Label ts77 = new Label(" "); ts77.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts77.setForeground(new Color(0, 0, 0)); ts77.setBackground(new Color(255, 255, 255)); info.add(ts77); Label ts771 = new Label(" "); ts771.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts771.setForeground(new Color(0, 0, 0)); ts771.setBackground(new Color(255, 255, 255)); info.add(ts771); SupCanvas supc = new SupCanvas(); info.add(supc); Label ts1234 = new Label("Desenvolupat en col·laboració amb Enginyeria i"); ts1234.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts1234.setForeground(new Color(0, 0, 0)); ts1234.setBackground(new Color(255, 255, 255)); info.add(ts1234); Label ts12345 = new Label("Arquitectura La Salle (Universitat Ramon Llull)"); ts12345.setFont(new Font("SansSerif", Font.PLAIN, 10)); ts12345.setForeground(new Color(0, 0, 0)); ts12345.setBackground(new Color(255, 255, 255)); info.add(ts12345); SalleCanvas sallec = new SalleCanvas(); // info.add(sallec); add(sallec, BorderLayout.SOUTH); add(infoscroll, BorderLayout.CENTER); addWindowListener( new WindowAdapter() { /** * This method catches the closing event and react accordingly. * * @param e WindowEvent: the window closing event. */ public void windowClosing(WindowEvent e) { setVisible(false); } }); }
/** Create the panel. */ public JListFriendPanel(String name, String path, ChatPanel chatpanel) { super(name, path); temp = chatpanel; setLayout(null); txtSearch = new JTextField(); txtSearch.setBounds(10, 11, 151, 29); add(txtSearch); txtSearch.setColumns(10); JButton btnSearch = new JButton("Tìm"); btnSearch.addMouseListener( new MouseAdapter() { @Override /** Tìm kiếm keyword trong danh sách bạn bè */ public void mouseClicked(MouseEvent arg0) { String keyword = txtSearch.getText(); if (keyword.isEmpty()) copy2view(); else { list_view.clear(); for (int i = 0; i < list.size(); i++) if (list.get(i).contains(keyword)) { list_view.add(list.get(i)); } } list_fri.setListData(list_view.toArray()); } }); btnSearch.setBounds(171, 11, 69, 29); add(btnSearch); list_fri = new JList(); list_fri.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list_fri.addListSelectionListener( new ListSelectionListener() { public void valueChanged(ListSelectionEvent arg0) {} }); list_fri.addMouseListener( new MouseAdapter() { @Override public void mouseReleased(MouseEvent arg0) { int n = list_fri.getSelectedIndex(); txtSearch.setText(list_view.get(n)); } }); // Khởi tạo danh sách bạn copy2view(); // Cap nhat danh sach ban ScrollPane scrollPane = new ScrollPane(); list_fri.setListData(list.toArray()); list_fri.setSelectedIndex(0); scrollPane.setBounds(10, 76, 230, 305); scrollPane.add(list_fri); add(scrollPane); JLabel lblTrcTuyn = new JLabel("Danh sách bạn bè"); lblTrcTuyn.setForeground(new Color(144, 238, 144)); lblTrcTuyn.setBounds(10, 51, 123, 14); add(lblTrcTuyn); JButton btnSearchServer = new JButton("Tìm kiếm tất cả"); btnSearchServer.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { change2searchserver(); } }); btnSearchServer.setBounds(127, 387, 113, 29); add(btnSearchServer); JButton btnChat = new JButton("Trò chuyện"); btnChat.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { temp.CreateTab(list_view.get(list_fri.getSelectedIndex())); } }); btnChat.setBounds(10, 387, 113, 29); add(btnChat); }
public void setupDBFields(String dbname) throws Exception { viewPane.setLayout(null); Dimension dimView = sp.getSize(); int height = 0, width = 50; viewPane.removeAll(); db = new DBF(dbname); setTitle(dbname); gb = new GridBagLayout(); gbc = new GridBagConstraints(); viewPane.setLayout(gb); int i, j; fldObjects = new Vector(db.getFieldCount()); for (i = 1; i <= db.getFieldCount(); i++) { j = i - 1; f = db.getField(i); if (f.isMemoField() || f.isPictureField()) { b = new Button(db.getField(i).getName()); b.addActionListener(this); addComponent( viewPane, b, 1, j, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST); fldObjects.addElement(b); } else if (f.getType() == 'L') { c = new Checkbox(db.getField(i).getName(), true); addComponent( viewPane, c, 1, j, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST); fldObjects.addElement(c); } else { l = new Label(db.getField(i).getName(), Label.RIGHT); addComponent( viewPane, l, 0, j, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST); int ln = f.getLength(); if (ln > 100) { ln = 100; } t = new TextField(db.getField(i).getName(), ln); if (width < ln * 10) { width = ln * 10; } addComponent( viewPane, t, 1, j, ln, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST); fldObjects.addElement(t); t.setEditable(true); } height += 10; } crl.setText("Record " + db.getCurrentRecordNumber()); trl.setText(" of " + db.getRecordCount()); SBrecpos.setMaximum(db.getRecordCount()); addComponent(viewPane, crl, 0, i, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST); addComponent(viewPane, trl, 1, i, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST); i++; addComponent( viewPane, SBrecpos, 0, i, 2, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST); addComponent( viewPane, delCB, 2, i, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST); i++; addComponent( viewPane, Prev, 0, i, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST); addComponent( viewPane, Next, 1, i, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST); i++; addComponent(viewPane, Add, 0, i, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST); addComponent( viewPane, Update, 1, i, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST); addComponent( viewPane, Clear, 2, i, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST); Prev.setEnabled(false); prevRecord.setEnabled(false); if (db.getRecordCount() == 0) { Update.setEnabled(false); updateRecord.setEnabled(false); Next.setEnabled(false); nextRecord.setEnabled(false); } dimView.setSize(width + 150, height + 150); sp.setSize(dimView); goTo(1); }
/** Create the whole GUI, and set up event listeners */ public AllComponents(String title) { super(title); // set frame title. // Arrange to detect window close events this.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); // Set a default font this.setFont(new Font("SansSerif", Font.PLAIN, 12)); // Create the menubar. Tell the frame about it. MenuBar menubar = new MenuBar(); this.setMenuBar(menubar); // Create the file menu. Add to menubar. Menu file = new Menu("File"); menubar.add(file); // Create two items for the file menu, setting their label, shortcut, // action command and listener. Add them to File menu. // Note that we use the frame itself as the action listener MenuItem open = new MenuItem("Open", new MenuShortcut(KeyEvent.VK_O)); open.setActionCommand("open"); open.addActionListener(this); file.add(open); MenuItem quit = new MenuItem("Quit", new MenuShortcut(KeyEvent.VK_Q)); quit.setActionCommand("quit"); quit.addActionListener(this); file.add(quit); // Create Help menu; add an item; add to menubar // Display the help menu in a special reserved place. Menu help = new Menu("Help"); menubar.add(help); menubar.setHelpMenu(help); // Create and add an item to the Help menu MenuItem about = new MenuItem("About", new MenuShortcut(KeyEvent.VK_A)); about.setActionCommand("about"); about.addActionListener(this); help.add(about); // Now that we've done the menu, we can begin work on the contents of // the frame. Assign a BorderLayout manager with margins for this frame. this.setLayout(new BorderLayout(10, 10)); // Create two panels to contain two columns of components. Use our custom // ColumnLayout layout manager for each. Add them on the west and // center of the frame's border layout Panel column1 = new Panel(); column1.setLayout(new ColumnLayout(5, 10, 2, ColumnLayout.LEFT)); this.add(column1, "West"); Panel column2 = new Panel(); column2.setLayout(new ColumnLayout(5, 10, 2, ColumnLayout.LEFT)); this.add(column2, "Center"); // Create a panel to contain the buttons at the bottom of the window // Give it a FlowLayout layout manager, and add it along the south border Panel buttonbox = new Panel(); buttonbox.setLayout(new FlowLayout(FlowLayout.CENTER, 100, 10)); this.add(buttonbox, "South"); // Create pushbuttons and add them to the buttonbox Button okay = new Button("Okay"); Button cancel = new Button("Cancel"); buttonbox.add(okay); buttonbox.add(cancel); // Handle events on the buttons ActionListener buttonlistener = new ActionListener() { public void actionPerformed(ActionEvent e) { textarea.append("You clicked: " + ((Button) e.getSource()).getLabel() + "\n"); } }; okay.addActionListener(buttonlistener); cancel.addActionListener(buttonlistener); // Now start filling the left column. // Create a 1-line text field and add to left column, with a label TextField textfield = new TextField(15); column1.add(new Label("Name:")); column1.add(textfield); // Handle events on the TextField textfield.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { textarea.append("Your name is: " + ((TextField) e.getSource()).getText() + "\n"); } }); textfield.addTextListener( new TextListener() { public void textValueChanged(TextEvent e) { textarea.append("You have typed: " + ((TextField) e.getSource()).getText() + "\n"); } }); // Create a dropdown list or option menu of choices Choice choice = new Choice(); choice.addItem("red"); choice.addItem("green"); choice.addItem("blue"); column1.add(new Label("Favorite color:")); column1.add(choice); // Handle events on this choice choice.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { textarea.append("Your favorite color is: " + e.getItem() + "\n"); } }); // Create checkboxes, and group them in a CheckboxGroup to give them // "radio button" behavior. CheckboxGroup checkbox_group = new CheckboxGroup(); Checkbox[] checkboxes = new Checkbox[3]; checkboxes[0] = new Checkbox("vanilla", checkbox_group, false); checkboxes[1] = new Checkbox("chocolate", checkbox_group, true); checkboxes[2] = new Checkbox("strawberry", checkbox_group, false); column1.add(new Label("Favorite flavor:")); for (int i = 0; i < checkboxes.length; i++) column1.add(checkboxes[i]); // Handle events on the checkboxes ItemListener checkbox_listener = new ItemListener() { public void itemStateChanged(ItemEvent e) { textarea.append( "Your favorite flavor is: " + ((Checkbox) e.getItemSelectable()).getLabel() + "\n"); } }; for (int i = 0; i < checkboxes.length; i++) checkboxes[i].addItemListener(checkbox_listener); // Create a list of choices. List list = new List(4, true); list.addItem("Java"); list.addItem("C"); list.addItem("C++"); list.addItem("Smalltalk"); list.addItem("Lisp"); list.addItem("Modula-3"); list.addItem("Forth"); column1.add(new Label("Favorite languages:")); column1.add(list); // Handle events on this list list.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { textarea.append("Your favorite languages are: "); String[] languages = ((List) e.getItemSelectable()).getSelectedItems(); for (int i = 0; i < languages.length; i++) { if (i > 0) textarea.append(","); textarea.append(languages[i]); } textarea.append("\n"); } }); // Create a multi-line text area in column 2 textarea = new TextArea(6, 40); textarea.setEditable(false); column2.add(new Label("Messages")); column2.add(textarea); // Create a scrollpane that displays portions of a larger component ScrollPane scrollpane = new ScrollPane(); scrollpane.setSize(300, 150); column2.add(new Label("Scrolling Window")); column2.add(scrollpane); // Create a custom MultiLineLabel with a really big font and make it // a child of the ScrollPane container String message = "/*************************************************\n" + " * AllComponents.java *\n" + " * Written by David Flanagan *\n" + " * Copyright (c) 1997 by O'Reilly & Associates *\n" + " * *\n" + " *************************************************/\n"; MultiLineLabel biglabel = new MultiLineLabel(message); biglabel.setFont(new Font("Monospaced", Font.BOLD + Font.ITALIC, 24)); scrollpane.add(biglabel); }
public RateIndicatorBFTab() { // Setup miscallenous setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS)); backgroundColor = new Color(231, 237, 246); branchesMaxColor = new Color(255, 5, 50, 255); branchesMinColor = new Color(0, 0, 0, 255); GridBagConstraints c = new GridBagConstraints(); // Setup icons nuclearIcon = CreateImageIcon("/icons/nuclear.png"); logIcon = CreateImageIcon("/icons/log.png"); locationsIcon = CreateImageIcon("/icons/locations.png"); processingIcon = CreateImageIcon("/icons/processing.png"); saveIcon = CreateImageIcon("/icons/save.png"); errorIcon = CreateImageIcon("/icons/error.png"); // Setup text fields numberOfIntervalsParser = new JTextField("100", 10); maxAltMappingParser = new JTextField("500000", 10); bfCutoffParser = new JTextField("3.0", 5); kmlPathParser = new JTextField("output.kml", 10); // Setup buttons openLog = new JButton("Open", logIcon); openLocations = new JButton("Open", locationsIcon); generateKml = new JButton("Generate", nuclearIcon); generateProcessing = new JButton("Plot", processingIcon); saveProcessingPlot = new JButton("Save", saveIcon); branchesMaxColorChooser = new JButton("Setup max"); branchesMinColorChooser = new JButton("Setup min"); // Setup sliders burnInParser = new JSlider(JSlider.HORIZONTAL, 0, 100, 10); burnInParser.setMajorTickSpacing(20); burnInParser.setMinorTickSpacing(10); burnInParser.setPaintTicks(true); burnInParser.setPaintLabels(true); branchesWidthParser = new JSlider(JSlider.HORIZONTAL, 2, 10, 4); branchesWidthParser.setMajorTickSpacing(2); branchesWidthParser.setMinorTickSpacing(1); branchesWidthParser.setPaintTicks(true); branchesWidthParser.setPaintLabels(true); // Setup progress bar progressBar = new JProgressBar(); /** left tools pane */ leftPanel = new JPanel(); leftPanel.setBackground(backgroundColor); leftPanel.setLayout(new BoxLayout(leftPanel, BoxLayout.PAGE_AXIS)); leftPanel.setPreferredSize(new Dimension(leftPanelWidth, leftPanelHeight)); // Listeners openLog.addActionListener(new ListenOpenLog()); generateKml.addActionListener(new ListenGenerateKml()); openLocations.addActionListener(new ListenOpenLocations()); generateProcessing.addActionListener(new ListenGenerateProcessing()); saveProcessingPlot.addActionListener(new ListenSaveProcessingPlot()); branchesMaxColorChooser.addActionListener(new ListenBranchesMaxColorChooser()); branchesMinColorChooser.addActionListener(new ListenBranchesMinColorChooser()); tmpPanel = new JPanel(); tmpPanel.setMaximumSize(new Dimension(leftPanelWidth + 60, 100)); tmpPanel.setBackground(backgroundColor); tmpPanel.setBorder(new TitledBorder("Load log file:")); tmpPanel.add(openLog); leftPanel.add(tmpPanel); tmpPanel = new JPanel(); tmpPanel.setMaximumSize(new Dimension(leftPanelWidth + 60, 100)); tmpPanel.setBackground(backgroundColor); tmpPanel.setBorder(new TitledBorder("Load locations file:")); tmpPanel.add(openLocations); leftPanel.add(tmpPanel); tmpPanel = new JPanel(); tmpPanel.setMaximumSize(new Dimension(leftPanelWidth + 60, 100)); tmpPanel.setBackground(backgroundColor); tmpPanel.setBorder(new TitledBorder("Specify burn-in %:")); tmpPanel.add(burnInParser); leftPanel.add(tmpPanel); tmpPanel = new JPanel(); tmpPanel.setMaximumSize(new Dimension(leftPanelWidth + 60, 100)); tmpPanel.setLayout(new GridLayout(1, 2)); tmpPanel.setBackground(backgroundColor); tmpPanel.setBorder(new TitledBorder("Poisson prior mean / offset:")); String[] meanPoissonPrior = {"log(2)", ""}; meanPoissonPriorParser = new JComboBox(meanPoissonPrior); meanPoissonPriorParser.setEditable(true); tmpPanel.add(meanPoissonPriorParser); String[] poissonPriorOffset = {"n-1", ""}; poissonPriorOffsetParser = new JComboBox(poissonPriorOffset); poissonPriorOffsetParser.setEditable(true); tmpPanel.add(poissonPriorOffsetParser); leftPanel.add(tmpPanel); tmpPanel = new JPanel(); tmpPanel.setMaximumSize(new Dimension(leftPanelWidth + 60, 100)); tmpPanel.setBackground(backgroundColor); tmpPanel.setBorder(new TitledBorder("Bayes Factor cut-off:")); tmpPanel.add(bfCutoffParser); leftPanel.add(tmpPanel); tmpPanel = new JPanel(); tmpPanel.setMaximumSize(new Dimension(leftPanelWidth + 60, 100)); tmpPanel.setBackground(backgroundColor); tmpPanel.setBorder(new TitledBorder("Number of intervals:")); tmpPanel.add(numberOfIntervalsParser); leftPanel.add(tmpPanel); tmpPanel = new JPanel(); tmpPanel.setMaximumSize(new Dimension(leftPanelWidth + 60, 100)); tmpPanel.setBackground(backgroundColor); tmpPanel.setBorder(new TitledBorder("Maximal altitude:")); tmpPanel.add(maxAltMappingParser); leftPanel.add(tmpPanel); // Branches color mapping: tmpPanel = new JPanel(); tmpPanel.setMaximumSize(new Dimension(leftPanelWidth + 60, 100)); tmpPanel.setLayout(new GridBagLayout()); tmpPanel.setBackground(backgroundColor); tmpPanel.setBorder(new TitledBorder("Rates color mapping:")); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0; c.gridy = 0; tmpPanel.add(branchesMinColorChooser, c); c.gridx = 2; c.gridy = 0; tmpPanel.add(branchesMaxColorChooser, c); leftPanel.add(tmpPanel); // Branches width: tmpPanel = new JPanel(); tmpPanel.setMaximumSize(new Dimension(leftPanelWidth + 60, 100)); tmpPanel.setBackground(backgroundColor); tmpPanel.setBorder(new TitledBorder("Rates width:")); tmpPanel.add(branchesWidthParser); leftPanel.add(tmpPanel); tmpPanel = new JPanel(); tmpPanel.setMaximumSize(new Dimension(leftPanelWidth + 60, 100)); tmpPanel.setBackground(backgroundColor); tmpPanel.setBorder(new TitledBorder("KML name:")); tmpPanel.add(kmlPathParser); leftPanel.add(tmpPanel); tmpPanel = new JPanel(); tmpPanel.setMaximumSize(new Dimension(leftPanelWidth + 60, 100)); tmpPanel.setLayout(new GridBagLayout()); tmpPanel.setBackground(backgroundColor); tmpPanel.setBorder(new TitledBorder("Generate KML / Plot map:")); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0; c.gridy = 0; tmpPanel.add(generateKml, c); c.gridx = 2; c.gridy = 0; tmpPanel.add(generateProcessing, c); c.ipady = 7; c.gridwidth = 3; c.gridx = 0; c.gridy = 1; tmpPanel.add(progressBar, c); leftPanel.add(tmpPanel); tmpPanel = new JPanel(); tmpPanel.setMaximumSize(new Dimension(leftPanelWidth + 60, 100)); tmpPanel.setBackground(backgroundColor); tmpPanel.setBorder(new TitledBorder("Save plot:")); tmpPanel.add(saveProcessingPlot); leftPanel.add(tmpPanel); JScrollPane leftScrollPane = new JScrollPane( leftPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); leftScrollPane.setMinimumSize(new Dimension(leftPanelWidth + 60, leftPanelHeight)); add(leftScrollPane, BorderLayout.CENTER); /** Processing pane */ rateIndicatorBFToProcessing = new RateIndicatorBFToProcessing(); rateIndicatorBFToProcessing.setPreferredSize(new Dimension(2048, 1025)); if (System.getProperty("java.runtime.name").toLowerCase().startsWith("openjdk")) { JScrollPane rightScrollPane = new JScrollPane( rateIndicatorBFToProcessing, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); add(rightScrollPane, BorderLayout.CENTER); } else { ScrollPane rightScrollPane = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS); rightScrollPane.add(rateIndicatorBFToProcessing); add(rightScrollPane, BorderLayout.CENTER); } } // END: RateIndicatorBFTab
/** * The child component has been resized. The scrollbars must be updated with the new sizes. At the * native level the sizes of the actual windows may not have changed yet, so the size information * from the java-level is passed down and used. */ public void childResized(int width, int height) { ScrollPane sp = (ScrollPane) target; Dimension vs = sp.getSize(); setSpans(vs.width, vs.height, width, height); setInsets(); }
public void run() { if (getScrollChild() == null) { return; } ScrollPane sp = (ScrollPane) WScrollPanePeer.this.target; ScrollPaneAdjustable adj = null; // ScrollPaneAdjustable made public in 1.4, but // get[HV]Adjustable can't be declared to return // ScrollPaneAdjustable because it would break backward // compatibility -- hence the cast if (orient == Adjustable.VERTICAL) { adj = (ScrollPaneAdjustable) sp.getVAdjustable(); } else if (orient == Adjustable.HORIZONTAL) { adj = (ScrollPaneAdjustable) sp.getHAdjustable(); } else { if (dbg.on) dbg.assertion(false); } if (adj == null) { return; } int newpos = adj.getValue(); switch (type) { case AdjustmentEvent.UNIT_DECREMENT: newpos -= adj.getUnitIncrement(); break; case AdjustmentEvent.UNIT_INCREMENT: newpos += adj.getUnitIncrement(); break; case AdjustmentEvent.BLOCK_DECREMENT: newpos -= adj.getBlockIncrement(); break; case AdjustmentEvent.BLOCK_INCREMENT: newpos += adj.getBlockIncrement(); break; case AdjustmentEvent.TRACK: newpos = this.pos; break; default: if (dbg.on) dbg.assertion(false); return; } // keep scroll position in acceptable range newpos = Math.max(adj.getMinimum(), newpos); newpos = Math.min(adj.getMaximum(), newpos); // set value, this will synchronously fire an AdjustmentEvent adj.setValueIsAdjusting(isAdjusting); // Fix for 4075484 - consider type information when creating AdjustmentEvent // We can't just call adj.setValue() because it creates AdjustmentEvent with type=TRACK // Instead, we call private method setTypedValue of ScrollPaneAdjustable. // Because ScrollPaneAdjustable is in another package we should call it through native code. setTypedValue(adj, newpos, type); // Paint the exposed area right away. To do this - find // the heavyweight ancestor of the scroll child. Component hwAncestor = getScrollChild(); while (hwAncestor != null && !(hwAncestor.getPeer() instanceof WComponentPeer)) { hwAncestor = hwAncestor.getParent(); } if (dbg.on) { dbg.assertion( hwAncestor != null, "couldn't find heavyweight ancestor of scroll pane child"); } WComponentPeer hwPeer = (WComponentPeer) hwAncestor.getPeer(); hwPeer.paintDamagedAreaImmediately(); }
/** *********************************************************************** */ private void initComponents() { /** ******************** The main container *************************** */ Container container = this.getContentPane(); container.setLayout(new BoxLayout(container, BoxLayout.Y_AXIS)); // container.setLayout( new PercentLayout() ); container.setBackground(Color.black); addWindowListener( new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { System.out.println("Trace viewer closed!"); // System.exit(0); } }); /** ******************** Menu bar ************************************* */ menuBar = new JMenuBar(); setJMenuBar(menuBar); // Build a second menu in the menu bar. optionsMenu = new JMenu(" Options "); optionsMenu.setBorder(new BevelBorder(BevelBorder.RAISED)); optionsMenu.setToolTipText("Some options related to the GUI"); animationMenuItem = new JMenuItem(" Animation "); animationMenuItem.setToolTipText("Animation of the entire selected session"); animationMenuItem.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { listenerTracesViewer.animationActionPerformed(evt); } }); optionsMenu.add(animationMenuItem); menuBar.add(optionsMenu); // create a menu and add it to the menubar displayAllSessionsMenu = new JMenu(" Display Sessions "); displayAllSessionsMenu.setBorder(new BevelBorder(BevelBorder.RAISED)); displayAllSessionsMenu.setToolTipText( "Display all the retrieved sessions in a separate windows"); displayAllSessionsMenu.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { listenerTracesViewer.displayAllSessionsMouseEvent(evt); } }); // add the Controls menu to the menu bar menuBar.add(displayAllSessionsMenu); // create a menu and add it to the menubar refreshMenu = new JMenu(" Refresh "); refreshMenu.setBorder(new BevelBorder(BevelBorder.RAISED)); refreshMenu.setBackground(new Color(51, 153, 255)); refreshMenu.setToolTipText("Get the new traces"); refreshMenu.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { listenerTracesViewer.refreshActionPerformed(evt); } }); // add the Controls menu to the menu bar menuBar.add(refreshMenu); // ...create and add some menus... menuBar.add(Box.createHorizontalGlue()); helpMenu = new JMenu(" Help "); helpMenu.setBorder(new BevelBorder(BevelBorder.RAISED)); helpMenu.setToolTipText("Some useful notes about this tool"); helpMenu.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { listenerTracesViewer.helpMenuMouseEvent(evt); } }); menuBar.add(helpMenu); aboutMenu = new JMenu(" About "); aboutMenu.setBorder(new BevelBorder(BevelBorder.RAISED)); aboutMenu.setToolTipText("Some advertises about the creators!"); aboutMenu.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { listenerTracesViewer.aboutMenuMouseEvent(evt); } }); menuBar.add(aboutMenu); quitMenu = new JMenu(" Quit "); quitMenu.setBorder(new BevelBorder(BevelBorder.RAISED)); quitMenu.setToolTipText("Quit the traces viewer"); quitMenu.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { close(); } }); menuBar.add(quitMenu); /** ****************** FIRST PANEL ******************************* */ firstPanel = new JPanel(); // If put to False: we see the container's background firstPanel.setOpaque(false); firstPanel.setLayout(new PercentLayout()); // firstPanel.setLayout( new BorderLayout() ); container.add(firstPanel); // Sub right panel: // topx %, topy %, width %, height % 73, 100-> 65, 95 PercentLayoutConstraint firstPanelConstraint = new PercentLayoutConstraint(30, 0, 70, 100); tracesSessionsList = new TracesSessionsList(); tracesSessionsList.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { listenerTracesViewer.tracesSessionsListStateChanged(e); } }); tracesSessionsList.setForeground(Color.black); tracesSessionsList.setFont(new Font("Dialog", 1, 14)); ScrollPane scroll = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS); TracesSession tracesSession = tracesSessions.firstElement(); String name = tracesSession.getName(); String logDescription = tracesSession.getLogDescription(); String callId = tracesSessionsList.getCallId(name); String origin = tracesSessionsList.getOrigin(name); // Warning: to put before for the canvas!!!! TextArea messageContentTextArea = new TextArea(); messageContentButton = new JButton("SIP Message:"); if (name.equals("No available session, refresh")) { tracesCanvas = new TracesCanvas(tracesSession, messageContentTextArea, "unknown", this); } else if (logDescription == null || logDescription.trim().equals("")) { tracesCanvas = new TracesCanvas(tracesSession, messageContentTextArea, origin, this); } else { // System.out.println("logDesc44:"+logDescription); tracesCanvas = new TracesCanvas(tracesSession, messageContentTextArea, logDescription, this); } tracesSessionsList.setTracesCanvas(tracesCanvas); // The ScrollPane for the Canvas scroll.add(tracesCanvas); firstPanel.add(scroll, firstPanelConstraint); /** ************************* SECOND PANEL ******************************* */ // left panel: secondPanel = new JPanel(); secondPanel.setBackground(Color.black); // rows, columns // secondPanel.setLayout(new GridLayout(3,1,0,0) ); secondPanel.setLayout(new BorderLayout()); // topx %, topy %, width %, height % PercentLayoutConstraint secondPanelConstraint = new PercentLayoutConstraint(0, 0, 30, 100); firstPanel.add(secondPanel, secondPanelConstraint); /** **************************** FIRST SUB PANEL ********************************* */ // Sub left panel: firstSubPanel = new JPanel(); firstSubPanel.setBackground(Color.black); // Top, left, bottom, right firstSubPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 7, 5)); if (!standaloneViewer) { // rows, columns, gap, gap firstSubPanel.setLayout(new GridLayout(2, 1, 3, 6)); secondPanel.add(firstSubPanel, BorderLayout.NORTH); JPanel panelGrid = new JPanel(); panelGrid.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); panelGrid.setLayout(new GridLayout(2, 1, 0, 0)); JPanel panelBox = new JPanel(); panelBox.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); panelBox.setLayout(new BorderLayout()); JLabel scriptLabel = new JLabel("Display the event script:"); scriptLabel.setToolTipText("Display the content of the selected script"); scriptLabel.setHorizontalAlignment(SwingConstants.CENTER); scriptLabel.setForeground(Color.black); scriptLabel.setFont(new Font("Dialog", 1, 14)); // If put to true: we see the label's background scriptLabel.setOpaque(true); panelGrid.add(scriptLabel); choice = new Choice(); panelBox.add(choice, BorderLayout.CENTER); scriptButton = new JButton("Open"); scriptButton.setToolTipText("Get the script controlling the current session"); scriptButton.setFont(new Font("Dialog", 1, 14)); scriptButton.setFocusPainted(false); scriptButton.setBackground(new Color(186, 175, 175)); scriptButton.setBorder(new BevelBorder(BevelBorder.RAISED)); scriptButton.setVerticalAlignment(SwingConstants.CENTER); scriptButton.setHorizontalAlignment(SwingConstants.CENTER); panelBox.add(scriptButton, BorderLayout.EAST); scriptButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { listenerTracesViewer.scriptActionPerformed(evt); } }); panelGrid.add(panelBox); firstSubPanel.add(panelGrid); // initComboBox(); /* refreshButton=new JButton("Refresh"); refreshButton.setToolTipText("Refresh all the sessions"); refreshButton.setFont(new Font ("Dialog", 1, 14)); refreshButton.setFocusPainted(false); //refreshButton.setBackground(new Color(186,175,175)); refreshButton.setBackground( new Color(51,153,255)); refreshButton.setBorder(new BevelBorder(BevelBorder.RAISED)); refreshButton.setVerticalAlignment(AbstractButton.CENTER); refreshButton.setHorizontalAlignment(AbstractButton.CENTER); firstSubPanel.add(refreshButton); refreshButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { listenerTracesViewer.refreshActionPerformed(evt); } } ); */ ImageIcon icon; if (logoNist != null) { icon = new ImageIcon(logoNist); JLabel label = new JLabel(icon); label.setVisible(true); label.setToolTipText("The NIST logo!!!"); // label.setHorizontalAlignment(AbstractButton.CENTER); label.setForeground(Color.black); // label.setFont(new Font ("Dialog", 1, 14)); label.setOpaque(false); firstSubPanel.add(label); } } else { // rows, columns, gap, gap firstSubPanel.setLayout(new GridLayout(1, 1, 3, 6)); secondPanel.add(firstSubPanel, BorderLayout.NORTH); ImageIcon icon; if (logoNist != null) { icon = new ImageIcon(logoNist); JLabel label = new JLabel(icon); label.setVisible(true); label.setToolTipText("The NIST logo!!!"); label.setHorizontalAlignment(SwingConstants.CENTER); label.setForeground(Color.black); label.setFont(new Font("Dialog", 1, 14)); label.setOpaque(false); firstSubPanel.add(label); } } /** **************** SECOND SUB PANEL *************************************** */ JPanel panel = new JPanel(); panel.setLayout(new GridLayout(2, 1, 0, 0)); secondPanel.add(panel, BorderLayout.CENTER); secondSubPanel = new JPanel(); secondSubPanel.setBackground(Color.black); secondSubPanel.setLayout(new BorderLayout()); // secondPanel.add(secondSubPanel); panel.add(secondSubPanel); sessionsLabel = new JLabel("Sessions available:"); sessionsLabel.setToolTipText("All the sessions currently available"); // Alignment of the text sessionsLabel.setHorizontalAlignment(SwingConstants.CENTER); // Color of the text sessionsLabel.setForeground(Color.black); // Size of the text sessionsLabel.setFont(new Font("Dialog", 1, 14)); // If put to true: we see the label's background sessionsLabel.setOpaque(true); sessionsLabel.setBackground(Color.lightGray); sessionsLabel.setBorder(BorderFactory.createLineBorder(Color.darkGray)); secondSubPanel.add(sessionsLabel, BorderLayout.NORTH); ScrollPane scrollList = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS); scrollList.add(tracesSessionsList); // secondSubPanel.add(scrollList,BorderLayout.CENTER); secondSubPanel.add(tracesSessionsList, BorderLayout.CENTER); /** ****************** THIRD SUB PANEL *************************************** */ thirdSubPanel = new JPanel(); thirdSubPanel.setBackground(Color.black); thirdSubPanel.setLayout(new BorderLayout()); // secondPanel.add(thirdSubPanel); panel.add(thirdSubPanel); messageContentButton.setToolTipText("Display all the content of the current SIP message"); // Alignment of the text messageContentButton.setHorizontalAlignment(SwingConstants.CENTER); // Color of the text messageContentButton.setForeground(Color.black); // Size of the text messageContentButton.setFont(new Font("Dialog", 1, 14)); // If put to true: we see the label's background messageContentButton.setOpaque(true); messageContentButton.setBackground(Color.lightGray); messageContentButton.setBorder(BorderFactory.createLineBorder(Color.darkGray)); messageContentButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { listenerTracesViewer.debugActionPerformed(evt); } }); messageContentTextArea.setBackground(Color.white); messageContentTextArea.setEditable(false); messageContentTextArea.setFont(new Font("Dialog", 1, 12)); messageContentTextArea.setForeground(Color.black); thirdSubPanel.add(messageContentButton, BorderLayout.NORTH); thirdSubPanel.add(messageContentTextArea, BorderLayout.CENTER); validateTree(); }
public void inicializar() { JPanel painel = new JPanel(); painel.setLayout(new BorderLayout()); setTitle("Instrucoes"); add(painel); tabela = new JTable(); tabela.setModel( new DefaultTableModel( new Object[][] { {"Instrução", "Exemplo", "Significado"}, {"Soma", "add $t0,$t1,$t2", "$t0 = $t1+$t2"}, {"Subtração", "sub $s1, $s2,$s3", "$s1 = $s2 - $s3"}, {"Soma imediato", "addi $s1,$s2, 100", "$s1 = $s2 + 100"}, {"Multiplicação", "mul $v0,$a1,$v0", "$v0 = $a1 * $v0"}, {"Divisão", "div $t0,$a1,$a0", "$t0 = $a1 / $s0"}, {"Resto", "rest $t1,$a1,$a0", "$t1 = $a1 % $a0"}, {"AND", "and $s1, $s2,$s3", "$s1 = $s2 & $s3"}, {"AND imediato", "andi $s1,$s2,100", "$s1 = $s2 & 100"}, {"OR", "or $s1,$s2,$s3", "$s1 = $s2 ou $s3"}, {"OR imediato", "ori $s1,$s2,100", "$s1 = $s2 ou 100"}, { "SHIFT para a Esquerda", "sll $s1,$s2,10", "$s1 = $s2 << 10 (Shifta os bits de $s2 10 posições para a esquerda)" }, { "SHIFT para a Direita", "srl $s1,$s2,10", "$s1 = $s2 >> 10 (Shifta os bits de $s2 10 posições para a direita)" }, {"Leitura do Array", "lw $s1,100($s2)", "$s1 = Memória ($s2 + 100)"}, {"Escrita no Array", "sw $s1,100($s2)", "Memória ($s2 + 100) = $s1"}, {"Verificar Igualdade", "beq $s1,$s2,label", "if ( $s1 == $s2 ) {vai para label}"}, {"Verificar Desigualdade", "bne $s1,$s2,label", "if ( $s1 != $s2 ) {vai para label}"}, { "Verificar se for menor", "slt $s1,$s2,$s3", "if ( $s2 < $s3 ) {$s1 = 1} else {$s1 = 0}" }, {"Salto", "j label", "Vá para label"}, {"Salto para um registrador", "jr $ra", "Vá para $ra"}, {"Salto para um ‘link’", "jal Func", "$ra = PC + 4; Vá para Func"}, {"Mover valor", "move $v0,$a0", "Move o $a0 para $v0"} }, new String[] {"New column", "New column", "New column"})); tabela.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); if (row == 0) { setBackground(Color.LIGHT_GRAY); } else { setBackground(null); } return this; } }); painel.add(tabela); tabela.getColumnModel().getColumn(0).setPreferredWidth(0); tabela.getColumnModel().getColumn(1).setPreferredWidth(0); tabela.getColumnModel().getColumn(2).setPreferredWidth(250); tabela.setRowHeight(0, 30); area.setPreferredSize(new Dimension(500, 500)); ScrollPane scroll = new ScrollPane(); scroll.setPreferredSize(new Dimension(800, 280)); scroll.add(area); setResizable(false); setSize(700, 395); setLocationRelativeTo(null); setVisible(true); }
/** @throws IOException */ public void setting_panel() throws IOException { this.setTitle("Music World!!"); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // the line that reads the image file // BufferedImage image = ImageIO.read(new File("icon.jpg")); // BufferedImage image = ImageIO.read(new File("C:/Users/Marium // Ahmad/work/P2P/GUI/ui/P2P/CT/icon.jpg")); this.setBounds(20, 20, 479, 483); // ImagePanel panel = new ImagePanel(new ImageIcon("C:/Users/Marium // Ahmad/work/P2P/GUI/ui/P2P/CT/background_image_music.jpg").getImage()); // ImagePanel panel = new ImagePanel(new ImageIcon("background_image_music.jpg").getImage()); /** * **************************************************************************************************************************************************** * Menu Bar * **************************************************************************************************************************************************** */ JMenuBar menuBar = new JMenuBar(); menuBar.setBackground(new Color(240, 240, 240)); setJMenuBar(menuBar); JMenu FileMenu = new JMenu("File"); FileMenu.setMnemonic('F'); menuBar.add(FileMenu); JMenuItem OpenMenuItem = new JMenuItem("Open..."); OpenMenuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser chooser = new JFileChooser(); chooser.showOpenDialog(null); File file = chooser.getSelectedFile(); // file.getName().toLowerCase().endsWith(".mp3"); String filename = file.getName(); } }); FileMenu.add(OpenMenuItem); JMenuItem CloseMenu = new JMenuItem("Close"); FileMenu.add(CloseMenu); JMenuItem RPIMenu = new JMenuItem("Recently played item"); FileMenu.add(RPIMenu); JMenuItem ExitMenu = new JMenuItem("Exit"); ExitMenu.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { System.exit(0); } }); FileMenu.add(ExitMenu); JMenu HelpMenu = new JMenu("Help"); HelpMenu.setMnemonic('H'); menuBar.add(HelpMenu); JMenuItem AboutMenu = new JMenuItem("About"); HelpMenu.add(AboutMenu); JMenuItem ContentsMenu = new JMenuItem("Help Contents"); HelpMenu.add(ContentsMenu); /* * ************************************************************************************************************************************************** */ contentPane = new JPanel(); contentPane.setBackground(new Color(240, 240, 240)); contentPane.setBorder(UIManager.getBorder("MenuBar.border")); setContentPane(contentPane); /** * *************************************************************************************************************************************************** * Adding genre list choice * **************************************************************************************************************************************************** */ /* * Setting Fonts */ Font SansSerif = new Font("SansSerif", Font.PLAIN, 14); contentPane.setFont(SansSerif); JPanel panel_2 = new JPanel(); contentPane.add(panel_2); textField_2 = new JTextField(); textField_2.setColumns(10); JLabel lblAlbum = new JLabel("Album"); lblAlbum.setFont(new Font("Showcard Gothic", Font.PLAIN, 11)); GroupLayout gl_panel_2 = new GroupLayout(panel_2); gl_panel_2.setHorizontalGroup( gl_panel_2 .createParallelGroup(Alignment.LEADING) .addGroup( gl_panel_2 .createSequentialGroup() .addGroup( gl_panel_2 .createParallelGroup(Alignment.LEADING) .addGroup( gl_panel_2 .createSequentialGroup() .addGap(45) .addComponent(lblAlbum)) .addGroup( gl_panel_2 .createSequentialGroup() .addGap(16) .addComponent( textField_2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))) .addContainerGap(17, Short.MAX_VALUE))); gl_panel_2.setVerticalGroup( gl_panel_2 .createParallelGroup(Alignment.LEADING) .addGroup( gl_panel_2 .createSequentialGroup() .addGap(5) .addComponent( textField_2, GroupLayout.PREFERRED_SIZE, 28, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(lblAlbum))); panel_2.setLayout(gl_panel_2); JPanel panel_1 = new JPanel(); contentPane.add(panel_1); textField = new JTextField(); textField.setColumns(10); JLabel lblGenre = new JLabel("Genre"); lblGenre.setFont(new Font("Showcard Gothic", Font.PLAIN, 11)); textField_1 = new JTextField(); textField_1.setColumns(10); JLabel lblArtist = new JLabel("Artist"); lblArtist.setFont(new Font("Showcard Gothic", Font.PLAIN, 11)); GroupLayout gl_panel_1 = new GroupLayout(panel_1); gl_panel_1.setHorizontalGroup( gl_panel_1 .createParallelGroup(Alignment.LEADING) .addGroup( gl_panel_1 .createSequentialGroup() .addGroup( gl_panel_1 .createParallelGroup(Alignment.LEADING) .addGroup( gl_panel_1 .createSequentialGroup() .addGap(45) .addComponent(lblGenre)) .addGroup( gl_panel_1 .createSequentialGroup() .addGap(46) .addComponent(lblArtist)) .addGroup( gl_panel_1 .createSequentialGroup() .addGap(16) .addComponent( textField_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGroup( gl_panel_1 .createSequentialGroup() .addGap(16) .addComponent( textField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))) .addContainerGap(17, Short.MAX_VALUE))); gl_panel_1.setVerticalGroup( gl_panel_1 .createParallelGroup(Alignment.LEADING) .addGroup( gl_panel_1 .createSequentialGroup() .addGap(5) .addComponent( textField, GroupLayout.PREFERRED_SIZE, 27, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(lblGenre) .addGap(5) .addComponent( textField_1, GroupLayout.PREFERRED_SIZE, 28, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(lblArtist))); panel_1.setLayout(gl_panel_1); // String genre = chooser.getSelectedItem(); // logger.debug(genre); // chooser.addItemListener((ItemListener) this); /* Event.itemStateChanged(ItemEvent e) // { String result = chooser.getSelectedItem(); myTextField.setText("Your Choice: " + result); logger.debug(result); //} */ /* * ************************************************************************************************************************************************** */ /** * ************************************************************************************************************************************************** * Adding Button * ***************************************************************************************************************************************** */ Component glue_2 = Box.createGlue(); contentPane.add(glue_2); Component glue_4 = Box.createGlue(); contentPane.add(glue_4); Component glue_5 = Box.createGlue(); contentPane.add(glue_5); Component glue_6 = Box.createGlue(); contentPane.add(glue_6); Component glue_7 = Box.createGlue(); contentPane.add(glue_7); txtTypeGenrealbumartistName = new JTextField("Enter Song"); contentPane.add(txtTypeGenrealbumartistName); txtTypeGenrealbumartistName.setSelectionColor(SystemColor.controlLtHighlight); txtTypeGenrealbumartistName.setPreferredSize(new Dimension(100, 20)); txtTypeGenrealbumartistName.setBackground(SystemColor.activeCaption); txtTypeGenrealbumartistName.setForeground(new Color(102, 0, 204)); JButton Pause = new JButton(); Pause.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { // **********For pause Button } }); // **************This whole is for progress bar*********************************** // final LongTask task = new LongTask(); // int length = 0; // final JProgressBar progressBar = new JProgressBar(0,task.getLengthOfTask()); // progressBar.setValue(0); // progressBar.setStringPainted(true); // ********************************************************************************* JButton Play = new JButton(); Play.setAlignmentX(Component.RIGHT_ALIGNMENT); Play.setAlignmentY(Component.BOTTOM_ALIGNMENT); Play.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { // To Do from the recommender system if (txtTypeGenrealbumartistName.getText().equals("Enter Song")) JOptionPane.showMessageDialog(null, "Enter something in the textbox to play"); else { String UserInput = txtTypeGenrealbumartistName.getText(); logger.debug(UserInput); // TO DO "UserInput to the recommender system // **********************OBSERVABLE***************************** try { Thread.sleep(500); } catch (InterruptedException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } // waiting for the input ObservableValue Observing_String = new ObservableValue(null); TextObserver Update_Value = new TextObserver(Observing_String); Observing_String.addObserver( Update_Value); /// *********************use as many observer as you want....If you // find difficulty just email me. // Debugging***************************************************************** // Observe observe = new Observe(); // ************************************************************************** /* * Creating a list for checking * Arrange the progressBar accordingly * */ String[] Check = new String[6]; Check[0] = "One"; // progressBar.setValue(2); Check[1] = "Two"; // progressBar.setValue(4); Check[2] = "Three"; // progressBar.setValue(6); Check[3] = "Four"; // progressBar.setValue(8); Check[4] = "Five"; // progressBar.setValue(10); Check[5] = "Six"; // logger.debug("here1"); for (int i = 0; i < Check.length; i++) { // logger.debug( Iter.next() ); Observing_String.setSong(Check[i]); /* * The updated value is shown in the text bars...here you will observe the same value as I took a single observer...rest of the thing is in email. */ textField.setText(Update_Value.GetValue()); textField_1.setText(Update_Value.GetValue()); textField_2.setText(Update_Value.GetValue()); try { Thread.sleep(2000); } catch (InterruptedException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } // DEBUGGING******************************************************************This is // used when you run it via Observe.java /*observe.startEngine(); try { Thread.sleep(3000); } catch (InterruptedException Check) { Check.printStackTrace(); } observe.stopEngine();*/ // Debugging******************************************************************* } } }); // contentPane.add(progressBar); THE ADDITION OF PROGRESS BAR! // Play.setIcon(new ImageIcon("C:\\Users\\Marium // Ahmad\\work\\P2P\\GUI\\ui\\P2P\\CT\\Button-Play-icon.png")); contentPane.add(Play); JButton Stop = new JButton(); Stop.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { // *************For stop button } }); Component glue = Box.createGlue(); contentPane.add(glue); Stop.setAlignmentX(Component.RIGHT_ALIGNMENT); Stop.setAlignmentY(Component.TOP_ALIGNMENT); // Stop.setIcon(new ImageIcon("C:\\Users\\Marium // Ahmad\\work\\P2P\\GUI\\ui\\P2P\\CT\\Button-Stop-icon.png")); contentPane.add(Stop); Pause.setAlignmentX(Component.RIGHT_ALIGNMENT); Pause.setAlignmentY(Component.TOP_ALIGNMENT); // Pause.setIcon(new ImageIcon("C:\\Users\\Marium // Ahmad\\work\\P2P\\GUI\\ui\\P2P\\CT\\Button-Pause-icon.png")); contentPane.add(Pause); JButton Skip = new JButton(); Skip.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { // *****For the Skip button } }); Component glue_1 = Box.createGlue(); contentPane.add(glue_1); // Skip.setIcon(new ImageIcon("C:\\Users\\Marium // Ahmad\\work\\P2P\\GUI\\ui\\P2P\\CT\\button_fast_forward_right_next_skip_button_bak_icon_go_arrow.png")); contentPane.add(Skip); /** * ************************************************************************************************************************************************** * Message display * ************************************************************************************************************************************************** */ ScrollPane scrollPane = new ScrollPane(); scrollPane.setForeground(Color.WHITE); scrollPane.setFont(new Font("Arial", Font.PLAIN, 12)); scrollPane.setBackground(Color.WHITE); // panel.add(scrollPane, BorderLayout.CENTER); }
public DrawPolygonMapTab() { // Setup miscallenous setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS)); backgroundColor = new Color(231, 237, 246); GridBagConstraints c = new GridBagConstraints(); dimension = Toolkit.getDefaultToolkit().getScreenSize(); // Setup buttons generateProcessing = new JButton("Plot"); saveProcessingPlot = new JButton("Save"); // Listeners generateProcessing.addActionListener(new ListenGenerateProcessing()); saveProcessingPlot.addActionListener(new ListenSaveProcessingPlot()); // Setup combo boxes String[] stringProjection = {"MERCATOR", "EQUIRECTANGULAR"}; projectionParser = new JComboBox(stringProjection); // Setup progress bar progressBar = new JProgressBar(); /** left tools pane */ leftPanel = new JPanel(); leftPanel.setBackground(backgroundColor); leftPanel.setLayout(new BoxLayout(leftPanel, BoxLayout.Y_AXIS)); leftPanel.setPreferredSize(new Dimension(leftPanelWidth, leftPanelHeight)); // ///////////// // ---INPUT---// // ///////////// tmpPanelsHolder = new JPanel(); tmpPanelsHolder.setLayout(new BoxLayout(tmpPanelsHolder, BoxLayout.Y_AXIS)); tmpPanel = new JPanel(); tmpPanel.setMaximumSize(new Dimension(leftPanelWidth + 60, 100)); tmpPanel.setBackground(backgroundColor); tmpPanel.setBorder(new TitledBorder("Choose projection:")); tmpPanel.add(projectionParser); tmpPanelsHolder.add(tmpPanel); tmpPanel = new JPanel(); tmpPanel.setMaximumSize(new Dimension(leftPanelWidth + 60, 100)); tmpPanel.setLayout(new GridBagLayout()); tmpPanel.setBackground(backgroundColor); tmpPanel.setBorder(new TitledBorder("Plot map:")); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 2; c.gridy = 0; tmpPanel.add(generateProcessing, c); c.ipady = 7; c.gridwidth = 3; c.gridx = 0; c.gridy = 1; tmpPanel.add(progressBar, c); tmpPanelsHolder.add(tmpPanel); sp = new SpinningPanel(tmpPanelsHolder, " Plotting", new Dimension(leftPanelWidth + 60, 20)); sp.showBottom(true); leftPanel.add(sp); // ////////////// // ---OUTPUT---// // ////////////// tmpPanelsHolder = new JPanel(); tmpPanelsHolder.setLayout(new BoxLayout(tmpPanelsHolder, BoxLayout.Y_AXIS)); tmpPanel = new JPanel(); tmpPanel.setMaximumSize(new Dimension(leftPanelWidth + 60, 100)); tmpPanel.setBackground(backgroundColor); tmpPanel.setBorder(new TitledBorder("Save plot:")); tmpPanel.add(saveProcessingPlot); tmpPanelsHolder.add(tmpPanel); sp = new SpinningPanel(tmpPanelsHolder, " Output", new Dimension(leftPanelWidth + 60, 20)); sp.showBottom(true); leftPanel.add(sp); // //////////////////////// // ---LEFT SCROLL PANE---// // //////////////////////// JScrollPane leftScrollPane = new JScrollPane( leftPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); leftScrollPane.setMinimumSize(new Dimension(leftPanelWidth + 60, leftPanelHeight)); add(leftScrollPane, BorderLayout.CENTER); /** Processing pane */ drawPolygonMap = new DrawPolygonMap(); drawPolygonMap.setPreferredSize(new Dimension(dimension.width, dimension.height)); // 2048, 1025 if (System.getProperty("java.runtime.name").toLowerCase().startsWith("openjdk")) { JScrollPane rightScrollPane = new JScrollPane( drawPolygonMap, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); add(rightScrollPane, BorderLayout.CENTER); } else { ScrollPane rightScrollPane = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS); rightScrollPane.add(drawPolygonMap); add(rightScrollPane, BorderLayout.CENTER); } } // END: continuousModelTab
public dbfShow(String title, String fname) throws Exception { super(title); String dbname; addWindowListener(this); sp = new ScrollPane(); viewPane = new Panel(); sp.add(viewPane); this.add(sp); if (fname == null || fname.length() == 0) { FileDialog fd = new FileDialog(this, "dbfShow", FileDialog.LOAD); fd.setFile("*.DBF"); fd.pack(); fd.setVisible(true); String DBFname = fd.getFile(); String dirname = fd.getDirectory(); if (DBFname == null) { System.exit(0); } if (DBFname.length() < 1) { System.exit(0); } dbname = new String(dirname + DBFname); } else { dbname = new String(fname); } MenuBar mb = new MenuBar(); this.setMenuBar(mb); Menu file = new Menu("File"); opener = new MenuItem("Open.."); file.add(opener); opener.addActionListener(this); packer = new MenuItem("Pack"); packer.addActionListener(this); file.add(packer); quiter = new MenuItem("Quit"); file.add(quiter); quiter.addActionListener(this); mb.add(file); Menu record = new Menu("Record"); firstRecord = new MenuItem("First"); firstRecord.addActionListener(this); record.add(firstRecord); nextRecord = new MenuItem("Next"); nextRecord.addActionListener(this); record.add(nextRecord); prevRecord = new MenuItem("Prev"); prevRecord.addActionListener(this); record.add(prevRecord); lastRecord = new MenuItem("Last"); lastRecord.addActionListener(this); record.add(lastRecord); addRecord = new MenuItem("Add"); addRecord.addActionListener(this); record.add(addRecord); updateRecord = new MenuItem("Update"); updateRecord.addActionListener(this); record.add(updateRecord); clearRecord = new MenuItem("Clear"); clearRecord.addActionListener(this); record.add(clearRecord); mb.add(record); crl = new Label("Record", Label.RIGHT); trl = new Label(" of ", Label.LEFT); SBrecpos = new Scrollbar(Scrollbar.HORIZONTAL, 1, 1, 0, 0); SBrecpos.addAdjustmentListener(this); delCB = new Checkbox("Deleted"); delCB.addItemListener(this); Prev = new Button("<<Prev"); Prev.addActionListener(this); Next = new Button("Next>>"); Next.addActionListener(this); Add = new Button("Add"); Add.addActionListener(this); Update = new Button("Update"); Update.addActionListener(this); Clear = new Button("Clear"); Clear.addActionListener(this); setupDBFields(dbname); setTitle(dbname + ", org.xBaseJ Version:" + org.xBaseJ.DBF.xBaseJVersion); pack(); setVisible(true); }
CadastrarCliente() { setTitle("Cadastrar Clientes"); setLayout(null); posicionaObjeto(jlbPesquisar, 10, 10, 100, 25); posicionaObjeto(jrbCodigo, 10, 30, 100, 25); posicionaObjeto(jrbNome, 10, 50, 150, 25); posicionaObjeto(jtfPesquisar, 160, 30, 300, 25); scpRolagem.setBounds(10, 80, 550, 300); scpRolagem.add(jtbTabela); getContentPane().add(scpRolagem); posicionaObjeto(jbtPesquisar, 470, 20, 100, 25); posicionaObjeto(jbtMostrar, 460, 50, 120, 25); posicionaObjeto(jbtNovo, 20, 400, 70, 25); posicionaObjeto(jbtConsultar, 110, 400, 100, 25); posicionaObjeto(jbtAlterar, 230, 400, 100, 25); posicionaObjeto(jbtExcluir, 350, 400, 100, 25); posicionaObjeto(jbtSair, 460, 400, 90, 25); jrbCodigo.setBackground(Color.white); jrbNome.setBackground(Color.white); btgEscolha.add(jrbCodigo); btgEscolha.add(jrbNome); jtbTabela.setModel(dtmTabela); dtmTabela.setColumnCount(3); dtmTabela.setRowCount(n); dtmTabela.setValueAt("Código", 0, 0); dtmTabela.setValueAt("Cliente", 0, 1); dtmTabela.setValueAt("Telefone", 0, 2); dtmTodos.setColumnCount(3); dtmTodos.setRowCount(1); ObjectSet<Cliente> clientes = bancoDeDados.query(Cliente.class); int linha = 1; for (Cliente cliente : clientes) { dtmTabela.setRowCount(dtmTabela.getRowCount() + 1); dtmTabela.setValueAt(cliente.getCodigo(), linha, 0); dtmTabela.setValueAt(cliente.getNome(), linha, 1); dtmTabela.setValueAt(cliente.getTelefone(), linha, 2); linha++; } jbtPesquisar.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (jrbNome.isSelected()) { if (jtfPesquisar.getText().isEmpty()) { JOptionPane.showMessageDialog( null, "Digite o nome do cliente que deseja pesquisar"); } else { ObjectSet<Cliente> clientes = bancoDeDados.query(Cliente.class); int aux = 0, linha = 1; dtmTabela.setRowCount(1); for (Cliente cliente1 : clientes) { if (cliente1.getNome().equals(jtfPesquisar.getText())) { dtmTabela.setRowCount(dtmTabela.getRowCount() + 1); dtmTabela.setValueAt(cliente1.getCodigo(), linha, 0); dtmTabela.setValueAt(cliente1.getNome(), linha, 1); dtmTabela.setValueAt(cliente1.getTelefone(), linha, 2); linha++; aux = 1; } } if (aux == 0 || jtfPesquisar.getText().isEmpty()) { JOptionPane.showMessageDialog(null, "Nenhum Cliente Encontrado"); } } } else if (jrbCodigo.isSelected()) { if (jtfPesquisar.getText().isEmpty()) { JOptionPane.showMessageDialog( null, "Digite o código do cliente que deseja pesquisar"); } else { ObjectSet<Cliente> clientes = bancoDeDados.query(Cliente.class); int aux = 0, linha = 1; dtmTabela.setRowCount(1); for (Cliente cliente1 : clientes) { if (cliente1.getCodigo().equals(Integer.valueOf(jtfPesquisar.getText()))) { dtmTabela.setRowCount(dtmTabela.getRowCount() + 1); dtmTabela.setValueAt(cliente1.getCodigo(), linha, 0); dtmTabela.setValueAt(cliente1.getNome(), linha, 1); dtmTabela.setValueAt(cliente1.getTelefone(), linha, 2); linha++; aux = 1; } } if (aux == 0 || jtfPesquisar.getText().isEmpty()) { JOptionPane.showMessageDialog(null, "Nenhum Cliente Encontrado"); } } } else { JOptionPane.showMessageDialog(null, "Selecione uma opção para pesquisar"); } } }); jbtNovo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { bancoDeDados.close(); dispose(); new NovoCliente(); } }); jbtConsultar.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { selecionado = jtbTabela.getSelectedRow(); if (selecionado == 0) { JOptionPane.showMessageDialog(null, "Não pode Visualizar essa linha"); } else if (selecionado == -1) { JOptionPane.showMessageDialog(null, "Selecione o cliente que deseja Visualizar"); } else { if (aux == 1) selecionado = procurar; bancoDeDados.close(); VisualizarCliente tela = new VisualizarCliente(); tela.setValor1(selecionado - 1); dispose(); } } }); jbtAlterar.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { selecionado = jtbTabela.getSelectedRow(); if (selecionado == 0) { JOptionPane.showMessageDialog(null, "Não pode alterar essa linha"); } else if (selecionado == -1) { JOptionPane.showMessageDialog(null, "Selecione o cliente que deseja alterar"); } else { if (aux == 1) selecionado = procurar; bancoDeDados.close(); AlterarCliente tela = new AlterarCliente(); tela.setValor1(selecionado - 1); dispose(); } } }); jbtMostrar.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { bancoDeDados.close(); dispose(); new CadastrarCliente(); } }); jbtExcluir.addActionListener( new ActionListener() { ObjectSet<ContaAReceber> contas = bancoDeDados.query(ContaAReceber.class); public void actionPerformed(ActionEvent arg0) { selecionado = jtbTabela.getSelectedRow(); if (selecionado == 0) { JOptionPane.showMessageDialog(null, "Não pode excluir essa linha"); } else if (selecionado == -1) { JOptionPane.showMessageDialog(null, "Selecione o cliente que deseja excluir"); } else { if (aux == 1) selecionado = procurar; Integer auxx = 0; ObjectSet<Cliente> clientes = bancoDeDados.query(Cliente.class); for (ContaAReceber conta : contas) { if (conta.getCliente().getNome().equals(clientes.get(selecionado - 1).getNome())) { if (conta.getDataVencimento() != null) { auxx = 1; } } } if (auxx == 1) { JOptionPane.showMessageDialog(null, "Você Não Pode Excluir esse Cliente"); JOptionPane.showMessageDialog(null, "Há Conta(s) a Receber Pendente(s)"); } else { for (ContaAReceber conta : contas) { if (conta .getCliente() .getNome() .equals(clientes.get(selecionado - 1).getNome())) { bancoDeDados.delete(conta); } } bancoDeDados.delete(clientes.get(selecionado - 1)); } bancoDeDados.close(); dispose(); new CadastrarCliente(); } } }); jbtSair.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { bancoDeDados.close(); dispose(); } }); setSize(600, 600); setLocationRelativeTo(null); this.getContentPane().setBackground(Color.white); this.setResizable(false); setDefaultCloseOperation(DISPOSE_ON_CLOSE); setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); setVisible(true); }