jpanel

How to setting setBorder for window application?

北慕城南 提交于 2020-03-03 10:07:25
问题 I tried create some application for monitoring network. I'm going to create 4 JPanels and insert, for example, panels insert_panel_0 , insert_panel_2 to panel_2 .I can't setting my borders between insert_panel_0 , insert_panel_2 . I have vertical gaps, but i don't have horizontal gaps. Could you help me solve it? import java.awt.Color; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.GridLayout; import java.awt.Toolkit; import javax.swing.JFrame; import javax.swing

Draw Shapes That User Selects

自作多情 提交于 2020-02-16 06:28:39
问题 I need to create a program to draw shapes(user chooses with radio button), and whether or not the shape is filled(user chooses with check box). This is the code I have so far: import javax.swing.*; import java.awt.*; import java.awt.event.*; public class SelectShape extends JFrame implements ItemListener{ private JRadioButton line = new JRadioButton("Line"); private JRadioButton rect = new JRadioButton("Rectangle"); private JRadioButton oval = new JRadioButton("Oval"); private JCheckBox fill

Draw Shapes That User Selects

主宰稳场 提交于 2020-02-16 06:28:19
问题 I need to create a program to draw shapes(user chooses with radio button), and whether or not the shape is filled(user chooses with check box). This is the code I have so far: import javax.swing.*; import java.awt.*; import java.awt.event.*; public class SelectShape extends JFrame implements ItemListener{ private JRadioButton line = new JRadioButton("Line"); private JRadioButton rect = new JRadioButton("Rectangle"); private JRadioButton oval = new JRadioButton("Oval"); private JCheckBox fill

How to align JPanel to bottom of JFrame (java swing)

三世轮回 提交于 2020-02-08 07:40:35
问题 Long story short, I'm making a simple audio player in Java and am starting the GUI; no events, no functionality of any kind as of yet. I'm asking how I can the JPanel with the buttons (controls), to align to the bottom center of the main window (JFrame). Here's the code. import javax.swing.*; import java.awt.*; public class tryingtowindow extends JFrame { //Buttons public JButton rewind; public JButton play; public JButton fastForward; //the window public JFrame UI; public JPanel controls; /

JScrollPane is not Working in JPanel

折月煮酒 提交于 2020-01-30 08:25:13
问题 I have to use JScrollPane in my Project but it is not working. I have pasted my code where I use a JSCrollPane in my main JPanel. frame = new JFrame(); frame.setBounds(100, 100, 1179, 733); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().setLayout(null); JScrollPane scrollPane_1 = new JScrollPane(); scrollPane_1.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); scrollPane_1.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL

JScrollPane is not Working in JPanel

倾然丶 夕夏残阳落幕 提交于 2020-01-30 08:24:06
问题 I have to use JScrollPane in my Project but it is not working. I have pasted my code where I use a JSCrollPane in my main JPanel. frame = new JFrame(); frame.setBounds(100, 100, 1179, 733); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().setLayout(null); JScrollPane scrollPane_1 = new JScrollPane(); scrollPane_1.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); scrollPane_1.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL

Unable to remove JLabel from JPanel after adding programmatically

て烟熏妆下的殇ゞ 提交于 2020-01-30 07:58:49
问题 I have a class called LMSPanel that extends JPanel . This class has the two following methods: /** * A method to add an informative temporary label to the Panel until * the second Sensor is added. * * @param zoneid - The ID of the Zone. * @param sensorid - The ID of the Sensor. */ public void justAddedLbl(String zoneid, String sensorid) { infoLbl = new JLabel("Sensor: " + zoneid + sensorid + " added. Please Add 2nd Sensor."); add(infoLbl); revalidate(); } /** * A method to remove the

Unable to remove JLabel from JPanel after adding programmatically

我怕爱的太早我们不能终老 提交于 2020-01-30 07:58:31
问题 I have a class called LMSPanel that extends JPanel . This class has the two following methods: /** * A method to add an informative temporary label to the Panel until * the second Sensor is added. * * @param zoneid - The ID of the Zone. * @param sensorid - The ID of the Sensor. */ public void justAddedLbl(String zoneid, String sensorid) { infoLbl = new JLabel("Sensor: " + zoneid + sensorid + " added. Please Add 2nd Sensor."); add(infoLbl); revalidate(); } /** * A method to remove the

Java Swing: Access panel components from another class

假如想象 提交于 2020-01-29 20:33:27
问题 Hi i basically have two classes, one main and one just to separate the panels, just for code readability really. i have : public class Main{ public static void main (String args[]) { JFrame mainJFrame; mainJFrame = new JFrame(); //some other code here CenterPanel centerPanel = new CenterPanel(); centerPanel.renderPanel(); mainFrame.add(centerPanel.getGUI()); } } class CenterPanel{ JPanel center = new JPanel(); public void renderPanel(){ JButton enterButton = new JButton("enter"); JButton

How to remove a JButton in a JButton matrix?

故事扮演 提交于 2020-01-25 14:16:55
问题 I want to remove a certain botton using MouseListener from a matrix of bottons and add a JLabel in the empty, so I use: import java.awt.*; import java.awt.event.*; import javax.swing.*; public MyClass(){ object = new Object(); bottons = new JButton[5][5]; labels = new JLabel[5][5]; myPanel = new JPanel(); myPanel.setLayout(new GridLayout(5,5)); click =false; for(int i = 0 ; i<5 ; i++){ for(int j = 0; j<5 ; j++){ myPanel.add(bottons[i][j] = new JButton()); } } } public void mouseReleased