JFrame frame = new JFrame(); JPanel panel = new JPanel(); frame.getContentPane().add(panel); panel.setFocusable(true); panel.requestFocusInWindow(); frame.setVisible(true);
constraints.fill = GridBagConstraints.BOTH; JLabel l = new JLabel("You have got 2 new Messages."); panel.add(l, constraints); constraints.gridx++; constraints.weightx = 0f; b.setOpaque(false); b.setMargin(new Insets(1, 4, 1, 4)); b.setFocusable(false); panel.add(b, constraints); dialog.setUndecorated(true); dialog.setSize(300, 100);
setFocusable(true); requestFocusInWindow(); ArrowTest mainPanel = new ArrowTest(); JFrame frame = new JFrame("ArrowTest"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(mainPanel); frame.pack(); frame.setLocationByPlatform(true); frame.setVisible(true);
l.setOpaque(false); c.add(l, constraints); b.setFocusable(false); c.add(b, constraints);
ta.setFocusable(false); return ta; JPanel fontTable = new JPanel(new BorderLayout(3, 1)); fontTable.setFocusable(true); JPanel fontNameCol = new JPanel(new GridLayout(0, 1, 2, 2)); JPanel fontExampleCol = new JPanel(new GridLayout(0, 1, 2, 2)); fontTable.add(fontNameCol, BorderLayout.WEST); fontTable.add(fontExampleCol, BorderLayout.CENTER); for (int ii = 0; ii < fonts.length; ii++) { fontNameCol.add(new JLabel(fonts[ii])); fontExampleCol.add(getExampleOfFont(fonts[ii])); p.add(tabPane, BorderLayout.CENTER); p.setPreferredSize(new Dimension(400, 400)); JFrame f = new JFrame("Properties"); f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); f.getContentPane().add(p, BorderLayout.CENTER); f.pack(); f.setMinimumSize(f.getPreferredSize()); f.setSize(600, 500); f.setLocationRelativeTo(null); f.setVisible(true);
textArea.setLineWrap(true); textArea.setEditable(false); textArea.setFocusable(false); panel.add(button, BorderLayout.NORTH); panel.add(new JScrollPane(textArea), BorderLayout.CENTER);
JFrame frame = new JFrame("WindowCommunication"); frame.getContentPane().add(new MyFramePanel()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); field.setFocusable(false); add(field); add(openDialogeBtn); ModalityType.APPLICATION_MODAL); dialog.getContentPane().add(dialogPanel); dialog.pack(); dialog.setLocationRelativeTo(null);
JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); p.add(f); frame.add(p); frame.pack(); frame.setVisible(true); lastFocusableIndex = 0; sl.setFocused(false); autoSuggestionPopUpWindow.setVisible(false); setFocusToTextField(); autoSuggestionPopUpWindow.setVisible(false); setFocusToTextField(); suggestionsPanel.add(suggestionLabel); setFocusable(true); setForeground(suggestionsTextColor);
contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS)); contentPane.add( nullTraversalKeys() ); contentPane.add( writeYourOwnAction() ); contentPane.add( useKeyListener() ); contentPane.add( addTraversalKeys() ); textArea.setText("Use Key Listener\n2\n3\n4\n5\n6\n7\n8\n9"); JScrollPane scrollPane = new JScrollPane( textArea ); scrollPane.getVerticalScrollBar().setFocusable(false); textArea.setText("Add Traversal Keys\n2\n3\n4\n5\n6\n7\n8\n9"); JScrollPane scrollPane = new JScrollPane( textArea ); scrollPane.getVerticalScrollBar().setFocusable(false); frame.setDefaultCloseOperation( EXIT_ON_CLOSE ); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true);
ui.add(text, BorderLayout.PAGE_START); io = new JTextField(15); Font font = io.getFont(); io.setFont(font); io.setHorizontalAlignment(SwingConstants.TRAILING); io.setFocusable(false); text.add(io); ui.add(buttons, BorderLayout.CENTER); String[] keyValues = { "7", "8", "9", "/", public void run() { ScriptEngineCalculator sc = new ScriptEngineCalculator(); JFrame f = new JFrame("Calculet"); f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); f.setContentPane(sc.getUI()); f.pack(); f.setMinimumSize(f.getSize()); f.setLocationByPlatform(true); f.setVisible(true);
private static final int HEIGHT = 800; private Random random = new Random(); private JFrame frame = new JFrame("SimplePaintSurface"); private JPanel tableaux; addRandom(); frame.add(tableaux, BorderLayout.CENTER); JButton add = new JButton("Add"); add.addActionListener(this); frame.add(add, BorderLayout.SOUTH); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(WIDTH, HEIGHT); frame.setLocationRelativeTo(null); frame.setVisible(true); tableaux.requestFocusInWindow(); Letter letter = new Letter(Character.toString((char) ('a' + random.nextInt(26)))); letter.setBounds(random.nextInt(WIDTH), random.nextInt(HEIGHT), 16, 16); tableaux.add(letter); setFocusable(true); setBackground(Color.RED); font1 = getFont();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); closeLabel.addKeyListener(this); closeLabel.setFocusable(true); add(closeLabel); pack(); setVisible(true);
JTextArea chatArea = new JTextArea(8, 40); chatArea.setEditable(false); chatArea.setFocusable(false); JScrollPane chatScroll = new JScrollPane(chatArea); JPanel chatPanel = new JPanel(new BorderLayout()); chatPanel.add(new JLabel("Chat:", SwingConstants.LEFT), BorderLayout.PAGE_START); chatPanel.add(chatScroll); JPanel inputPanel = new JPanel(); inputPanel.setLayout(new BoxLayout(inputPanel, BoxLayout.LINE_AXIS)); inputPanel.add(inputField); inputPanel.add(sendBtn); mainPanel.add(inputPanel); JFrame frame = new JFrame("Foo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(mainPanel); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true);
fields.setFocusable(false); // so we can't write directly into JTextArea JScrollPane scrollPane = new JScrollPane(fields); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); add(scrollPane, BorderLayout.CENTER); add(input, BorderLayout.PAGE_END); LayoutEg mainPanel = new LayoutEg(); JFrame frame = new JFrame("Story GUI"); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.getContentPane().add(mainPanel); frame.pack(); frame.setLocationByPlatform(true); frame.setVisible(true);
this.setFocusable(true); this.addKeyListener(this); this.add(comboBox); comboBox.setFocusable(false); JFrame frame = new JFrame(); frame.setSize(640, 480); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(panel); frame.setVisible(true);
public void run() { JFrame f = new JFrame ("Output"); textArea.setFocusable(false); // you might want to turn off the possibility to select the text inside the textArea, comment out this line if you don't for (String e : t) if(e.startsWith("A")) textArea.append(e + separator); f.add(textArea); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.pack(); f.setLocationRelativeTo(null); f.setVisible(true);
text.setFocusable(false); JScrollPane scrollPane = new JScrollPane(text); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); buttonPanel.add(new JButton(new ButtonAction("Press Me"))); add(scrollPane); add(buttonPanel, BorderLayout.PAGE_END); JFrame frame = new JFrame("Tester2"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(new Tester2()); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true);
textarea.setLineWrap(true); textarea.setEditable(false); textarea.setFocusable(false); JScrollPane scrollpane = new JScrollPane(textarea); scrollpane topPanel.add(scrollpane); topPanel.add(new JButton(new AbstractAction("Press Me") { mainPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); mainPanel.add(topPanel, BorderLayout.PAGE_START); mainPanel.add(scrollpane, BorderLayout.CENTER); JFrame frame = new JFrame("Layout Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(mainPanel); frame.pack(); frame.setLocationByPlatform(true); frame.setVisible(true);
resultField.setFocusable(false); add(new JLabel("Value:")); add(valueInputField); add(findColorButton); add(new JLabel("Result:")); add(resultField); ResistorGui mainPanel = new ResistorGui(); JFrame frame = new JFrame("ResistorGui"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(mainPanel); frame.pack(); frame.setLocationByPlatform(true); frame.setVisible(true);
final JFrame frame1 = new JFrame("frame 1"); final JFrame frame2 = new JFrame("frame 2"); final JButton button = new JButton("Button"); final JTextField textFieald = new JTextField("0"); button.setFocusable(false); button.addActionListener(new ActionListener() { @Override frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame1.getContentPane().add(button); frame1.pack(); frame1.setLocationRelativeTo(null); frame1.setVisible(true); frame2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame2.getContentPane().add(textFieald); frame2.pack(); frame2.setLocationRelativeTo(null); frame2.setVisible(true);