@Override protected JComponent createCenterPanel() { final JPanel panel = new JPanel(new BorderLayout()); JTextArea area = new JTextArea( "The imported language extends other languages.\n" + "It might be useful to import all or some of them."); area.setEditable(false); area.setBackground(this.getContentPane().getBackground()); area.setBorder(BorderFactory.createEmptyBorder(5, 5, 3, 5)); panel.add(area, BorderLayout.NORTH); JPanel center = new JPanel(new GridBagLayout()); JTextArea label = new JTextArea("Select additional languages to import:"); label.setEditable(false); label.setBackground(getContentPane().getBackground()); label.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); center.add( label, new GridBagConstraints( 0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); myList = new JBList(myCandidates.toArray()); myList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); myList.setSelectionInterval(0, myList.getModel().getSize() - 1); myList.setCellRenderer(new MyDefaultListCellRenderer()); myList.setBorder(BorderFactory.createEtchedBorder()); center.add( ScrollPaneFactory.createScrollPane(myList), new GridBagConstraints( 0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); panel.add(center, BorderLayout.CENTER); panel.setPreferredSize(new Dimension(400, 250)); return panel; }
public void mousePressed(MouseEvent e) { if (e.getButton() == e.BUTTON3) { NumberFormat nf = NumberFormat.getInstance(); nf.setMaximumFractionDigits(2); int index = list.locationToIndex(e.getPoint()); GetImageFile gif = new GetImageFile(files[index]); JTextArea area = new JTextArea( "File: " + gif.getImageString() + "\n" + "Score: " + nf.format(scores[index]) + "\n" + "Pairs: " + nrpairs[index]); area.setEditable(false); area.setBorder(BorderFactory.createLineBorder(Color.black)); area.setFont(new Font("times", Font.PLAIN, 12)); PopupFactory factory = PopupFactory.getSharedInstance(); popup = factory.getPopup( null, area, (int) e.getComponent().getLocationOnScreen().getX() + e.getX() + 25, (int) e.getComponent().getLocationOnScreen().getY() + e.getY()); popup.show(); } }
private void addComponents() { this.setLayout(new BorderLayout()); this.setSize(new Dimension(350, 200)); // set display location Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); this.setLocation((d.width - getWidth()) / 2, (d.height - getHeight()) / 2); textArea = new JTextArea(); textArea.setLineWrap(true); textArea.setEditable(false); textArea.setBorder(BorderFactory.createLineBorder(Color.gray)); JScrollPane scrollPane = new JScrollPane( textArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); this.add(scrollPane, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton closeButton = new JButton("Close"); closeButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { PopupDialog.this.setVisible(false); } }); buttonPanel.add(closeButton); this.add(buttonPanel, BorderLayout.SOUTH); }
/** Create and add Clippy's output text */ public void addClippyTxt() { clippyTxt.setLineWrap(true); clippyTxt.setWrapStyleWord(true); clippyTxt.setEditable(false); clippyTxt.setFont(txtFont); clippyTxt.setAlignmentX(JTextArea.CENTER_ALIGNMENT); clippyTxt.setAlignmentY(JTextArea.CENTER_ALIGNMENT); clippyTxt.setBorder(null); clippyTxt.setSize(105, 35); clippyTxt.setLocation(25, 45); clippyTxt.setOpaque(false); lpane.add(clippyTxt, new Integer(1), 0); }
public JStatusBar() { setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); setLayout(new BorderLayout(0, 0)); statusBar = new JLabel(); statusBar.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); statusBar.setAlignmentX(JComponent.LEFT_ALIGNMENT); miniBuf = new JTextArea(); miniBuf.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); miniBuf.setEditable(false); miniBuf.setLineWrap(true); miniBuf.setRows(1); JScrollPane scrollPane = new JScrollPane(); scrollPane.getViewport().setView(miniBuf); add(statusBar, BorderLayout.PAGE_START); add(scrollPane, BorderLayout.PAGE_END); statusBar.setText(" "); miniBuf.setText(""); }
public Gui2() { setTitle("My First Gui"); setSize(600, 600); setLocation(100, 100); setDefaultCloseOperation(EXIT_ON_CLOSE); pane = getContentPane(); // pane.setLayout(new GridLayout(3,3)); pane.setLayout(new FlowLayout()); b1 = new JButton("Click me"); b1.addActionListener(this); pane.add(b1); b2 = new JButton("exit"); b2.addActionListener(this); pane.add(b2); labeler = new JButton("Labeler"); labeler.addActionListener(this); pane.add(labeler); label = new JLabel("The Label:"); pane.add(label); box = new JCheckBox("Cap"); pane.add(box); text = new JTextArea(); text.setColumns(40); text.setRows(5); text.setBorder(BorderFactory.createLineBorder(Color.red, 2)); text.addKeyListener(new Key()); pane.add(text); canvas = new Canvas(); canvas.setPreferredSize(new Dimension(300, 300)); canvas.setBorder(BorderFactory.createLineBorder(Color.blue, 2)); pane.add(canvas); }
/** Populates the frame with UI controls. */ private void buildUI() { Container cPane = getContentPane(); cPane.setLayout(new BorderLayout()); // Split pane for message text area and input text area mChatSplitter = new JSplitPane(JSplitPane.VERTICAL_SPLIT); mChatSplitter.setResizeWeight(1); mChatSplitter.setBorder(BorderFactory.createEmptyBorder()); mLog = new ChatLogPanel(mColorMap); mChatSplitter.setTopComponent(mLog); mInputText = new JTextArea(); mInputText.setLineWrap(true); mInputText.setWrapStyleWord(true); mInputText.setBorder(BorderFactory.createEmptyBorder(1, 4, 1, 4)); mChatSplitter.setBottomComponent(new JScrollPane(mInputText)); cPane.add(mChatSplitter, BorderLayout.CENTER); // Necessary for all windows, for Mac support AppMenuBar.applyPlatformMenuBar(this); }
public DefaultDnDSupport() { JFrame fen = new JFrame("DnD et CCP"); fen.getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER)); fen.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Panel gauche JPanel panelgauche = new JPanel(); panelgauche.setLayout(new BoxLayout(panelgauche, BoxLayout.Y_AXIS)); // JTextField JTextField textField = new JTextField(10); textField.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("JTextField"), BorderFactory.createEmptyBorder(5, 5, 5, 5))); textField.setDragEnabled(true); // JPasswordField JPasswordField passwordField = new JPasswordField(10); passwordField.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("JPasswordField"), BorderFactory.createEmptyBorder(5, 5, 5, 5))); passwordField.setDragEnabled(true); // JFormattedTextField JFormattedTextField ftf = new JFormattedTextField("Universite de Lille 1"); ftf.setFont(new Font("Courier", Font.ITALIC, 12)); ftf.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("JFormattedTextField"), BorderFactory.createEmptyBorder(5, 5, 5, 5))); ftf.setDragEnabled(true); // JTextArea JTextArea jta = new JTextArea("Master 1 informatique"); jta.setFont(new Font("Arial", Font.BOLD, 12)); jta.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("JTextArea"), BorderFactory.createEmptyBorder(5, 5, 5, 5))); jta.setDragEnabled(true); // JEditorPane JEditorPane editorPane = createEditorPane(); editorPane.setDragEnabled(true); JScrollPane editorScrollPane = new JScrollPane(editorPane); editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); editorScrollPane.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("JEditorPane"), BorderFactory.createEmptyBorder(5, 5, 5, 5))); // JColorChooser JColorChooser cc = new JColorChooser(); cc.setDragEnabled(true); cc.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("JColorChooser"), BorderFactory.createEmptyBorder(5, 5, 5, 5))); // Panel droit JPanel paneldroit = new JPanel(); paneldroit.setLayout(new BoxLayout(paneldroit, BoxLayout.Y_AXIS)); // JList String[] data = { "AAC", "AEV", "ANG", "ASE", "COA", "PJE", "CAR", "PJI", "AeA", "BDA", "CALP", "FDD", "HECI", "IHM", "M3DS", "PAC", "PPD", "RdF", "SVL", "TI" }; JList liste = new JList(data); JScrollPane jscrollListe = new JScrollPane(liste); jscrollListe.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("JList"), BorderFactory.createEmptyBorder(5, 5, 5, 5))); // liste.setDragEnabled(true); // JTree DefaultMutableTreeNode m1 = new DefaultMutableTreeNode("M1"); DefaultMutableTreeNode s1 = new DefaultMutableTreeNode("S1"); m1.add(s1); s1.add(new DefaultMutableTreeNode("AAC")); s1.add(new DefaultMutableTreeNode("AEV")); s1.add(new DefaultMutableTreeNode("ANG")); s1.add(new DefaultMutableTreeNode("ASE")); s1.add(new DefaultMutableTreeNode("COA")); s1.add(new DefaultMutableTreeNode("PJE")); DefaultMutableTreeNode s2 = new DefaultMutableTreeNode("S2"); m1.add(s2); s2.add(new DefaultMutableTreeNode("CAR")); s2.add(new DefaultMutableTreeNode("PJI")); s2.add(new DefaultMutableTreeNode("AeA")); s2.add(new DefaultMutableTreeNode("BDA")); s2.add(new DefaultMutableTreeNode("CALP")); s2.add(new DefaultMutableTreeNode("FDD")); s2.add(new DefaultMutableTreeNode("HECI")); s2.add(new DefaultMutableTreeNode("IHM")); s2.add(new DefaultMutableTreeNode("M3DS")); s2.add(new DefaultMutableTreeNode("PAC")); s2.add(new DefaultMutableTreeNode("PPD")); s2.add(new DefaultMutableTreeNode("RdF")); s2.add(new DefaultMutableTreeNode("SVL")); s2.add(new DefaultMutableTreeNode("TI")); JTree tree = new JTree(m1); // tree.setDragEnabled(true); JScrollPane jscrollTree = new JScrollPane(tree); jscrollTree.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("JTree"), BorderFactory.createEmptyBorder(5, 5, 5, 5))); jscrollTree.setPreferredSize(new Dimension(200, 200)); // JTable String[] columnNames = {"S1", "S2"}; Object[][] data2 = { {"AAC", "CAR"}, {"AEV", "PJI"}, {"ANG", "AeA"}, {"ASE", "BDA"}, {"COA", "CALP"}, {"PJE", "FDD"}, {"", "HECI"}, {"", "IHM"}, {"", "M3DS"}, {"", "PAC"}, {"", "PPD"}, {"", "RdF"}, {"", "SVL"}, {"", "TI"} }; JTable table = new JTable(data2, columnNames); JScrollPane scrollPaneTable = new JScrollPane(table); table.setDragEnabled(true); // JFileChooser JFileChooser fc = new JFileChooser(); fc.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("JFileChooser"), BorderFactory.createEmptyBorder(5, 5, 5, 5))); fc.setDragEnabled(true); panelgauche.add(textField); panelgauche.add(passwordField); panelgauche.add(ftf); panelgauche.add(jta); panelgauche.add(cc); panelgauche.add(editorScrollPane); fen.getContentPane().add(panelgauche); paneldroit.add(fc); paneldroit.add(jscrollListe); paneldroit.add(jscrollTree); paneldroit.add(scrollPaneTable); fen.getContentPane().add(paneldroit); fen.pack(); fen.setVisible(true); }
public JComponent buildCommon() { String colSpec = FormLayoutUtil.getColSpec(COMMON_COL_SPEC, orientation); FormLayout layout = new FormLayout(colSpec, COMMON_ROW_SPEC); PanelBuilder builder = new PanelBuilder(layout); builder.setBorder(Borders.EMPTY_BORDER); builder.setOpaque(false); CellConstraints cc = new CellConstraints(); maxbuffer = new JTextField("" + configuration.getMaxMemoryBufferSize()); maxbuffer.addKeyListener( new KeyListener() { @Override public void keyPressed(KeyEvent e) {} @Override public void keyTyped(KeyEvent e) {} @Override public void keyReleased(KeyEvent e) { try { int ab = Integer.parseInt(maxbuffer.getText()); configuration.setMaxMemoryBufferSize(ab); } catch (NumberFormatException nfe) { LOGGER.debug( "Could not parse max memory buffer size from \"" + maxbuffer.getText() + "\""); } } }); JComponent cmp = builder.addSeparator( Messages.getString("NetworkTab.5"), FormLayoutUtil.flip(cc.xyw(1, 1, 3), colSpec, orientation)); cmp = (JComponent) cmp.getComponent(0); cmp.setFont(cmp.getFont().deriveFont(Font.BOLD)); builder.addLabel( Messages.getString("NetworkTab.6") .replaceAll("MAX_BUFFER_SIZE", configuration.getMaxMemoryBufferSizeStr()), FormLayoutUtil.flip(cc.xy(1, 3), colSpec, orientation)); builder.add(maxbuffer, FormLayoutUtil.flip(cc.xy(3, 3), colSpec, orientation)); String nCpusLabel = String.format( Messages.getString("NetworkTab.7"), Runtime.getRuntime().availableProcessors()); builder.addLabel(nCpusLabel, FormLayoutUtil.flip(cc.xy(1, 5), colSpec, orientation)); String[] guiCores = new String[MAX_CORES]; for (int i = 0; i < MAX_CORES; i++) { guiCores[i] = Integer.toString(i + 1); } nbcores = new JComboBox(guiCores); nbcores.setEditable(false); int nbConfCores = configuration.getNumberOfCpuCores(); if (nbConfCores > 0 && nbConfCores <= MAX_CORES) { nbcores.setSelectedItem(Integer.toString(nbConfCores)); } else { nbcores.setSelectedIndex(0); } nbcores.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { configuration.setNumberOfCpuCores(Integer.parseInt(e.getItem().toString())); } }); builder.add(nbcores, FormLayoutUtil.flip(cc.xy(3, 5), colSpec, orientation)); chapter_interval = new JTextField("" + configuration.getChapterInterval()); chapter_interval.setEnabled(configuration.isChapterSupport()); chapter_interval.addKeyListener( new KeyListener() { @Override public void keyPressed(KeyEvent e) {} @Override public void keyTyped(KeyEvent e) {} @Override public void keyReleased(KeyEvent e) { try { int ab = Integer.parseInt(chapter_interval.getText()); configuration.setChapterInterval(ab); } catch (NumberFormatException nfe) { LOGGER.debug( "Could not parse chapter interval from \"" + chapter_interval.getText() + "\""); } } }); chapter_support = new JCheckBox(Messages.getString("TrTab2.52")); chapter_support.setContentAreaFilled(false); chapter_support.setSelected(configuration.isChapterSupport()); chapter_support.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { configuration.setChapterSupport((e.getStateChange() == ItemEvent.SELECTED)); chapter_interval.setEnabled(configuration.isChapterSupport()); } }); builder.add(chapter_support, FormLayoutUtil.flip(cc.xy(1, 7), colSpec, orientation)); builder.add(chapter_interval, FormLayoutUtil.flip(cc.xy(3, 7), colSpec, orientation)); cmp = builder.addSeparator( Messages.getString("TrTab2.3"), FormLayoutUtil.flip(cc.xyw(1, 11, 3), colSpec, orientation)); cmp = (JComponent) cmp.getComponent(0); cmp.setFont(cmp.getFont().deriveFont(Font.BOLD)); channels = new JComboBox( new Object[] { Messages.getString("TrTab2.55"), Messages.getString("TrTab2.56") /*, "8 channels 7.1" */ }); // 7.1 not supported by Mplayer :\ channels.setEditable(false); if (configuration.getAudioChannelCount() == 2) { channels.setSelectedIndex(0); } else { channels.setSelectedIndex(1); } channels.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { configuration.setAudioChannelCount( Integer.parseInt(e.getItem().toString().substring(0, 1))); } }); builder.addLabel( Messages.getString("TrTab2.50"), FormLayoutUtil.flip(cc.xy(1, 13), colSpec, orientation)); builder.add(channels, FormLayoutUtil.flip(cc.xy(3, 13), colSpec, orientation)); forcePCM = new JCheckBox(Messages.getString("TrTab2.27")); forcePCM.setContentAreaFilled(false); if (configuration.isMencoderUsePcm()) { forcePCM.setSelected(true); } forcePCM.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { configuration.setMencoderUsePcm(e.getStateChange() == ItemEvent.SELECTED); } }); builder.add(forcePCM, FormLayoutUtil.flip(cc.xyw(1, 15, 3), colSpec, orientation)); ac3remux = new JCheckBox( Messages.getString("MEncoderVideo.32") + (Platform.isWindows() ? Messages.getString("TrTab2.21") : "")); ac3remux.setContentAreaFilled(false); if (configuration.isRemuxAC3()) { ac3remux.setSelected(true); } ac3remux.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { configuration.setRemuxAC3((e.getStateChange() == ItemEvent.SELECTED)); } }); builder.add(ac3remux, FormLayoutUtil.flip(cc.xyw(1, 17, 3), colSpec, orientation)); forceDTSinPCM = new JCheckBox( Messages.getString("TrTab2.28") + (Platform.isWindows() ? Messages.getString("TrTab2.21") : "")); forceDTSinPCM.setContentAreaFilled(false); if (configuration.isDTSEmbedInPCM()) { forceDTSinPCM.setSelected(true); } forceDTSinPCM.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { configuration.setDTSEmbedInPCM(forceDTSinPCM.isSelected()); if (configuration.isDTSEmbedInPCM()) { JOptionPane.showMessageDialog( (JFrame) (SwingUtilities.getWindowAncestor((Component) PMS.get().getFrame())), Messages.getString("TrTab2.10"), "Information", JOptionPane.INFORMATION_MESSAGE); } } }); builder.add(forceDTSinPCM, FormLayoutUtil.flip(cc.xyw(1, 19, 3), colSpec, orientation)); abitrate = new JTextField("" + configuration.getAudioBitrate()); abitrate.addKeyListener( new KeyListener() { @Override public void keyPressed(KeyEvent e) {} @Override public void keyTyped(KeyEvent e) {} @Override public void keyReleased(KeyEvent e) { try { int ab = Integer.parseInt(abitrate.getText()); configuration.setAudioBitrate(ab); } catch (NumberFormatException nfe) { LOGGER.debug("Could not parse audio bitrate from \"" + abitrate.getText() + "\""); } } }); builder.addLabel( Messages.getString("TrTab2.29"), FormLayoutUtil.flip(cc.xy(1, 21), colSpec, orientation)); builder.add(abitrate, FormLayoutUtil.flip(cc.xy(3, 21), colSpec, orientation)); mpeg2remux = new JCheckBox( Messages.getString("MEncoderVideo.39") + (Platform.isWindows() ? Messages.getString("TrTab2.21") : "")); mpeg2remux.setContentAreaFilled(false); if (configuration.isMencoderRemuxMPEG2()) { mpeg2remux.setSelected(true); } mpeg2remux.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { configuration.setMencoderRemuxMPEG2((e.getStateChange() == ItemEvent.SELECTED)); } }); builder.add(mpeg2remux, FormLayoutUtil.flip(cc.xyw(1, 23, 3), colSpec, orientation)); cmp = builder.addSeparator( Messages.getString("TrTab2.4"), FormLayoutUtil.flip(cc.xyw(1, 25, 3), colSpec, orientation)); cmp = (JComponent) cmp.getComponent(0); cmp.setFont(cmp.getFont().deriveFont(Font.BOLD)); builder.addLabel( Messages.getString("TrTab2.32"), FormLayoutUtil.flip(cc.xyw(1, 29, 3), colSpec, orientation)); Object data[] = new Object[] { configuration.getMencoderMainSettings(), /* default */ String.format( "keyint=5:vqscale=1:vqmin=2 /* %s */", Messages.getString("TrTab2.60")), /* great */ String.format( "keyint=5:vqscale=1:vqmin=1 /* %s */", Messages.getString("TrTab2.61")), /* lossless */ String.format( "keyint=5:vqscale=2:vqmin=3 /* %s */", Messages.getString("TrTab2.62")), /* good (wired) */ String.format( "keyint=25:vqmax=5:vqmin=2 /* %s */", Messages.getString("TrTab2.63")), /* good (wireless) */ String.format( "keyint=25:vqmax=7:vqmin=2 /* %s */", Messages.getString("TrTab2.64")), /* medium (wireless) */ String.format( "keyint=25:vqmax=8:vqmin=3 /* %s */", Messages.getString("TrTab2.65")) /* low */ }; MyComboBoxModel cbm = new MyComboBoxModel(data); vq = new JComboBox(cbm); vq.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { String s = (String) e.getItem(); if (s.indexOf("/*") > -1) { s = s.substring(0, s.indexOf("/*")).trim(); } configuration.setMencoderMainSettings(s); } } }); vq.getEditor() .getEditorComponent() .addKeyListener( new KeyListener() { @Override public void keyPressed(KeyEvent e) {} @Override public void keyTyped(KeyEvent e) {} @Override public void keyReleased(KeyEvent e) { vq.getItemListeners()[0].itemStateChanged( new ItemEvent(vq, 0, vq.getEditor().getItem(), ItemEvent.SELECTED)); } }); vq.setEditable(true); builder.add(vq, FormLayoutUtil.flip(cc.xyw(1, 31, 3), colSpec, orientation)); String help1 = Messages.getString("TrTab2.39"); help1 += Messages.getString("TrTab2.40"); help1 += Messages.getString("TrTab2.41"); help1 += Messages.getString("TrTab2.42"); help1 += Messages.getString("TrTab2.43"); help1 += Messages.getString("TrTab2.44"); JTextArea decodeTips = new JTextArea(help1); decodeTips.setEditable(false); decodeTips.setBorder(BorderFactory.createEtchedBorder()); decodeTips.setBackground(new Color(255, 255, 192)); builder.add(decodeTips, FormLayoutUtil.flip(cc.xyw(1, 41, 3), colSpec, orientation)); disableSubs = new JCheckBox(Messages.getString("TrTab2.51")); disableSubs.setContentAreaFilled(false); cmp = builder.addSeparator( Messages.getString("TrTab2.7"), FormLayoutUtil.flip(cc.xyw(1, 33, 3), colSpec, orientation)); cmp = (JComponent) cmp.getComponent(0); cmp.setFont(cmp.getFont().deriveFont(Font.BOLD)); builder.add(disableSubs, FormLayoutUtil.flip(cc.xy(1, 35), colSpec, orientation)); builder.addLabel( Messages.getString("TrTab2.8"), FormLayoutUtil.flip(cc.xy(1, 37), colSpec, orientation)); notranscode = new JTextField(configuration.getNoTranscode()); notranscode.addKeyListener( new KeyListener() { @Override public void keyPressed(KeyEvent e) {} @Override public void keyTyped(KeyEvent e) {} @Override public void keyReleased(KeyEvent e) { configuration.setNoTranscode(notranscode.getText()); } }); builder.add(notranscode, FormLayoutUtil.flip(cc.xy(3, 37), colSpec, orientation)); builder.addLabel( Messages.getString("TrTab2.9"), FormLayoutUtil.flip(cc.xy(1, 39), colSpec, orientation)); forcetranscode = new JTextField(configuration.getForceTranscode()); forcetranscode.addKeyListener( new KeyListener() { @Override public void keyPressed(KeyEvent e) {} @Override public void keyTyped(KeyEvent e) {} @Override public void keyReleased(KeyEvent e) { configuration.setForceTranscode(forcetranscode.getText()); } }); builder.add(forcetranscode, FormLayoutUtil.flip(cc.xy(3, 39), colSpec, orientation)); JPanel panel = builder.getPanel(); // Apply the orientation to the panel and all components in it panel.applyComponentOrientation(orientation); return panel; }
public void makeGUI() { frm = new JFrame(); c = frm.getContentPane(); btnImport = new JButton("Import"); btnImport.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { secureImport(); } }); btnMove = new JButton("Move"); btnMove.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { secureMove(); } }); btnDelete = new JButton("Delete"); btnDelete.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { secureDelete(); } }); btnAnalyse = new JButton("Analyse"); btnAnalyse.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { secureAnalysis(); } }); tblItems = new JTable(store); tblItems.setRowSorter(tableSorter); tblItems.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); tblItems.setFillsViewportHeight(true); tblItems.getRowSorter().toggleSortOrder(Storage.COL_DATE); tblItems.addMouseListener( new MouseListener() { public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3) { tblItems.setRowSelectionInterval( e.getY() / tblItems.getRowHeight(), e.getY() / tblItems.getRowHeight()); } if (e.getClickCount() > 1 || e.getButton() == MouseEvent.BUTTON3) { int idx = tblItems.convertRowIndexToModel(tblItems.getSelectedRow()); secureExport(idx); } } public void mouseEntered(MouseEvent arg0) {} public void mouseExited(MouseEvent arg0) {} public void mousePressed(MouseEvent arg0) {} public void mouseReleased(MouseEvent arg0) {} }); txaStatus = new JTextArea(TXA_HEIGHT, TXA_WIDTH); txaStatus.setEditable(false); txaStatus.setBorder(BorderFactory.createTitledBorder("Status")); txaSearch = new JTextArea(4, TXA_WIDTH); txaSearch.setBorder(BorderFactory.createTitledBorder("Search")); txaSearch.addKeyListener( new KeyListener() { public void keyPressed(KeyEvent arg0) {} public void keyReleased(KeyEvent arg0) { filterBase(txaSearch.getText()); // EXPORT settings here, as in mass export (export everything) if (allowExport && txaSearch.getText().equalsIgnoreCase(CMD_EXPORT)) { // txaSearch.setText(""); if (JOptionPane.showConfirmDialog( frm, "Do you really want to export the whole secure base?", "Confirm Export", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) { totalExport(); } } // LOST X IMPORT asin look through the store for files not listed if (txaSearch.getText().equalsIgnoreCase(CMD_STOCKTAKE)) { for (int i = 0; i < storeLocs.size(); i++) { if (store.stockTake(i)) needsSave = true; } } } public void keyTyped(KeyEvent arg0) {} }); JPanel pnlTop = new JPanel(new GridLayout(1, 4)); JPanel pnlEast = new JPanel(new BorderLayout()); JPanel pnlCenterEast = new JPanel(new BorderLayout()); JScrollPane jspItems = new JScrollPane(tblItems); pnlTop.add(btnImport); pnlTop.add(btnMove); pnlTop.add(btnDelete); pnlTop.add(btnAnalyse); pnlCenterEast.add(txaStatus, BorderLayout.CENTER); pnlCenterEast.add(txaSearch, BorderLayout.NORTH); // pnlEast.add(pswPass, BorderLayout.NORTH); pnlEast.add(pnlCenterEast, BorderLayout.CENTER); c.setLayout(new BorderLayout()); c.add(pnlTop, BorderLayout.NORTH); c.add(pnlEast, BorderLayout.EAST); c.add(jspItems, BorderLayout.CENTER); frm.setContentPane(c); }
public HTTPProxySettingsPanel(final HttpConfigurable httpConfigurable) { final ButtonGroup group = new ButtonGroup(); group.add(myUseHTTPProxyRb); group.add(myAutoDetectProxyRb); group.add(myNoProxyRb); myNoProxyRb.setSelected(true); final ButtonGroup proxyTypeGroup = new ButtonGroup(); proxyTypeGroup.add(myHTTP); proxyTypeGroup.add(mySocks); myHTTP.setSelected(true); myProxyExceptions.setBorder(UIUtil.getTextFieldBorder()); final Boolean property = Boolean.getBoolean(JavaProxyProperty.USE_SYSTEM_PROXY); mySystemProxyDefined.setVisible(Boolean.TRUE.equals(property)); if (Boolean.TRUE.equals(property)) { mySystemProxyDefined.setIcon(Messages.getWarningIcon()); mySystemProxyDefined.setFont(mySystemProxyDefined.getFont().deriveFont(Font.BOLD)); mySystemProxyDefined.setUI(new MultiLineLabelUI()); } myProxyAuthCheckBox.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { enableProxyAuthentication(myProxyAuthCheckBox.isSelected()); } }); myPacUrlCheckBox.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { myPacUrlTextField.setEnabled(myPacUrlCheckBox.isSelected()); } }); final ActionListener listener = new ActionListener() { public void actionPerformed(ActionEvent e) { enableProxy(myUseHTTPProxyRb.isSelected()); } }; myUseHTTPProxyRb.addActionListener(listener); myAutoDetectProxyRb.addActionListener(listener); myNoProxyRb.addActionListener(listener); myHttpConfigurable = httpConfigurable; myClearPasswordsButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { myHttpConfigurable.clearGenericPasswords(); Messages.showMessageDialog( myMainPanel, "Proxy passwords were cleared.", "Auto-detected proxy", Messages.getInformationIcon()); } }); if (HttpConfigurable.getInstance() != null) { myCheckButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final String title = "Check Proxy Settings"; final String answer = Messages.showInputDialog( myMainPanel, "Warning: your settings will be saved.\n\nEnter any URL to check connection to:", title, Messages.getQuestionIcon(), "http://", null); if (!StringUtil.isEmptyOrSpaces(answer)) { apply(); final HttpConfigurable instance = HttpConfigurable.getInstance(); final AtomicReference<IOException> exc = new AtomicReference<IOException>(); myCheckButton.setEnabled(false); myCheckButton.setText("Check connection (in progress...)"); myConnectionCheckInProgress = true; final Application application = ApplicationManager.getApplication(); application.executeOnPooledThread( new Runnable() { @Override public void run() { HttpURLConnection connection = null; try { // already checked for null above //noinspection ConstantConditions connection = instance.openHttpConnection(answer); connection.setReadTimeout(3 * 1000); connection.setConnectTimeout(3 * 1000); connection.connect(); final int code = connection.getResponseCode(); if (HttpURLConnection.HTTP_OK != code) { exc.set(new IOException("Error code: " + code)); } } catch (IOException e1) { exc.set(e1); } finally { if (connection != null) { connection.disconnect(); } } //noinspection SSBasedInspection SwingUtilities.invokeLater( new Runnable() { @Override public void run() { myConnectionCheckInProgress = false; reset(); // since password might have been set Component parent = null; if (myMainPanel.isShowing()) { parent = myMainPanel; myCheckButton.setText("Check connection"); myCheckButton.setEnabled(canEnableConnectionCheck()); } else { final IdeFrame frame = IdeFocusManager.findInstance().getLastFocusedFrame(); if (frame == null) { return; } parent = frame.getComponent(); } //noinspection ThrowableResultOfMethodCallIgnored final IOException exception = exc.get(); if (exception == null) { Messages.showMessageDialog( parent, "Connection successful", title, Messages.getInformationIcon()); } else { final String message = exception.getMessage(); if (instance.USE_HTTP_PROXY) { instance.LAST_ERROR = message; } Messages.showErrorDialog(parent, errorText(message)); } } }); } }); } } }); } else { myCheckButton.setVisible(false); } }
private void jbInit() throws Exception { this.getContentPane().setLayout(gridBagLayout1); jProgressBar1.setValue(50); lblTask.setFont(new java.awt.Font("Dialog", 1, 11)); lblTask.setText("Deploying all Units"); btnCancel.setText("Cancel"); btnClose.setEnabled(false); btnClose.setText("Close"); btnClose.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { btnCloseActionPerformed(e); } }); txtDetail.setBackground(UIManager.getColor("Label.background")); txtDetail.setFont(new java.awt.Font("SansSerif", 0, 12)); txtDetail.setForeground(Color.black); txtDetail.setBorder(BorderFactory.createLoweredBevelBorder()); txtDetail.setDoubleBuffered(true); txtDetail.setEditable(false); txtDetail.setLineWrap(true); txtDetail.setWrapStyleWord(true); this.getContentPane() .add( lblTask, new GridBagConstraints( 0, 0, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 10, 0, 10), 313, 6)); this.getContentPane() .add( jProgressBar1, new GridBagConstraints( 0, 2, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 10, 0, 10), 257, 5)); this.getContentPane() .add( btnCancel, new GridBagConstraints( 0, 3, 1, 1, 1.0, 0.0, GridBagConstraints.SOUTHWEST, GridBagConstraints.NONE, new Insets(15, 10, 10, 0), 0, 0)); this.getContentPane() .add( btnClose, new GridBagConstraints( 1, 3, 1, 1, 1.0, 0.0, GridBagConstraints.SOUTHEAST, GridBagConstraints.NONE, new Insets(15, 0, 10, 10), 0, 0)); this.getContentPane() .add( txtDetail, new GridBagConstraints( 0, 1, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 10, 10, 10), 0, 0)); }
/** Creates the design and add the input field to the panel */ public void addField() { exeTxt.setBounds(55, 195, 300, 30); exeTxt.setFont(txtFont); exeTxt.setBorder(new EtchedBorder()); clipPnl.add(exeTxt); }
public OptionsDialog(JFrame parent) { super(parent, Globals.lang("Writing XMP metadata for selected entries..."), false); okButton.setEnabled(false); okButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { dispose(); } }); AbstractAction cancel = new AbstractAction() { private static final long serialVersionUID = -338601477652815366L; public void actionPerformed(ActionEvent e) { canceled = true; } }; cancelButton.addActionListener(cancel); InputMap im = cancelButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); ActionMap am = cancelButton.getActionMap(); im.put(Globals.prefs.getKey("Close dialog"), "close"); am.put("close", cancel); progressArea = new JTextArea(15, 60); JScrollPane scrollPane = new JScrollPane( progressArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); Dimension d = progressArea.getPreferredSize(); d.height += scrollPane.getHorizontalScrollBar().getHeight() + 15; d.width += scrollPane.getVerticalScrollBar().getWidth() + 15; panel.setSize(d); progressArea.setBackground(Color.WHITE); progressArea.setEditable(false); progressArea.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); progressArea.setText(""); JPanel panel = new JPanel(); panel.setBorder(BorderFactory.createEmptyBorder(3, 2, 3, 2)); panel.add(scrollPane); // progressArea.setPreferredSize(new Dimension(300, 300)); ButtonBarBuilder bb = new ButtonBarBuilder(); bb.addGlue(); bb.addGridded(okButton); bb.addRelatedGap(); bb.addGridded(cancelButton); bb.addGlue(); JPanel bbPanel = bb.getPanel(); bbPanel.setBorder(BorderFactory.createEmptyBorder(0, 3, 3, 3)); getContentPane().add(panel, BorderLayout.CENTER); getContentPane().add(bbPanel, BorderLayout.SOUTH); pack(); this.setResizable(false); }
public Project2() { frame = new JFrame(""); frame.setLayout(new GridLayout(2, 2)); frame.setSize(300, 500); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jta = new JTextArea("Tree View", 17, 25); jta.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); jta.setEditable(false); frame.add(jta); userId = new JTextArea("User Id"); groupId = new JTextArea("Group Id"); JButton addUser = new JButton("Add User"); JButton addGroup = new JButton("Add Group"); JButton openUserView = new JButton("Open User View"); JButton showUserTotal = new JButton("Show User Total"); JButton showGroupTotal = new JButton("Show Group Total"); JButton showMessagesTotal = new JButton("Show Messages Total"); JButton showPositivePercentage = new JButton("Show Positive Percentage"); addUser.addActionListener(this); addGroup.addActionListener(this); openUserView.addActionListener(this); showUserTotal.addActionListener(this); showGroupTotal.addActionListener(this); showMessagesTotal.addActionListener(this); showPositivePercentage.addActionListener(this); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new GridLayout(5, 2)); buttonPanel.add(userId); buttonPanel.add(addUser); buttonPanel.add(groupId); buttonPanel.add(addGroup); buttonPanel.add(openUserView); buttonPanel.add(showUserTotal); buttonPanel.add(showGroupTotal); buttonPanel.add(showMessagesTotal); buttonPanel.add(showPositivePercentage); frame.add(buttonPanel); frame.setVisible(true); userView = new JFrame(""); userView.setLayout(new GridLayout(2, 2)); userView.setSize(300, 500); following = new JTextArea("Current Following", 17, 5); following.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); JButton followUser = new JButton("Follow User"); userId2 = new JTextArea("User Id"); JPanel followingPanel = new JPanel(); followingPanel.setLayout(new GridLayout(2, 2)); followingPanel.add(userId2); followingPanel.add(followUser); followingPanel.add(following); userView.add(followingPanel); tweet = new JTextArea("Tweet Message"); JButton postTweet = new JButton("Post Tweet"); newsFeed = new JTextArea("News Feed", 30, 5); newsFeed.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); newsFeed.setEditable(false); postTweet.addActionListener(this); followUser.addActionListener(this); JPanel tweetPanel = new JPanel(); tweetPanel.setLayout(new GridLayout(2, 2)); tweetPanel.add(tweet); tweetPanel.add(postTweet); tweetPanel.add(newsFeed); userView.add(tweetPanel); }
public CellarGUI(Cellar model) { this.model = model; setTitle("Cellar"); setSize(new Dimension(1000, 600)); setResizable(false); setDefaultCloseOperation(EXIT_ON_CLOSE); setLayout(new BorderLayout()); health.setPreferredSize(new Dimension(200, 10)); exp.setPreferredSize(new Dimension(200, 10)); currentRoom.setPreferredSize(new Dimension(200, 10)); spacer.setPreferredSize(new Dimension(200, 115)); magicLabel.setPreferredSize(new Dimension(200, 10)); magicLabel.setHorizontalAlignment(JLabel.CENTER); playerItemLabel.setText("Player's Items (Max 1)"); setLabels(); JScrollPane playerItemsPane = new JScrollPane(); playerItemsList.setListData(model.getPlayer().getItemList().toArray()); playerItemsPane.setViewportView(playerItemsList); playerItemsPane.setPreferredSize(new Dimension(200, 125)); JButton drop = new JButton("Drop Item"); drop.addActionListener(this); drop.setPreferredSize(new Dimension(200, 25)); JScrollPane roomItemsPane = new JScrollPane(); roomItemsList = new JList(getRoomItems()); roomItemsPane.setViewportView(roomItemsList); roomItemsPane.setPreferredSize(new Dimension(200, 125)); JButton pickUp = new JButton("Pick Up"); pickUp.addActionListener(this); pickUp.setPreferredSize(new Dimension(200, 25)); JScrollPane hallsPane = new JScrollPane(); hallList = new JList(getHalls()); hallsPane.setViewportView(hallList); hallsPane.setPreferredSize(new Dimension(200, 200)); JButton enterHall = new JButton("Enter Hallway"); enterHall.setPreferredSize(new Dimension(200, 25)); enterHall.addActionListener(this); JScrollPane outputPane = new JScrollPane(); output = new JTextArea(); outputPane.setPreferredSize(new Dimension(550, 550)); output.setEditable(false); output.setBorder(BorderFactory.createLineBorder(Color.black)); outputPane.setViewportView(output); JLabel roomItemLabel = new JLabel("Items in the Room"); JLabel hallsLabel = new JLabel("Hallways"); JPanel rightPanel = new JPanel(); JPanel leftPanel = new JPanel(); rightPanel.add(playerItemLabel); rightPanel.add(playerItemsPane); rightPanel.add(drop); rightPanel.add(roomItemLabel); rightPanel.add(roomItemsPane); rightPanel.add(pickUp); rightPanel.add(magicLabel); rightPanel.add(magic); rightPanel.add(spacer); rightPanel.add(health); rightPanel.add(exp); rightPanel.add(currentRoom); rightPanel.setPreferredSize(new Dimension(200, 600)); rightPanel.setBackground(Color.WHITE); leftPanel.add(hallsLabel); leftPanel.add(hallsPane); leftPanel.add(enterHall); leftPanel.setPreferredSize(new Dimension(200, 600)); leftPanel.setBackground(Color.WHITE); add(outputPane, BorderLayout.CENTER); add(rightPanel, BorderLayout.WEST); add(leftPanel, BorderLayout.EAST); }
/////////////////////////////////// // member functions ////////////////////////////////// protected final void initForm() { thisPanel = new JPanel(); thisPanel.setName("Import Range Data"); thisPanel.setLayout(new java.awt.BorderLayout()); _thePanel.add(thisPanel); _theWarning = new JTextArea(); _theWarning.setEditable(false); String theMessage = "Warning, data imported through this panel has"; theMessage += " speed and course calculated as over the ground."; theMessage += System.getProperties().getProperty("line.separator"); theMessage += "Debrief recognises PC Argos (RAO) and PMRF (PRN) files."; theMessage += System.getProperties().getProperty("line.separator"); theMessage += "See Debrief Help File for file format and details."; _theWarning.setText(theMessage); _theWarning.setLineWrap(true); _theWarning.setBorder(BorderFactory.createLoweredBevelBorder()); _theWarning.setWrapStyleWord(true); thisPanel.add("North", _theWarning); //////////////////////////////////////////// // auto generated stuff //////////////////////////////////////////// ButtonPanel = new javax.swing.JPanel(); importBtn = new javax.swing.JButton(); closeBtn = new javax.swing.JButton(); PropertiesList = new javax.swing.JPanel(); FilenamePanel = new javax.swing.JPanel(); jLabel3 = new javax.swing.JLabel(); FilenameLabel = new javax.swing.JLabel(); selectFileBtn = new javax.swing.JButton(); FrequencyPanel = new javax.swing.JPanel(); FrequencyLabel = new javax.swing.JLabel(); FrequencyCombo = new TimeFrequencyCombo(); OriginPanel = new javax.swing.JPanel(); jLabel7 = new javax.swing.JLabel(); OriginLabel = new javax.swing.JLabel(); selectOriginBtn = new javax.swing.JButton(); DTGPanel = new javax.swing.JPanel(); jLabel9 = new javax.swing.JLabel(); _theDate = new javax.swing.JTextField("2001/01/30"); ///////////////////////////////////////////////// // button panel first ////////////////////////////////////////////////// importBtn.setText("Import"); ButtonPanel.add(importBtn); closeBtn.setText("Close"); ButtonPanel.add(closeBtn); thisPanel.add(ButtonPanel, java.awt.BorderLayout.SOUTH); closeBtn.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent e) { doClose(); } }); importBtn.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent e) { doImport(); } }); /////////////////////////////////////////////////// // now the properties panel /////////////////////////////////////////////////// PropertiesList.setLayout(new java.awt.GridLayout(0, 1)); jLabel3.setText("Filename:"); FilenamePanel.add(jLabel3); FilenameLabel.setText(" blank "); FilenamePanel.add(FilenameLabel); selectFileBtn.setPreferredSize(new java.awt.Dimension(33, 27)); selectFileBtn.setToolTipText("Select file"); selectFileBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); selectFileBtn.setText("..."); selectFileBtn.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent e) { doEditFilename(); } }); FilenamePanel.add(selectFileBtn); PropertiesList.add(FilenamePanel); FrequencyLabel.setText("Frequency:"); FrequencyPanel.add(FrequencyLabel); FrequencyCombo.setPreferredSize(new java.awt.Dimension(100, 25)); FrequencyPanel.add(FrequencyCombo); PropertiesList.add(FrequencyPanel); jLabel7.setText("Origin:"); OriginPanel.add(jLabel7); OriginLabel.setText(" blank "); OriginPanel.add(OriginLabel); selectOriginBtn.setPreferredSize(new java.awt.Dimension(33, 27)); selectOriginBtn.setToolTipText("Select file"); selectOriginBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); selectOriginBtn.setText("..."); selectOriginBtn.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent e) { editOrigin(); } }); OriginPanel.add(selectOriginBtn); PropertiesList.add(OriginPanel); ////////////////////////////////////////////////////// // DTG ///////////////////////////////////////////////////// jLabel9.setText("DTG (yyyy/mm/dd):"); _theDate.setText("2001/01/30"); _theDate.addFocusListener( new FocusAdapter() { public void focusLost(final FocusEvent e) { checkDTG(); } }); DTGPanel.add(jLabel9); DTGPanel.add(_theDate); PropertiesList.add(DTGPanel); final JPanel jp = new JPanel(); jp.setLayout(new FlowLayout()); jp.add(PropertiesList); thisPanel.add(jp, java.awt.BorderLayout.CENTER); }
/* * GUI Code to add a modpack to the selection */ public void addPack(final ModPack pack) { if (!modPacksAdded) { modPacksAdded = true; packs.removeAll(); packs.repaint(); } final int packIndex = packPanels.size(); final JPanel p = new JPanel(); p.setBounds(0, (packIndex * 55), 420, 55); p.setLayout(null); JLabel logo = new JLabel(new ImageIcon(pack.getLogo())); logo.setBounds(6, 6, 42, 42); logo.setVisible(true); JTextArea filler = new JTextArea( pack.getName() + " (v" + pack.getVersion() + ") Minecraft Version " + pack.getMcVersion() + "\n" + "By " + pack.getAuthor()); filler.setBorder(null); filler.setEditable(false); filler.setForeground(LauncherStyle.getCurrentStyle().tabPaneForeground); filler.setBounds(58, 6, 362, 42); filler.setBackground(LauncherStyle.getCurrentStyle().tabPaneBackground); MouseAdapter lin = new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { LaunchFrame.getInstance().doLaunch(); } } @Override public void mousePressed(MouseEvent e) { selectedPack = packIndex; updatePacks(); } }; p.addMouseListener(lin); filler.addMouseListener(lin); logo.addMouseListener(lin); p.add(filler); p.add(logo); packPanels.add(p); packs.add(p); packs.setMinimumSize(new Dimension(420, (packPanels.size() * 55))); packs.setPreferredSize(new Dimension(420, (packPanels.size() * 55))); // // packsScroll.revalidate(); if (pack.getDir().equalsIgnoreCase(getLastPack())) { selectedPack = packIndex; } }
/** initiate panel */ private void init() { txaHint = new JTextArea(); txaHint.setBorder(null); txaHint.setFocusable(false); txaHint.setLineWrap(true); txaHint.setWrapStyleWord(true); txaHint.setOpaque(false); btnHint = new JButton("Hint >>"); btnHint.setBorder(new EmptyBorder(new Insets(0, 0, 0, 0))); txtClassDir = new JTextField(); butSelect = new JButton("Browse.."); chkBoxIncludeClass = new JCheckBox("include .class file only"); chkBoxArchiveType = new JCheckBox("Select for Service Group Archive"); setBackButtonEnabled(true); setFinishButtonEnabled(false); setPageComplete(false); this.setLayout(new GridBagLayout()); this.add( new JLabel("Class file location"), new GridBagConstraints( 0, 0, 1, 1, 0.1, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 10, 0, 0), 0, 0)); this.add( txtClassDir, new GridBagConstraints( 1, 0, GridBagConstraints.RELATIVE, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 1, 1, 1), 0, 0)); txtClassDir.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { update(); } }); this.add( butSelect, new GridBagConstraints( 2, 0, 1, 1, 0.1, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 1, 1, 10), 0, 0)); butSelect.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int returnVal = fileChooser.showOpenDialog(butSelect); if (returnVal == JFileChooser.APPROVE_OPTION) { file = fileChooser.getSelectedFile(); fileChooser.setCurrentDirectory(file); txtClassDir.setText(file.getAbsolutePath()); setPageComplete(true); setNextButtonEnabled(true); } else { txtClassDir.setText(""); } update(); } }); this.add( chkBoxIncludeClass, new GridBagConstraints( 0, 1, GridBagConstraints.REMAINDER, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 10, 1, 1), 0, 0)); chkBoxIncludeClass.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { update(); } }); // this.add(chkBoxArchiveType // , new GridBagConstraints(0, 2, GridBagConstraints.REMAINDER, 1, 0.0, 0.0 // , GridBagConstraints.WEST , GridBagConstraints.HORIZONTAL // , new Insets(5, 10, 1,1), 0, 0)); // chkBoxArchiveType .addActionListener(new ActionListener() { // public void actionPerformed(ActionEvent e) { // update(); // } // }); this.add( btnHint, new GridBagConstraints( 0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 10, 0, 10), 0, 0)); btnHint.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (flag) { btnHint.setText("Hint >>"); txaHint.setText(""); flag = false; } else { btnHint.setText("Hint <<"); txaHint.setText(hint); flag = true; } update(); } }); this.add( txaHint, new GridBagConstraints( 0, 3, GridBagConstraints.REMAINDER, 1, 0.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 10, 10, 10), 0, 0)); }
public WizStepManyTextFields(Wizard w, String instr, Vector strings) { // store wizard? _instructions.setText(instr); _instructions.setWrapStyleWord(true); _instructions.setEditable(false); _instructions.setBorder(null); _instructions.setBackground(_mainPanel.getBackground()); _mainPanel.setBorder(new EtchedBorder()); GridBagLayout gb = new GridBagLayout(); _mainPanel.setLayout(gb); GridBagConstraints c = new GridBagConstraints(); c.ipadx = 3; c.ipady = 3; c.weightx = 0.0; c.weighty = 0.0; c.anchor = GridBagConstraints.EAST; JLabel image = new JLabel(""); // image.setMargin(new Insets(0, 0, 0, 0)); image.setIcon(WIZ_ICON); image.setBorder(null); c.gridx = 0; c.gridheight = GridBagConstraints.REMAINDER; c.gridy = 0; c.anchor = GridBagConstraints.NORTH; gb.setConstraints(image, c); _mainPanel.add(image); c.weightx = 0.0; c.gridx = 2; c.gridheight = 1; c.gridwidth = 3; c.gridy = 0; c.fill = GridBagConstraints.NONE; gb.setConstraints(_instructions, c); _mainPanel.add(_instructions); c.gridx = 1; c.gridy = 1; c.weightx = 0.0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; SpacerPanel spacer = new SpacerPanel(); gb.setConstraints(spacer, c); _mainPanel.add(spacer); c.gridx = 2; c.weightx = 1.0; c.anchor = GridBagConstraints.WEST; c.gridwidth = 1; int size = strings.size(); for (int i = 0; i < size; i++) { c.gridy = 2 + i; String s = (String) strings.elementAt(i); JTextField tf = new JTextField(s, 50); tf.setMinimumSize(new Dimension(200, 20)); tf.getDocument().addDocumentListener(this); _fields.addElement(tf); gb.setConstraints(tf, c); _mainPanel.add(tf); } c.gridx = 1; c.gridy = 3 + strings.size(); c.weightx = 0.0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; SpacerPanel spacer2 = new SpacerPanel(); gb.setConstraints(spacer2, c); _mainPanel.add(spacer2); }