jbutton

How to change jButton value when clicked

别说谁变了你拦得住时间么 提交于 2021-02-08 10:09:38
问题 I kept getting errors while compiling. I have no idea how to use the list generated integers and display it into the jButtons after clicking. public static void Random () { int Rand [] = new int [49]; for (int b = 0; b < 49; b++) Rand [b] = b; List<Integer> alist = Arrays.stream(Rand) .boxed() .map (x -> x + 1) .collect (Collectors.toList()); Collections.shuffle(alist); } private class HandleTextField implements ActionListener { @Override public void actionPerformed(ActionEvent event) { for

Unable to add JButtons wrapped in JPanel into JTable

北城以北 提交于 2021-02-08 09:28:14
问题 I am having a JTable , where the final column of the table is for adding 2 buttons. Below is the format of my JTable . Below is my code private class ViewLawyersDisplayData extends ComponentAdapter { @Override public void componentShown(ComponentEvent e) { dbConnector = new DBHandler(); dbConnector.makeConnection(); ResultSet rs = dbConnector.selectAllLawyerDetails(); if(rs==null) { JOptionPane.showMessageDialog(null,"The table is empty"); } else { try { while(rs.next()) { int id = rs.getInt(

Not all of my JButtons are showing up after I add a dozen of them. What am I doing wrong?

烂漫一生 提交于 2021-01-29 22:43:24
问题 I want to add 52 buttons in a JPanel. All with ActionListeners. When I reach a certain amount (13) and run the program, not all of the buttons show up. For example I've added 15 buttons and only 9 or 12 of them show up. Sometimes all of them, but not every time. Here's the code for two of the JButtons: JButton button_one=new JButton(); button_one.setPreferredSize(new Dimension(100,150)); mainpanel.add(button_one); button_one.addActionListener(new ActionListener(){ @Override public void

Not all of my JButtons are showing up after I add a dozen of them. What am I doing wrong?

北城余情 提交于 2021-01-29 22:40:49
问题 I want to add 52 buttons in a JPanel. All with ActionListeners. When I reach a certain amount (13) and run the program, not all of the buttons show up. For example I've added 15 buttons and only 9 or 12 of them show up. Sometimes all of them, but not every time. Here's the code for two of the JButtons: JButton button_one=new JButton(); button_one.setPreferredSize(new Dimension(100,150)); mainpanel.add(button_one); button_one.addActionListener(new ActionListener(){ @Override public void

Not all of my JButtons are showing up after I add a dozen of them. What am I doing wrong?

|▌冷眼眸甩不掉的悲伤 提交于 2021-01-29 22:02:13
问题 I want to add 52 buttons in a JPanel. All with ActionListeners. When I reach a certain amount (13) and run the program, not all of the buttons show up. For example I've added 15 buttons and only 9 or 12 of them show up. Sometimes all of them, but not every time. Here's the code for two of the JButtons: JButton button_one=new JButton(); button_one.setPreferredSize(new Dimension(100,150)); mainpanel.add(button_one); button_one.addActionListener(new ActionListener(){ @Override public void

Buttons overlap or disappear

你。 提交于 2021-01-29 20:24:08
问题 I have an example of a error in my program. I created 4 buttons: 1, 2, 3, 4. Button 2 overlaps button 4, and i just added events for 2 and 4. If I click on Button 2, it will be hidden, and Button 4 will be displayed. And if I click on Button 4, Button 2 will be displayed, and Button 4 will be covered by Button 2 again. As if anything happened, but, when I click on Button 1 or Button 3 after doing the above, Button 4 will be displayed, when I point at it (not click), it will disappear. public

Java swing metal JButton focus border size

血红的双手。 提交于 2021-01-29 03:07:02
问题 If I set Metal theme for Swing GUI, JButton border is painted around the whole button, but focus border is painted only around JButton's text and icon, so if text size is smaller than button size, the border appears inside button. Most replies to this problem simply suggest to disable global focus border painting by UIManager.getLookAndFeelDefaults().put("Button.focus", new ColorUIResource(new Color(0, 0, 0, 0))); or per-button by jButton.setFocusPainted(false); But I actually want focus

Java swing metal JButton focus border size

a 夏天 提交于 2021-01-29 03:03:26
问题 If I set Metal theme for Swing GUI, JButton border is painted around the whole button, but focus border is painted only around JButton's text and icon, so if text size is smaller than button size, the border appears inside button. Most replies to this problem simply suggest to disable global focus border painting by UIManager.getLookAndFeelDefaults().put("Button.focus", new ColorUIResource(new Color(0, 0, 0, 0))); or per-button by jButton.setFocusPainted(false); But I actually want focus

how to set jbutton icon for specific time to show when it is clicked and how to disappear the icon when time finished

故事扮演 提交于 2021-01-28 07:16:57
问题 how to code java for set timer to my button for set button icon when i clicked and some time delay for process while my button icon has to show then the icon have to set null for time end. i have tried following way but it is work when i am not to clicked the button private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) { timer = new Timer(5000, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if(chromeShown) { jButton3.setIcon(new javax.swing

Java swing JButton/JLabel: icons are not displayed in their original size

帅比萌擦擦* 提交于 2021-01-11 02:54:12
问题 I have png icons and use them as icons in JButton / JLabel . The problem is that the image displayed at runtime is larger than the original icon, and because of this resizing, it's super ugly. Here is an example: Original icon (left) and how it's rendered in the JButton (right) The source code for this minimal example is simply: public class Main { public static void main(String... args) { JFrame frame = new JFrame("Test"); frame.setBounds(0, 0, 120, 80); frame.setDefaultCloseOperation(JFrame