jtextfield

HTML in JTextArea of JEditorPane, JTextPane

家住魔仙堡 提交于 2019-12-24 04:44:04
问题 Right I already worked out that JTextArea or JTextField don't support HTML. I want to add text to a "screen" like a JTextArea and later keep appending text to it. I tried with JTextArea which worked wonderfully, but it does not support formatting it seems... So I tried using JEditorPane's subclass JTextPane, but this one does not have it's append function... Can someone guid me in the right direction how I easily can append text to a JTextPane or format a JTextArea. Or if there is any other

Why my JTextField has changed after set new Border

梦想的初衷 提交于 2019-12-24 04:12:42
问题 I would like to know why my element JTextField has change height after setting a new Border: packagesAddField.setBorder(BorderFactory.createLineBorder(Color.RED)); after this code my JTextField changing a height (about 1px from upper and 1px from footer). It is possible, when i set some border he can change appearance of component? 回答1: In a word, don't. The setBorder() API recommends that you add the border to the enclosing container: Although technically you can set the border on any object

Why my JTextField has changed after set new Border

三世轮回 提交于 2019-12-24 04:12:13
问题 I would like to know why my element JTextField has change height after setting a new Border: packagesAddField.setBorder(BorderFactory.createLineBorder(Color.RED)); after this code my JTextField changing a height (about 1px from upper and 1px from footer). It is possible, when i set some border he can change appearance of component? 回答1: In a word, don't. The setBorder() API recommends that you add the border to the enclosing container: Although technically you can set the border on any object

Why my JTextField has changed after set new Border

眉间皱痕 提交于 2019-12-24 04:12:06
问题 I would like to know why my element JTextField has change height after setting a new Border: packagesAddField.setBorder(BorderFactory.createLineBorder(Color.RED)); after this code my JTextField changing a height (about 1px from upper and 1px from footer). It is possible, when i set some border he can change appearance of component? 回答1: In a word, don't. The setBorder() API recommends that you add the border to the enclosing container: Although technically you can set the border on any object

Add JTextField to Game Menu (graphics2d)

房东的猫 提交于 2019-12-24 01:45:31
问题 I'm developing a multiplayer game, and at the menu, I need to add a field, where the player can type the host-ip. I'm making the menu with Graphics2D, and I'm updating it in a loop: JFrame screenFrame = screen.getFullScreenWindow(); while (menuIsRunning) { Graphics2D g = screen.getGraphics(); renderer.drawMenu(g, screen.getWidth(), screen.getHeight(), menuObjects); screenFrame.getLayeredPane().paintComponents(g); g.dispose(); screen.update(); } And there I want to add a JTextField too, like

How to point out which jTextfield is empty [duplicate]

大兔子大兔子 提交于 2019-12-24 00:32:55
问题 This question already has answers here : How to check which JTextFields are empty and inform the user about them? (2 answers) Closed 3 years ago . I have this code sample to see which Jtextfield is empty. I have attached a image of my application too. All I need to know is that, when a user was not entering the details in a specific jTextfield, and click "Register" button, I want the user to be informed about his mistake/s like; "You haven't entered Student Middle Name" or "You have not

Border Layout not working

旧时模样 提交于 2019-12-23 23:36:29
问题 I've been trying to setup this border layout for hours. I've looked up How to Use BorderLayout on the Java website but I still haven't gotten it. I've included my code below for review and to make it easier to see how I am trying to use the BorderLayout function. How do I setup a border layout on JL3? class GameStructure { private String []wordList = {"computer","java","activity","alaska","appearance","article", "automobile","basket","birthday","canada","central","character","chicken","chosen

Get focus on a JTextField inside a CardLayout

佐手、 提交于 2019-12-23 22:44:28
问题 I have a JTextField inside a JPanel A which is a part of CardLayout . When this A gets shown, I want to set the focus automatically to the JTextField (i.e. the cursor is flashing in the text field so the user doesn't need to click on it to enable the input). I tried calling requestFocusInWindow() on the JTextField object at initialization, but that doesn't seem to work. Do I need to call this method every time when A gets displayed? Thanks. 回答1: Maybe you can try requestFocusInWindow() when

How to only allow capital letters in Java GUI?

让人想犯罪 __ 提交于 2019-12-23 20:03:06
问题 I want to be able to input only capital letters to my GUI and so I just need the easiest way to cap/stop people from entering lowercase. JTextField jt = new JTextField(12); 回答1: Use a DocumentFilter Take a look at Implementing a Document Filter for details and MDP's Weblog for examples import java.awt.EventQueue; import java.awt.GridBagLayout; import javax.swing.JFrame; import javax.swing.JTextField; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import

JTextField that has inner fields or preformated format, something like the ip field in windows

感情迁移 提交于 2019-12-23 17:51:26
问题 I want to create a text field that will be for dates and will have dd.mm.YYYY format. Now what I want the user to type only the numbers, not the dots to. So the field would be like: _ _. _ _ . _ _ _ _ So when the user wants to type the date: 15.05.2010 for example, he will only type the numbers in the sequence 15052010. Also I would like, when he presses on left or right arrow, the cursor to go from one field (not JTextField, but field in the JTextField) to the next. So lets say I have