1. JLabel - get parent panel? stackoverflow.comIs it possible to get the name of the panel that a JLabel is added to? I added some JLabels to different JPanels, and I want to call different mouse events according ... |
2. Removing JLabels with the "same" name stackoverflow.comI'm doing a 4 in a row game, and i'm adding the red or green piece as a label, but always the same label, to the panel game. My code is ... |
3. Jlabel pushing graphics panel out of view coderanch.com// import javax.swing.*; import java.awt.*; import java.awt.geom.*; public class MA extends JApplet { public void init() { Container content = getContentPane(); content.setLayout(new BorderLayout()); // Try this. Layouts require imaginative experimenting. // The class api for the various layout manager classes have // a lot of information and some examples. The tutorial has // helpful pages on using ... |
4. Spreading out JLabels in a panel coderanch.comHere's my code: package scoresheet; import javax.swing.*; import javax.swing.BorderFactory; import javax.swing.table.*; import java.awt.event.*; import java.awt.*; public class ScoreSheet { /* Table Creation Start*/ String[] columnNames = {"Rank", "Name", "Material Total", "Presentation Total", "Total"}; Object[][] data = { {"","","","",""}, {"","","","",""} }; JTable table = new JTable(data, columnNames){ @Override public boolean isCellEditable(int row, int column){ return false; } }; /* Table Creation End*/ ... |
5. Working with Labels on Panels. java-forums.orgHi, Im new here and I have 2 questions. 1) I have added some labels into a panel and by default they all align in the center of the screen. How do I align them all to the left? I have tried using the following but nothing works: label = new JLabel(text, SwingConstants.LEFT); and label.setVerticalTextPosition(JLabel.LEFT); label.setHorizontalTextPosition(JLabel.LEFT); 2) I have one panel ... |
6. How to move JLabel around on a panel java-forums.orgpackage chapter3; import java.awt.Color; import java.awt.Dimension; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.SwingConstants; public class Panel { public static void main(String[] args) { Color myColor = new Color(255, 0, 120); //Subpanel JPanel subpanel = new JPanel(); subpanel.setPreferredSize(new Dimension(150, 150)); subpanel.setBackground(myColor); JLabel label = new JLabel("Some text"); label.setAlignmentX(SwingConstants.LEFT); //not working label.setAlignmentX(0); //not working label.setHorizontalAlignment(SwingConstants.LEFT); //not working label.setHorizontalAlignment(0); //not working subpanel.add(label); //Main ... |